forked from IBM/CodeEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
63 lines (51 loc) · 1.72 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
53
54
55
56
57
58
59
60
61
62
63
FROM registry.access.redhat.com/ubi8/ubi-minimal:latest as build
RUN /bin/true \
&& echo $'[appstream]\n\
name=CentOS Stream $releasever - AppStream\n\
mirrorlist=http://mirrorlist.centos.org/?repo=AppStream&arch=$basearch&release=8-stream\n\
gpgcheck=0\n\
enabled=1\n\
' >/etc/yum.repos.d/upstream.repo \
&& microdnf --nodocs update \
&& microdnf --nodocs install go-toolset openssh-clients git \
&& microdnf clean all \
&& rm -rf /var/cache/yum \
&& /bin/true
ARG GO111MODULE="on"
ENV GO111MODULE $GO111MODULE
USER root
WORKDIR /tmp/build
# First, download dependencies so we can cache this layer
COPY go.mod .
COPY go.sum .
COPY internal/*.go .
RUN if [ "${GO111MODULE}" = "on" ]; then go mod download; fi
# Copy the rest of the source code and build
COPY . .
ENV GOOS=linux
ENV GOARCH=amd64
ENV GOPRIVATE=github.ibm.com
ARG PROGRAM="vsi-proxy"
ENV CGO_ENABLED=0
RUN mkdir -p /etc/vsi-proxy/config
RUN mkdir -p /etc/vsi-proxy/templates
RUN cp -p internal/cloud-config-template.tmpl /etc/vsi-proxy/templates/
# Display Go version and build
RUN go version && \
go build \
-a \
-tags timetzdata,netgo,osusergo \
-ldflags='-extldflags "-static"' \
-o "${PROGRAM}" \
./*.go && ls
RUN cp -p "${PROGRAM}" /usr/bin/vsi-proxy
# Multi stage build
FROM registry.access.redhat.com/ubi8/ubi-minimal:latest
USER 0
RUN mkdir -p /etc/vsi-proxy/config
RUN mkdir -p /opt/vsi-proxy/templates
RUN mkdir -p /opt/vsi-proxy/generated
WORKDIR /opt/vsi-proxy
COPY --from=build /usr/bin/vsi-proxy /opt/vsi-proxy/vsi-proxy
COPY --from=build /etc/vsi-proxy/templates/cloud-config-template.tmpl /opt/vsi-proxy/templates/cloud-config-template.tmpl
ENTRYPOINT [ "/opt/vsi-proxy/vsi-proxy", "-config", "/etc/vsi-proxy/config/vsi-proxy-config.yaml" ]