Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gomodule multistage build #274

Merged
merged 7 commits into from
May 6, 2024
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions template/dockerfiles/gomodule/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
FROM golang:{{VERSION}}
FROM golang:{{VERSION}} AS builder
ENV PORT {{PORT}}
EXPOSE {{PORT}}

WORKDIR /go/src/app
WORKDIR /build
COPY go.mod go.sum ./
RUN go mod download && go mod verify
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -v -o app-binary

RUN go get
RUN go build -v -o app
RUN mv ./app /go/bin/

CMD ["app"]
FROM scratch
davidgamero marked this conversation as resolved.
Show resolved Hide resolved
WORKDIR /app
COPY --from=builder /build/app-binary .
CMD ["/app/app-binary"]
Loading