This repository has been archived by the owner on May 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathDockerfile
69 lines (51 loc) · 2.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# golang-builder is used in OSBS build
ARG GOLANG_BUILDER=golang:1.13
ARG OPERATOR_BASE_IMAGE=registry.access.redhat.com/ubi7/ubi-minimal:latest
FROM ${GOLANG_BUILDER} AS builder
ARG REMOTE_SOURCE=.
ARG REMOTE_SOURCE_DIR=compute-node-operator
ARG REMOTE_SOURCE_SUBDIR=.
ARG DEST_ROOT=/dest-root
ARG GO_BUILD_EXTRA_ARGS="-v"
COPY $REMOTE_SOURCE $REMOTE_SOURCE_DIR
WORKDIR ${REMOTE_SOURCE_DIR}/${REMOTE_SOURCE_SUBDIR}
RUN mkdir -p ${DEST_ROOT}/usr/local/bin/
# Build
RUN CGO_ENABLED=0 GO111MODULE=on go build ${GO_BUILD_EXTRA_ARGS} -a -o ${DEST_ROOT}/usr/local/bin/manager main.go
RUN CGO_ENABLED=0 GO111MODULE=on go build ${GO_BUILD_EXTRA_ARGS} -a -o ${DEST_ROOT}/usr/local/bin/csv-generator tools/csv-generator.go
RUN cp tools/user_setup ${DEST_ROOT}/usr/local/bin/
RUN cp -r templates ${DEST_ROOT}/templates
RUN cp -r bindata ${DEST_ROOT}/bindata
# prep the bundle
RUN mkdir -p ${DEST_ROOT}/bundle
RUN cp config/crd/bases/compute-node.openstack.org_computenodeopenstacks.yaml ${DEST_ROOT}/bundle/compute-node.openstack.org_computenodeopenstacks_crd.yaml
# strip top 2 lines (this resolves parsing in opm which handles this badly)
RUN sed -i -e 1,2d ${DEST_ROOT}/bundle/*
FROM ${OPERATOR_BASE_IMAGE}
ARG DEST_ROOT=/dest-root
LABEL com.redhat.component="compute-node-operator-container" \
name="cn-osp/compute-node-operator" \
version="0.0.1" \
summary="Compute Node Operator" \
io.k8s.name="compute-node-operator" \
io.k8s.description="This image includes the compute-node-operator"
ENV USER_UID=1001 \
OPERATOR_TEMPLATES=/usr/share/compute-node-operator/templates/ \
OPERATOR_BINDATA=/usr/share/compute-node-operator/bindata/ \
OPERATOR_BUNDLE=/usr/share/compute-node-operator/bundle/
# install operator binary
COPY --from=builder ${DEST_ROOT}/usr/local/bin/* /usr/local/bin/
# install our templates
RUN mkdir -p ${OPERATOR_TEMPLATES}
COPY --from=builder ${DEST_ROOT}/templates ${OPERATOR_TEMPLATES}
# install bindata
RUN mkdir -p ${OPERATOR_BINDATA}
COPY --from=builder ${DEST_ROOT}/bindata ${OPERATOR_BINDATA}
# install CRDs and required roles, services, etc
RUN mkdir -p ${OPERATOR_BUNDLE}
COPY --from=builder ${DEST_ROOT}/bundle/* ${OPERATOR_BUNDLE}
WORKDIR /
# user setup
RUN /usr/local/bin/user_setup
USER ${USER_UID}
ENTRYPOINT ["/usr/local/bin/manager"]