Skip to content

Commit 2b217f5

Browse files
committed
dockerfile: add upx optimization
1 parent 62508f8 commit 2b217f5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ FROM golang:1.24 AS build
44
# Set the working directory inside the container
55
WORKDIR /app
66

7+
RUN apt update -y && apt install -y \
8+
upx
9+
710
# Copy the Go module files first and download dependencies
811
COPY go.mod go.sum ./
912
RUN go mod download
@@ -12,7 +15,7 @@ RUN go mod download
1215
COPY . .
1316

1417
# Build the application
15-
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w" -o app ./cmd/app/main.go
18+
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w" -o app ./cmd/app/main.go && upx --ultra-brute --lzma /app/app
1619

1720
# Use a minimal base image for the final container
1821
FROM scratch

0 commit comments

Comments
 (0)