This repository has been archived by the owner on May 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Dockerfile
55 lines (40 loc) · 1.87 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
# Copyright (C) 2020, 2021, Oracle and/or its affiliates.
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
FROM ghcr.io/oracle/oraclelinux:7-slim AS build_base
RUN yum update -y \
&& yum-config-manager --save --setopt=ol7_ociyum_config.skip_if_unavailable=true \
&& yum install -y oracle-golang-release-el7 \
&& yum-config-manager --add-repo http://yum.oracle.com/repo/OracleLinux/OL7/developer/golang113/x86_64 \
&& yum install -y golang-1.13.3-1.el7 \
&& yum clean all \
&& go version
# Compile to /usr/bin
ENV GOBIN=/usr/bin
# Set go path
ENV GOPATH=/go
ARG BUILDVERSION
ARG BUILDDATE
# Need to use specific WORKDIR to match verrazzano-operator's source packages
WORKDIR /root/go/src/github.com/verrazzano/verrazzano-operator
COPY . .
ENV CGO_ENABLED 0
RUN go version
RUN go env
RUN GO111MODULE=on go build \
-mod= \
-ldflags '-extldflags "-static"' \
-ldflags "-X main.buildVersion=${BUILDVERSION} -X main.buildDate=${BUILDDATE}" \
-o /usr/bin/verrazzano-operator ./cmd/...
FROM ghcr.io/oracle/oraclelinux:7-slim
RUN yum update -y \
&& yum clean all \
&& rm -rf /var/cache/yum
COPY --from=build_base /usr/bin/verrazzano-operator /usr/local/bin/verrazzano-operator
# Copy source tree to image
RUN mkdir -p go/src/github.com/verrazzano/verrazzano-operator
COPY --from=build_base /root/go/src/github.com/verrazzano/verrazzano-operator go/src/github.com/verrazzano/verrazzano-operator
COPY --from=build_base /root/go/src/github.com/verrazzano/verrazzano-operator/THIRD_PARTY_LICENSES.txt /licenses/
RUN groupadd -r verrazzano-operator && useradd --no-log-init -r -g verrazzano-operator -u 1000 verrazzano-operator
RUN chown 1000:verrazzano-operator /usr/local/bin/verrazzano-operator && chmod 500 /usr/local/bin/verrazzano-operator
USER 1000
ENTRYPOINT ["/usr/local/bin/verrazzano-operator"]