-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
40 lines (28 loc) · 988 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
37
38
39
40
########################################################
# STEP 1 use a temporary image to build a static binary
########################################################
FROM golang:1.18 AS builder
# Pull build dependencies
ENV GOPATH=$APP_ROOT
ENV GOBIN=$APP_ROOT/bin
USER root
WORKDIR $GOPATH/src//
COPY go.mod go.sum ./
RUN go mod download
COPY . .
# Build static image.
RUN go get -d github.com/alvaroloes/enumer && \
go generate ./... && \
GIT_SHA=$(git rev-parse --short HEAD) && \
CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -a \
-ldflags "-extldflags '-static' -w -s -X main.appSha=$GIT_SHA" \
-o /opt/app-root/src/github.com/ignalina/fixed2arrow/fixed2arrow-monolith \
github.com/ignalina/fixed2arrow
FROM alpine:3.15
USER root
RUN mkdir /app \
&& chown -R 1001:1001 /app
USER 1001
WORKDIR /opt/bin
COPY --from=builder /opt/app-root/src/github.com/ignalina/fixed2arrow/fixed2arrow-monolith /opt/bin/fixed2arrow-monolith
CMD /opt/bin/fixed2arrow-monolith