From 80e5528ed12d7f70211708d5a3b598bd0b5196a1 Mon Sep 17 00:00:00 2001 From: "VanCuren, Logan" Date: Tue, 29 Nov 2022 09:57:31 -0800 Subject: [PATCH 1/4] Adding the output from update.sh script to .gitigore. --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index c69ed5b..a3583e8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ vendor/ +# Ignore the binary output directory (result of running update.sh). +/out/ From b8571318b1161d8b5722863876ba355d9dc1e1c9 Mon Sep 17 00:00:00 2001 From: "VanCuren, Logan" Date: Tue, 29 Nov 2022 09:57:52 -0800 Subject: [PATCH 2/4] Bash formatting and lint corrections in update.sh. --- update.sh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/update.sh b/update.sh index ac1f0ef..a4fbb16 100755 --- a/update.sh +++ b/update.sh @@ -2,7 +2,7 @@ set -e -if [ $# -eq 0 ] ; then +if [ $# -eq 0 ]; then echo "Usage: ./update.sh v#.#.#" exit fi @@ -15,18 +15,18 @@ ID=$(docker create sfs-builder) rm -rf out mkdir -p out -docker cp $ID:/build/pkg/linux-amd64/serve ./out/static-file-server-$VERSION-linux-amd64 -docker cp $ID:/build/pkg/linux-i386/serve ./out/static-file-server-$VERSION-linux-386 -docker cp $ID:/build/pkg/linux-arm6/serve ./out/static-file-server-$VERSION-linux-arm6 -docker cp $ID:/build/pkg/linux-arm7/serve ./out/static-file-server-$VERSION-linux-arm7 -docker cp $ID:/build/pkg/linux-arm64/serve ./out/static-file-server-$VERSION-linux-arm64 -docker cp $ID:/build/pkg/darwin-amd64/serve ./out/static-file-server-$VERSION-darwin-amd64 -docker cp $ID:/build/pkg/win-amd64/serve.exe ./out/static-file-server-$VERSION-windows-amd64.exe +docker cp "${ID}:/build/pkg/linux-amd64/serve" "./out/static-file-server-${VERSION}-linux-amd64" +docker cp "${ID}:/build/pkg/linux-i386/serve" "./out/static-file-server-${VERSION}-linux-386" +docker cp "${ID}:/build/pkg/linux-arm6/serve" "./out/static-file-server-${VERSION}-linux-arm6" +docker cp "${ID}:/build/pkg/linux-arm7/serve" "./out/static-file-server-${VERSION}-linux-arm7" +docker cp "${ID}:/build/pkg/linux-arm64/serve" "./out/static-file-server-${VERSION}-linux-arm64" +docker cp "${ID}:/build/pkg/darwin-amd64/serve" "./out/static-file-server-${VERSION}-darwin-amd64" +docker cp "${ID}:/build/pkg/win-amd64/serve.exe" "./out/static-file-server-${VERSION}-windows-amd64.exe" -docker rm -f $ID +docker rm -f "${ID}" docker rmi sfs-builder -docker buildx build --push --platform linux/arm/v7,linux/arm64/v8,linux/amd64 --tag halverneus/static-file-server:$VERSION . +docker buildx build --push --platform linux/arm/v7,linux/arm64/v8,linux/amd64 --tag "halverneus/static-file-server:${VERSION}" . docker buildx build --push --platform linux/arm/v7,linux/arm64/v8,linux/amd64 --tag halverneus/static-file-server:latest . -echo "Done" \ No newline at end of file +echo "Done" From bacce33bb6be50f3f1c67c24b538917f08432d3f Mon Sep 17 00:00:00 2001 From: "VanCuren, Logan" Date: Tue, 29 Nov 2022 09:59:10 -0800 Subject: [PATCH 3/4] Strip symbol table and debug info to reduce the size of release binaries. --- Dockerfile.all | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Dockerfile.all b/Dockerfile.all index e57f816..84fbe80 100644 --- a/Dockerfile.all +++ b/Dockerfile.all @@ -9,13 +9,13 @@ WORKDIR ${BUILD_DIR} COPY . . RUN go test -cover ./... -RUN GOOS=linux GOARCH=amd64 go build -a -tags netgo -installsuffix netgo -ldflags "-X github.com/halverneus/static-file-server/cli/version.version=${VERSION}" -o pkg/linux-amd64/serve /build/bin/serve -RUN GOOS=linux GOARCH=386 go build -a -tags netgo -installsuffix netgo -ldflags "-X github.com/halverneus/static-file-server/cli/version.version=${VERSION}" -o pkg/linux-i386/serve /build/bin/serve -RUN GOOS=linux GOARCH=arm GOARM=6 go build -a -tags netgo -installsuffix netgo -ldflags "-X github.com/halverneus/static-file-server/cli/version.version=${VERSION}" -o pkg/linux-arm6/serve /build/bin/serve -RUN GOOS=linux GOARCH=arm GOARM=7 go build -a -tags netgo -installsuffix netgo -ldflags "-X github.com/halverneus/static-file-server/cli/version.version=${VERSION}" -o pkg/linux-arm7/serve /build/bin/serve -RUN GOOS=linux GOARCH=arm64 go build -a -tags netgo -installsuffix netgo -ldflags "-X github.com/halverneus/static-file-server/cli/version.version=${VERSION}" -o pkg/linux-arm64/serve /build/bin/serve -RUN GOOS=darwin GOARCH=amd64 go build -a -tags netgo -installsuffix netgo -ldflags "-X github.com/halverneus/static-file-server/cli/version.version=${VERSION}" -o pkg/darwin-amd64/serve /build/bin/serve -RUN GOOS=windows GOARCH=amd64 go build -a -tags netgo -installsuffix netgo -ldflags "-X github.com/halverneus/static-file-server/cli/version.version=${VERSION}" -o pkg/win-amd64/serve.exe /build/bin/serve +RUN GOOS=linux GOARCH=amd64 go build -a -tags netgo -installsuffix netgo -ldflags "-s -w -X github.com/halverneus/static-file-server/cli/version.version=${VERSION}" -o pkg/linux-amd64/serve /build/bin/serve +RUN GOOS=linux GOARCH=386 go build -a -tags netgo -installsuffix netgo -ldflags "-s -w -X github.com/halverneus/static-file-server/cli/version.version=${VERSION}" -o pkg/linux-i386/serve /build/bin/serve +RUN GOOS=linux GOARCH=arm GOARM=6 go build -a -tags netgo -installsuffix netgo -ldflags "-s -w -X github.com/halverneus/static-file-server/cli/version.version=${VERSION}" -o pkg/linux-arm6/serve /build/bin/serve +RUN GOOS=linux GOARCH=arm GOARM=7 go build -a -tags netgo -installsuffix netgo -ldflags "-s -w -X github.com/halverneus/static-file-server/cli/version.version=${VERSION}" -o pkg/linux-arm7/serve /build/bin/serve +RUN GOOS=linux GOARCH=arm64 go build -a -tags netgo -installsuffix netgo -ldflags "-s -w -X github.com/halverneus/static-file-server/cli/version.version=${VERSION}" -o pkg/linux-arm64/serve /build/bin/serve +RUN GOOS=darwin GOARCH=amd64 go build -a -tags netgo -installsuffix netgo -ldflags "-s -w -X github.com/halverneus/static-file-server/cli/version.version=${VERSION}" -o pkg/darwin-amd64/serve /build/bin/serve +RUN GOOS=windows GOARCH=amd64 go build -a -tags netgo -installsuffix netgo -ldflags "-s -w -X github.com/halverneus/static-file-server/cli/version.version=${VERSION}" -o pkg/win-amd64/serve.exe /build/bin/serve # Metadata LABEL life.apets.vendor="Halverneus" \ From 8a0f6598b3c325aee74eccd42444732516fa98d3 Mon Sep 17 00:00:00 2001 From: "VanCuren, Logan" Date: Tue, 29 Nov 2022 10:05:33 -0800 Subject: [PATCH 4/4] Strip symbol table and debug info to reduce the size of release docker image. --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 3faac2e..51fff03 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,7 +15,7 @@ RUN go mod download COPY . . RUN go test -cover ./... -RUN go build -a -tags netgo -installsuffix netgo -ldflags "-X github.com/halverneus/static-file-server/cli/version.version=${VERSION}" -o /serve /build/bin/serve +RUN go build -a -tags netgo -installsuffix netgo -ldflags "-s -w -X github.com/halverneus/static-file-server/cli/version.version=${VERSION}" -o /serve /build/bin/serve RUN adduser --system --no-create-home --uid 1000 --shell /usr/sbin/nologin static