generated from zercle/gofiber-skeleton
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
45 lines (36 loc) · 1.12 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# syntax=docker/dockerfile:1
FROM golang AS builder
ARG timezone=Asia/Bangkok
ENV TZ $timezone
WORKDIR /app
# install dumb-init
RUN apt-get update && \
apt-get -y install dumb-init && \
apt-get -y clean
# pre-copy/cache go.mod for pre-downloading dependencies and only redownloading them in subsequent builds if they change
COPY go.* ./
RUN go mod download && go mod verify
# let's build project
COPY . .
RUN CGO_ENABLED=0 go build -v \
-buildvcs=false \
-installsuffix 'static' \
-ldflags="-X 'main.version=$(git rev-parse --short HEAD)' -X 'main.build=$(date --iso-8601=seconds)'" \
-o dist/server .
# pack PRD image
FROM gcr.io/distroless/base:nonroot
LABEL maintainer="Kawin Viriyaprasopsook <[email protected]>"
ARG timezone=Asia/Bangkok
ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8
ENV TZ $timezone
# Create app dir
WORKDIR /app
COPY --from=builder /usr/bin/dumb-init /usr/bin/dumb-init
COPY --from=builder /app/dist/server /app/server
COPY ./configs /app/configs
COPY ./assets/docs /app/assets/docs
EXPOSE 8080 8443
# default run entrypoint
ENTRYPOINT ["/usr/bin/dumb-init", "--", "/app/server"]
CMD ["--env=prd"]