Skip to content

Commit

Permalink
Non-root containers (stolostron#1274)
Browse files Browse the repository at this point in the history
* Use non-root user for tests container

Signed-off-by: Douglas Camata <[email protected]>

* Tighten container permissions

Signed-off-by: Douglas Camata <[email protected]>

---------

Signed-off-by: Douglas Camata <[email protected]>
  • Loading branch information
douglascamata authored Nov 6, 2023
1 parent fe7f3ba commit 4d9d8fd
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 5 deletions.
2 changes: 2 additions & 0 deletions collectors/metrics/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ RUN microdnf update &&\
mkdir /licenses &&\
microdnf clean all

USER 1001:1001

COPY --from=builder /workspace/metrics-collector /usr/bin/

# standalone required parameters
Expand Down
2 changes: 2 additions & 0 deletions loaders/dashboards/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ WORKDIR /

RUN microdnf update -y && microdnf clean all

USER 1001:1001

COPY --from=builder /workspace/main grafana-dashboard-loader

EXPOSE 3002
Expand Down
2 changes: 2 additions & 0 deletions operators/multiclusterobservability/bundle.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FROM scratch

USER 1001:1001

LABEL operators.operatorframework.io.bundle.mediatype.v1=registry+v1
LABEL operators.operatorframework.io.bundle.manifests.v1=manifests/
LABEL operators.operatorframework.io.bundle.metadata.v1=metadata/
Expand Down
3 changes: 3 additions & 0 deletions proxy/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ LABEL org.label-schema.vendor="Red Hat" \
io.openshift.tags="$IMAGE_OPENSHIFT_TAGS"

WORKDIR /

USER 1001:1001

COPY --from=builder /workspace/main rbac-query-proxy

EXPOSE 3002
Expand Down
4 changes: 2 additions & 2 deletions tests/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ RUN go install github.com/onsi/ginkgo/[email protected] && go mod vendor && ginkgo
# create new docker image to hold built artifacts
FROM registry.access.redhat.com/ubi8/ubi-minimal:latest

# run as root
USER root
# run as non-root
USER 1001:1001

# expose env vars for runtime
ENV KUBECONFIG "/opt/.kube/config"
Expand Down
2 changes: 1 addition & 1 deletion tools/simulator/metrics-collector/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
FROM registry.access.redhat.com/ubi8/ubi-minimal:latest

USER 1001:1001
COPY timeseries.txt /tmp/
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ RUN microdnf install wget -y \
RUN microdnf install tar gzip jq bc -y\
&& microdnf clean all

USER 1001:1001

RUN wget https://mirror.openshift.com/pub/openshift-v4/clients/ocp/stable-4.13/openshift-client-linux.tar.gz -P /ocp-tools
WORKDIR /ocp-tools
RUN chmod 777 /ocp-tools
RUN chmod 644 /ocp-tools
RUN tar xvf openshift-client-linux.tar.gz oc kubectl
RUN rm openshift-client-linux.tar.gz
RUN cp oc /usr/local/bin
Expand All @@ -38,7 +39,7 @@ RUN export matches=$(curl -L $METRICS_ALLOW_LIST_URL | $GOJSONTOYAML_BIN --yamlt


COPY ./extract-metrics-data.sh /metrics-extractor/
RUN chmod 777 /metrics-extractor
RUN chmod 744 /metrics-extractor


CMD [ "/bin/bash", "/metrics-extractor/extract-metrics-data.sh" ]

0 comments on commit 4d9d8fd

Please sign in to comment.