Skip to content

Commit

Permalink
feat: create both rootless and rootfull images (#22)
Browse files Browse the repository at this point in the history
* added rootless dockerfile

---------

Co-authored-by: mikhail-klimko <[email protected]>
  • Loading branch information
ATGardner and mikhail-klimko authored Jul 16, 2024
1 parent 4303651 commit 25ac2cc
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 30 deletions.
38 changes: 9 additions & 29 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,35 +1,15 @@
ARG ARCH=amd64
FROM alpine:3.20.1

FROM prom/node-exporter:v1.6.1 AS node-exporter
COPY --from=prom/node-exporter:v1.8.1 /bin/node_exporter /usr/local/bin/
COPY --from=bitnami/kubectl:1.30.2 /opt/bitnami/kubectl/bin/kubectl /usr/local/bin/

FROM alpine:3.16.7

COPY --from=node-exporter /bin/node_exporter /bin/

ENV KUBECTL_VERSION="v1.8.8"

RUN apk add --update curl bash coreutils \
&& export ARCH=$([[ "$(uname -m)" == "aarch64" ]] && echo "arm64" || echo "amd64") \
&& curl -L https://storage.googleapis.com/kubernetes-release/release/${KUBECTL_VERSION}/bin/linux/${ARCH}/kubectl -o /usr/local/bin/kubectl \
&& chmod +x /usr/local/bin/kubectl

# add user
RUN addgroup --gid 1000 dind-volume-utils && \
adduser --uid 1000 --gecos "" --disabled-password \
--ingroup dind-volume-utils \
--home /home/dind-volume-utils \
--shell /bin/bash dind-volume-utils
RUN apk add --update bash coreutils

WORKDIR /home/dind-volume-utils

ADD bin ./bin
ADD monitor ./monitor
ADD dind-metrics ./dind-metrics
ADD local-volumes ./local-volumes

RUN chown -R dind-volume-utils:dind-volume-utils /home/dind-volume-utils && \
chmod 755 /home/dind-volume-utils

USER dind-volume-utils:dind-volume-utils
COPY bin ./bin
COPY monitor ./monitor
COPY dind-metrics ./dind-metrics
COPY local-volumes ./local-volumes

CMD ["/bin/bash"]
CMD ["sh"]
27 changes: 27 additions & 0 deletions Dockerfile.rootless
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM alpine:3.20.1

COPY --from=prom/node-exporter:v1.8.1 /bin/node_exporter /usr/local/bin/
COPY --from=bitnami/kubectl:1.30.2 /opt/bitnami/kubectl/bin/kubectl /usr/local/bin/

RUN apk add --update bash coreutils

WORKDIR /home/dind-volume-utils

COPY bin ./bin
COPY monitor ./monitor
COPY dind-metrics ./dind-metrics
COPY local-volumes ./local-volumes

# add user
RUN addgroup --gid 1000 dind-volume-utils && \
adduser --uid 1000 --gecos "" --disabled-password \
--ingroup dind-volume-utils \
--home /home/dind-volume-utils \
--shell /bin/bash dind-volume-utils

RUN chown -R dind-volume-utils:dind-volume-utils /home/dind-volume-utils && \
chmod 755 /home/dind-volume-utils

USER dind-volume-utils:dind-volume-utils

CMD ["sh"]
2 changes: 1 addition & 1 deletion service.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version: 1.29.5
version: 1.30.0

0 comments on commit 25ac2cc

Please sign in to comment.