Skip to content

Instantly share code, notes, and snippets.

@quintesse
Last active July 13, 2021 17:35
Show Gist options
  • Save quintesse/a9972d96c046a1253ac626256344036c to your computer and use it in GitHub Desktop.
Save quintesse/a9972d96c046a1253ac626256344036c to your computer and use it in GitHub Desktop.
Dockerfile Rootless RPMs
  1. Save the Dockerfile locally
  2. Build docker image: docker build -t rootlessrpms .
  3. Have some NodeJS code ready to run
  • eg: git clone github.com/nodeshift-starters/nodejs-health-check
  1. Run the image: docker run -ti --rm -v $(pwd)/nodejs-health-check:/code -p 8080:8080 rootlessrpms
FROM registry.access.redhat.com/ubi8/ubi:latest
RUN dnf install -y cpio yum-utils
RUN useradd -ms /bin/bash notroot
RUN ln -s /home/notroot/pkgs/usr/bin/node /usr/bin/node ; \
ln -s /home/notroot/pkgs/usr/bin/npm /usr/bin/npm ; \
ln -s /home/notroot/pkgs/usr/bin/npx /usr/bin/npx
USER notroot
WORKDIR /home/notroot
RUN yumdownloader --resolve --destdir ~/rpms/ nodejs ; \
for f in ~/rpms/*.rpm; do rpm2cpio $f | cpio -D ~/pkgs -idmv; done
# The lines below are not relevant
# They are just there to demonstrate that the above actually works
WORKDIR /code
CMD [ "bash", "-c", "npm install ; npm start" ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment