diff --git a/Dockerfile b/Dockerfile index dabaf7f1..6b739a3c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,6 +15,7 @@ COPY . . ENV CGO_ENABLED=1 ENV CGO_CFLAGS="-D_LARGEFILE64_SOURCE" +RUN go run ./cmd/genassets RUN go build -ldflags "-w -s" -o build/x-ui main.go RUN ./DockerInit.sh "$TARGETARCH" diff --git a/README.md b/README.md index 45e87ad4..58379f34 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,17 @@ bash <(curl -Ls https://raw.githubusercontent.com/Sora39831/3x-ui/master/install For full documentation, please visit the [project Wiki](https://github.com/Sora39831/3x-ui/wiki). +## Building from source + +Generate fingerprinted frontend assets before compiling: + +```bash +go run ./cmd/genassets +go build -ldflags "-w -s" -o build/x-ui main.go +``` + +Production builds embed files from `web/public/assets` and `web/public/assets-manifest.json`. + ## A Special Thanks to - [alireza0](https://github.com/alireza0/) diff --git a/web/asset_manifest_test.go b/web/asset_manifest_test.go index 1d06532c..e0cffa29 100644 --- a/web/asset_manifest_test.go +++ b/web/asset_manifest_test.go @@ -85,3 +85,11 @@ func TestAssetRequestCacheControlDoesNotMarkMissingFingerprintPathImmutable(t *t t.Fatalf("expected missing asset path to avoid immutable cache-control, got %q", got) } } + +func TestAssetCacheControlForLogicalPathIsShortLived(t *testing.T) { + got := assetCacheControl("js/websocket.js") + want := "public, max-age=300" + if got != want { + t.Fatalf("expected %q, got %q", want, got) + } +}