-
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.
ci(dockerfile): use mutlistage builds
- Loading branch information
Showing
1 changed file
with
11 additions
and
16 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,21 +1,16 @@ | ||
FROM golang:1.18.3-alpine | ||
FROM golang:1.18.3-alpine as build | ||
|
||
RUN mkdir -p /go/src/github.com/dpliakos/jorge | ||
WORKDIR /go/src/github.com/dpliakos/jorge | ||
WORKDIR /app | ||
COPY go.mod go.sum /app/ | ||
RUN go mod download | ||
|
||
RUN apk add make | ||
COPY . . | ||
RUN go build | ||
|
||
COPY ./main.go . | ||
COPY ./cmd ./cmd | ||
COPY ./internal ./internal | ||
COPY ./go.mod . | ||
COPY ./go.sum . | ||
COPY ./LICENSE . | ||
COPY ./Makefile . | ||
FROM alpine:3.17.5 as final | ||
|
||
RUN go get | ||
RUN make build | ||
RUN make install | ||
USER 1000 | ||
COPY --from=build /app/jorge /jorge | ||
|
||
RUN mkdir /root/projectRoot | ||
WORKDIR /root/projectRoot | ||
WORKDIR /projectRoot | ||
ENTRYPOINT ["/jorge"] |