Skip to content

Commit 05b034e

Browse files
committed
add Dockerfile for production env
1 parent cf89cc0 commit 05b034e

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

Dockerfile

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
ARG GO_VERSION=1.19.1
2+
3+
FROM golang:${GO_VERSION}-alpine AS builder
4+
5+
RUN go env -w GOPROXY=direct
6+
RUN apk add --no-cache git
7+
RUN apk --no-cache add ca-certificates && update-ca-certificates
8+
9+
WORKDIR /src
10+
11+
COPY ./go.mod ./go.sum ./
12+
RUN go mod download
13+
14+
COPY ./ ./
15+
16+
RUN CGO_ENABLED=0 go build \
17+
-installsuffix 'static' \
18+
-o /API-REST_GO
19+
20+
FROM scratch AS runner
21+
22+
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
23+
24+
COPY .env ./
25+
26+
COPY --from=builder /API-REST_GO /API-REST_GO
27+
28+
EXPOSE 5050
29+
30+
ENTRYPOINT ["/API-REST_GO"]

0 commit comments

Comments
 (0)