forked from penguin-statistics/backend-next
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
34 lines (25 loc) · 850 Bytes
/
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
FROM golang:1.19.2-alpine AS base
WORKDIR /app
# builder
FROM base AS builder
ENV GOOS linux
ENV GOARCH amd64
# build-args
ARG VERSION
RUN apk --no-cache add bash git openssh
# modules: utilize build cache
COPY go.mod ./
COPY go.sum ./
# RUN go env -w GO111MODULE=on && go env -w GOPROXY=https://goproxy.cn,direct
RUN go mod download
COPY . .
# inject versioning information & build the binary
RUN export BUILD_TIME=$(date -u +"%Y-%m-%dT%H:%M:%SZ"); go build -o backend -ldflags "-X exusiai.dev/backend-next/internal/pkg/bininfo.Version=$VERSION -X exusiai.dev/backend-next/internal/pkg/bininfo.BuildTime=$BUILD_TIME" .
# runner
FROM base AS runner
RUN apk add --no-cache libc6-compat tini
# Tini is now available at /sbin/tini
COPY --from=builder /app/backend /app/backend
EXPOSE 8080
ENTRYPOINT ["/sbin/tini", "--"]
CMD [ "/app/backend" ]