generated from dathan/go-project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
52 lines (43 loc) · 1.31 KB
/
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
41
42
43
44
45
46
47
48
49
50
51
52
# this is a multi-stage build
# the 1st FROM builds the application
FROM golang:1.17.5-alpine3.15 AS baseGo
LABEL stage=build
ENV CGO_ENABLED 0
RUN apk add --no-cache git bash openssh
RUN git config --global url."[email protected]:".insteadOf "https://github.com/"
RUN mkdir /root/gocode
COPY . /root/gocode
WORKDIR /root/gocode
ENV CGO_ENABLED 0
RUN apk --no-cache add git make
ENV GO111MODULE on
RUN go version
RUN make build
RUN make test
#
# this is a dependancy for our container to have CA certs to talk to vault
#
#FROM alpine:latest as alpineCerts
#LABEL stage=alpineCerts
#RUN apk add -U --no-cache ca-certificates
#
# the 2nd FROM says copy the binary from baseGo and put it here using scratch as its base
# - note using alpine because need to run a shell command wrapper
#FROM scratch AS release
FROM alpine:3.15 AS release
LABEL stage=release
RUN apk add -U --no-cache ca-certificates
# Pull CA Certificates to allow for TLS validation a CA
COPY --from=baseGo /root/gocode/bin /app
#COPY --from=baseGo /root/gocode/cmd/upload-bridge/test_upload.html /app
COPY --from=baseGo /root/gocode/scripts/entrypoint.sh /app
EXPOSE 8181
ENTRYPOINT ["/app/entrypoint.sh"]
#
# add another base image from scratch and add meta data called stage=mock
#
FROM scratch AS mock
LABEL stage=mock
#
# Only ship the release layer
FROM release