Skip to content

Commit

Permalink
Update Dockerfile to use multi-stage build
Browse files Browse the repository at this point in the history
This reduces the image size from 1.04GB to 31.3MB, which makes it easier
to stay within cloud provider free tiers.
  • Loading branch information
eyalzek committed Jun 5, 2024
1 parent 397f972 commit 84eda73
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
FROM golang:1.22
FROM golang:1.22 AS build-stage

WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download

COPY . ./

RUN CGO_ENABLED=0 GOOS=linux go build -o /frigabun

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

COPY --from=build-stage /frigabun /frigabun

WORKDIR /app
EXPOSE 9595

CMD ["/frigabun"]
CMD ["/frigabun"]

0 comments on commit 84eda73

Please sign in to comment.