Skip to content

Commit

Permalink
feat(deploy): make api image lighter (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
RomainDreidemy authored Sep 15, 2023
1 parent e6cce5f commit 036e42e
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions api/Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
FROM golang:1.20-alpine
FROM golang:1.20-alpine AS build-stage

WORKDIR /app

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

COPY . .
RUN ls -la
RUN pwd
COPY *.go ./

RUN go build -o /api src/server.go

CMD ["/api"]
FROM build-stage AS run-test-stage
RUN go test -v ./...

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

WORKDIR /

COPY --from=build-stage /api /api

EXPOSE 8080

USER nonroot:nonroot

ENTRYPOINT ["/api"]

0 comments on commit 036e42e

Please sign in to comment.