-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile.ubi7
40 lines (25 loc) · 1.02 KB
/
Dockerfile.ubi7
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 monolith binary
################################################################
FROM registry.access.redhat.com/ubi7/go-toolset:1.16.7-3 AS builder
# Pull build dependencies
#ENV GOPATH=$APP_ROOT
ENV GOBIN=/opt/rh/go-toolset-1.16/root/usr/bin/go
USER root
WORKDIR $GOPATH/src/
COPY . .
RUN ${GOBIN} mod download
# Build static image.
# -ldflags "-extldflags '-static' -w -s -X main.appSha=$GIT_SHA" \
RUN ${GOBIN} get -d github.com/alvaroloes/enumer && \
${GOBIN} generate ./... && \
GIT_SHA=$(git rev-parse --short HEAD) && \
CGO_ENABLED=1 GOARCH=amd64 GOOS=linux ${GOBIN} build -a -o /opt/app-root/src/github.com/ignalina/shredder/shredder github.com/ignalina/shredder
FROM registry.access.redhat.com/ubi7
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/shredder/shredder /opt/bin/shredder
CMD /opt/bin/shredder