-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathDockerfile
40 lines (29 loc) · 936 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
# Stage 1
FROM golang:1.12.7-alpine3.10 AS dependency_builder
WORKDIR /go/src
ENV GO111MODULE=on
RUN apk update
RUN apk add --no-cache bash ca-certificates git make
COPY go.mod .
COPY go.sum .
RUN go mod download
# Stage 2
FROM dependency_builder AS service_builder
ARG SERVICE_NAME
WORKDIR /usr/app
COPY . .
RUN make prepare service=$SERVICE_NAME
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags '-w -s' -a -o bin
# Stage 3
FROM alpine:latest
ARG SERVICE_NAME
RUN apk --no-cache add ca-certificates tzdata
WORKDIR /root/
RUN mkdir -p /root/api/$SERVICE_NAME
RUN mkdir -p /root/cmd/$SERVICE_NAME
RUN mkdir -p /root/config/key
COPY --from=service_builder /usr/app/bin bin
COPY --from=service_builder /usr/app/cmd/$SERVICE_NAME/.env /root/cmd/$SERVICE_NAME/.env
COPY --from=service_builder /usr/app/api/$SERVICE_NAME /root/api/$SERVICE_NAME
COPY --from=service_builder /usr/app/config/key /root/config/key
ENTRYPOINT ["./bin"]