-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(deploy): make api image lighter (#130)
- Loading branch information
1 parent
e6cce5f
commit 036e42e
Showing
1 changed file
with
17 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |