-
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: multistage docker for gin server
- Loading branch information
1 parent
a51b0cf
commit 13031c6
Showing
1 changed file
with
13 additions
and
9 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,17 @@ | ||
FROM golang:latest AS builder | ||
WORKDIR /app | ||
|
||
WORKDIR /build | ||
|
||
COPY . . | ||
|
||
RUN go mod download | ||
RUN go build -o ginserver ./cmd/ginserver/main.go | ||
|
||
RUN CGO_ENABLED=0 GOOS=linux go build -o ginout ./cmd/ginserver/main.go | ||
|
||
EXPOSE 8083 | ||
|
||
ENTRYPOINT [ "/app/ginserver" ] | ||
|
||
FROM scratch | ||
WORKDIR /app | ||
COPY --from=builder /build/ginout . | ||
|
||
ENTRYPOINT [ "/app/ginout" ] |