Skip to content

Commit

Permalink
use upx and use alpine base image for running the app
Browse files Browse the repository at this point in the history
  • Loading branch information
Divkix committed May 30, 2023
1 parent 6e2bf39 commit d4e1ff3
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
@@ -1,11 +1,13 @@
# Build Stage: Build bot using the golang image
FROM golang:1.20-alpine AS builder
RUN apk add --no-cache curl wget gnupg git upx
WORKDIR /app
COPY . .
RUN CGO_ENABLED=0 GOOS=`go env GOHOSTOS` GOARCH=`go env GOHOSTARCH` go build -o out/aliveimage
RUN CGO_ENABLED=0 GOOS=`go env GOHOSTOS` GOARCH=`go env GOHOSTARCH` go build -o out/aliveimage -ldflags="-w -s" .
RUN upx --brute out/aliveimage

# Final Stage: Use a smaller base image and only include necessary files
FROM scratch
FROM alpine:3.18
COPY --from=builder /app/out/aliveimage /app/aliveimage
ENV API_LISTEN_PORT=8080
EXPOSE $API_LISTEN_PORT
Expand Down

0 comments on commit d4e1ff3

Please sign in to comment.