-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
36 lines (25 loc) · 806 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
35
36
FROM golang:1.16 AS builder
RUN apt-get -qq update && apt-get -yqq install upx
ENV GO111MODULE=on \
CGO_ENABLED=0 \
GOOS=linux \
GOARCH=amd64
WORKDIR /src
COPY . .
ENV BUILD_INFO_PACKAGE=github.com/go-sod/sod/internal/buildinfo
ENV BUILD_NAME=sod-srv
RUN go build \
-trimpath \
-ldflags "-s -w -X $BUILD_INFO_PACKAGE.BuildTag=$(git describe --tags --abbrev=0) -X $BUILD_INFO_PACKAGE.Time=$(date -u '+%Y-%m-%d-%H:%M') -X $BUILD_INFO_PACKAGE.Name=$BUILD_NAME -extldflags '-static'" \
-installsuffix cgo \
-o /bin/sod \
./cmd/sod-srv
RUN strip /bin/sod
RUN upx -q -9 /bin/sod
RUN mkdir /data
FROM scratch
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /bin/sod /bin/sod
COPY --from=builder /data /data
VOLUME /data
ENTRYPOINT ["/bin/sod"]