forked from opencost/opencost
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
33 lines (30 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
FROM golang:latest as build-env
RUN mkdir /app
WORKDIR /app
COPY go.mod .
COPY go.sum .
# Get dependencies - will also be cached if we won't change mod/sum
RUN go mod download
# COPY the source code as the last step
COPY . .
# Build the binary
RUN set -e ;\
GIT_COMMIT=`git rev-parse HEAD` ;\
GIT_DIRTY='' ;\
# for our purposes, we only care about dirty .go files ;\
if test -n "`git status --porcelain --untracked-files=no | grep '\.go'`"; then \
GIT_DIRTY='+dirty' ;\
fi ;\
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
go build -a -installsuffix cgo \
-ldflags "-X main.gitCommit=${GIT_COMMIT}${GIT_DIRTY}" \
-o /go/bin/app
FROM alpine:3.10.2
RUN apk add --update --no-cache ca-certificates
COPY --from=build-env /go/bin/app /go/bin/app
ADD ./cloud/default.json /models/default.json
ADD ./cloud/azure.json /models/azure.json
ADD ./cloud/aws.json /models/aws.json
ADD ./cloud/gcp.json /models/gcp.json
USER 1001
ENTRYPOINT ["/go/bin/app"]