forked from RedHatInsights/export-service-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
51 lines (40 loc) · 1.28 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
################################
# STEP 1 build executable binary
################################
FROM registry.access.redhat.com/ubi8/go-toolset:latest AS builder
USER root
WORKDIR /workspace
# Cache deps before copying source so that we do not need to re-download for every build
COPY go.mod go.sum .
# Fetch dependencies
RUN go mod download
# -x flag for more verbose download logging
# RUN go mod download -x
# Now copy the rest of the files for build
COPY docs docs
COPY s3 s3
COPY metrics metrics
COPY cmd cmd
COPY static static
COPY db db
COPY utils utils
COPY config config
COPY logger logger
COPY exports exports
COPY kafka kafka
COPY models models
COPY middleware middleware
# Build the binary
RUN GO111MODULE=on go build -ldflags "-w -s" -o export-service cmd/export-service/*.go
############################
# STEP 2 build a small image
############################
FROM registry.access.redhat.com/ubi8-minimal:latest
RUN microdnf update -y
COPY --from=builder /workspace/export-service /usr/bin
COPY --from=builder /workspace/db/migrations /db/migrations/
COPY --from=builder /workspace/static/spec/openapi.json /var/tmp/openapi.json
COPY --from=builder /workspace/static/spec/private.json /var/tmp/private.json
COPY licenses/LICENSE /licenses/LICENSE
USER 1001
CMD ["export-service"]