Skip to content

Commit

Permalink
Merge pull request #124 from SongStitch/feature/use-upx
Browse files Browse the repository at this point in the history
compress binary with upx and re-add -s -w flags
  • Loading branch information
BradLewis authored Aug 10, 2023
2 parents df2c48f + 2c780ef commit 1481198
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ WORKDIR /app/ui
COPY ui ./
RUN npm install && npm run build

FROM golang:1.21-bookworm AS builder
FROM golang:1.21-bullseye AS builder

WORKDIR /app

Expand All @@ -23,6 +23,7 @@ RUN apt-get update \
&& apt-get install -y --no-install-recommends \
minify \
libwebp-dev \
upx-ucl \
&& find ./public -type f \( \
-name "*.html" \
-o -name '*.js' \
Expand All @@ -31,7 +32,8 @@ RUN apt-get update \
-print0 | \
xargs -0 -I '{}' sh -c 'minify -o "{}" "{}"'

RUN CGO_ENABLED=1 GOOS=linux go build -ldflags="-linkmode 'external' -extldflags '-static'" -o ./bin/song-stitch cmd/*.go
RUN CGO_ENABLED=1 GOOS=linux go build -ldflags="-s -w -linkmode 'external' -extldflags '-static'" -o ./bin/song-stitch cmd/*.go \
&& upx ./bin/song-stitch

FROM gcr.io/distroless/static-debian11:nonroot AS build-release-stage

Expand Down

0 comments on commit 1481198

Please sign in to comment.