File tree 4 files changed +41
-17
lines changed 4 files changed +41
-17
lines changed Original file line number Diff line number Diff line change 5
5
* .dll
6
6
* .so
7
7
* .dylib
8
- bin
9
8
10
9
.envrc
11
10
Original file line number Diff line number Diff line change 1
1
FROM quay.io/redhat-services-prod/openshift/boilerplate:image-v6.0.1 AS builder
2
2
3
3
WORKDIR /workspace
4
- # Copy the Go Modules manifests
5
4
COPY go.mod go.mod
6
5
COPY go.sum go.sum
7
- # cache deps before building and copying source so that we don't need to re-download as much
8
- # and so that source changes don't invalidate our downloaded layer
9
6
RUN go mod download
10
7
11
- # Copy the go source
12
- COPY *.go .
13
- COPY controllers/ controllers/
14
- COPY api/ api/
8
+ COPY . .
9
+ RUN make go-build
15
10
16
- # Build
17
- RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -mod=mod -a -o manager main.go
18
-
19
- # Use distroless as minimal base image to package the manager binary
20
- # Refer to https://github.com/GoogleContainerTools/distroless for more details
21
11
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.10-1130
22
- WORKDIR /
23
- COPY --from=builder /workspace/manager .
24
- USER nonroot:nonroot
12
+ ENV OPERATOR=/usr/local/bin/must-gather-operator \
13
+ USER_UID=1001 \
14
+ USER_NAME=osd-example-operator
15
+
16
+ COPY --from=builder /workspace/build/_output/bin/* /usr/local/bin/
17
+
18
+ COPY build/bin /usr/local/bin
19
+ RUN /usr/local/bin/user_setup
20
+
21
+ ENTRYPOINT ["/usr/local/bin/entrypoint" ]
22
+
23
+ USER ${USER_UID}
25
24
26
- ENTRYPOINT ["/manager" ]
25
+ LABEL io.openshift.managed.name="osd-example-operator" \
26
+ io.openshift.managed.description="OSD Example Operator"
Original file line number Diff line number Diff line change
1
+ #! /bin/sh -e
2
+
3
+ # This is documented here:
4
+ # https://docs.openshift.com/container-platform/4.10/openshift_images/create-images.html#images-create-guide-openshift_create-images
5
+
6
+ if ! whoami & > /dev/null; then
7
+ if [ -w /etc/passwd ]; then
8
+ echo " ${USER_NAME:- osd-example-operator} :x:$( id -u) :$( id -g) :${USER_NAME:- osd-example-operator} user:${HOME} :/sbin/nologin" >> /etc/passwd
9
+ fi
10
+ fi
11
+
12
+ exec ${OPERATOR} $@
Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+ set -x
3
+
4
+ # ensure $HOME exists and is accessible by group 0 (we don't know what the runtime UID will be)
5
+ mkdir -p ${HOME}
6
+ chown ${USER_UID} :0 ${HOME}
7
+ chmod ug+rwx ${HOME}
8
+
9
+ # runtime user will need to be able to self-insert in /etc/passwd
10
+ chmod g+rw /etc/passwd
11
+
12
+ # no need for this script to remain in the image after running
13
+ rm $0
You can’t perform that action at this time.
0 commit comments