-
Notifications
You must be signed in to change notification settings - Fork 8
/
dockerfile.production
37 lines (26 loc) · 1018 Bytes
/
dockerfile.production
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
FROM golang:1.19.5-alpine AS builder
WORKDIR /temp
COPY go.mod go.sum ./
# Download the dependencies listed in the go.mod file.
RUN go mod download
COPY . .
# Build with version information
ARG APP=mccs
ARG VERSION_DIR="github.com/ic3network/mccs-alpha/internal/pkg/version"
ARG GIT_TAG
ARG BUILD_DATE
ARG GIT_COMMIT
ARG GIT_TREE_STATUS
ARG ldflags="-w -X $VERSION_DIR.gitTag=$GIT_TAG -X $VERSION_DIR.buildDate=$BUILD_DATE -X $VERSION_DIR.gitCommit=$GIT_COMMIT -X $VERSION_DIR.gitTreeState=$GIT_TREE_STATUS"
# * CGO_ENABLED=0 to build a statically-linked executable
RUN CGO_ENABLED=0 GOOS=linux go build -a -v -ldflags "$ldflags" -o "$APP" ./cmd/mccs-alpha
######## Start a new stage from scratch #######
FROM alpine:latest
RUN apk --no-cache --update upgrade && apk --no-cache add ca-certificates
WORKDIR /app
COPY --from=builder /temp .
COPY --from=0 /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
EXPOSE 8080
# Run the executable
ENTRYPOINT ["./mccs", "-config=production"]
CMD []