Skip to content

Commit a13b801

Browse files
feat: add production dockerfile
1 parent f38e391 commit a13b801

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

Dockerfile.prod

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
ARG BUILD_IMAGE_TAG=1.19-bullseye
2+
3+
FROM golang:${BUILD_IMAGE_TAG} AS build
4+
5+
RUN useradd -u 1001 nonroot
6+
7+
WORKDIR /usr/src/app
8+
9+
COPY go.mod go.sum ./
10+
11+
RUN go mod download
12+
13+
COPY . .
14+
15+
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o okane_server .
16+
17+
# Production
18+
FROM scratch
19+
20+
ENV GIN_MODE=release
21+
22+
WORKDIR /usr/src/app
23+
24+
COPY --from=build /etc/passwd /etc/passwd
25+
26+
COPY --from=build /usr/src/app/okane_server /usr/src/app/okane_server
27+
28+
USER nonroot
29+
30+
EXPOSE 8000
31+
32+
CMD ["./okane_server"]

0 commit comments

Comments
 (0)