-
Notifications
You must be signed in to change notification settings - Fork 31
/
Dockerfile.rhel
66 lines (49 loc) · 2.25 KB
/
Dockerfile.rhel
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
# golang-builder is used in OSBS build
ARG GOLANG_BUILDER=openshift/golang-builder:1.13
ARG OPERATOR_BASE_IMAGE=registry.redhat.io/ubi8/ubi-minimal:latest
FROM ${GOLANG_BUILDER} AS builder
# Intended to build in OSBS using cachito external sources bundle
ARG REMOTE_SOURCE=.
ARG REMOTE_SOURCE_DIR
ARG REMOTE_SOURCE_SUBDIR=app
ARG DEST_ROOT=/dest-root
ARG GO_BUILD_EXTRA_ARGS="-mod readonly -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
# prep the bundle
RUN mkdir -p ${DEST_ROOT}/bundle
RUN cp config/crd/bases/mariadb.openstack.org_mariadbs.yaml ${DEST_ROOT}/bundle/mariadb.openstack.org_mariadbs_crd.yaml
RUN cp config/crd/bases/mariadb.openstack.org_mariadbdatabases.yaml ${DEST_ROOT}/bundle/mariadb.openstack.org_mariadbdatabases_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="mariadb-operator-container" \
name="mariadb-operator" \
version="1.0" \
summary="Mariadb Operator" \
io.k8s.name="mariadb-operator" \
io.k8s.description="This image includes the mariadb-operator" \
io.openshift.tags="cn-openstack openstack"
ENV USER_UID=1001 \
OPERATOR_TEMPLATES=/usr/share/mariadb-operator/templates/ \
OPERATOR_BUNDLE=/usr/share/mariadb-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 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"]