Skip to content

Commit

Permalink
Add fixed minimal variants for Fedora
Browse files Browse the repository at this point in the history
  • Loading branch information
hhorak committed Aug 23, 2023
1 parent 6d15e48 commit b37fecf
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 5 deletions.
12 changes: 7 additions & 5 deletions 18-minimal/Dockerfile.fedora
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# using registry.fedoraproject.org because there is no f36 version of fedora-minimal on quay.io/fedora
FROM registry.fedoraproject.org/fedora-minimal:36
FROM registry.fedoraproject.org/fedora-minimal:38

EXPOSE 8080

Expand Down Expand Up @@ -50,12 +50,14 @@ LABEL summary="$SUMMARY" \
help="For more information visit https://github.com/sclorg/s2i-nodejs-container"

# nodejs-full-i18n is included for error strings
RUN INSTALL_PKGS="nodejs nodejs-nodemon nodejs-full-i18n npm findutils tar nss_wrapper-libs which" && \
microdnf -y install fedora-repos-modular && \
microdnf -y module enable nodejs:$NODEJS_VERSION && \
RUN INSTALL_PKGS="nodejs$NODEJS_VERSION nodejs-nodemon nodejs$NODEJS_VERSION-full-i18n nodejs$NODEJS_VERSION-npm findutils tar nss_wrapper-libs" && \
microdnf -y --nodocs --setopt=install_weak_deps=0 install $INSTALL_PKGS && \
node -v | grep -qe "^v$NODEJS_VERSION\." && echo "Found VERSION $NODEJS_VERSION" && \
microdnf clean all && \
ln -s /usr/bin/node-20 /usr/bin/node && \
ln -s /usr/bin/npm-20 /usr/bin/npm && \
ln -s /usr/bin/npx-20 /usr/bin/npx && \
ln -s /usr/lib/node_modules_18/nodemon /usr/lib/node_modules_20/nodemon && \
node -v | grep -qe "^v$NODEJS_VERSION\." && echo "Found VERSION $NODEJS_VERSION" && \
rm -rf /mnt/rootfs/var/cache/* /mnt/rootfs/var/log/dnf* /mnt/rootfs/var/log/yum.*

COPY ./s2i/bin/ /usr/libexec/s2i
Expand Down
73 changes: 73 additions & 0 deletions 20-minimal/Dockerfile.fedora
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# using registry.fedoraproject.org because there is no f36 version of fedora-minimal on quay.io/fedora
FROM registry.fedoraproject.org/fedora-minimal:38

EXPOSE 8080

# Add $HOME/node_modules/.bin to the $PATH, allowing user to make npm scripts
# available on the CLI without using npm's --global installation mode
# This image will be initialized with "npm run $NPM_RUN"
# See https://docs.npmjs.com/misc/scripts, and your repo's package.json
# file for possible values of NPM_RUN
# Description
# Environment:
# * $NPM_RUN - Select an alternate / custom runtime mode, defined in your package.json files' scripts section (default: npm run "start").
# Expose ports:
# * 8080 - Unprivileged port used by nodejs application
ENV APP_ROOT=/opt/app-root \
# The $HOME is not set by default, but some applications need this variable
HOME=/opt/app-root/src \
NPM_RUN=start \
PLATFORM="fedora" \
NODEJS_VERSION=20 \
NPM_RUN=start \
NAME=nodejs

ENV SUMMARY="Minimal image for running Node.js $NODEJS_VERSION applications" \
DESCRIPTION="Node.js $NODEJS_VERSION available as container is a base platform for \
running various Node.js $NODEJS_VERSION applications and frameworks. \
Node.js is a platform built on Chrome's JavaScript runtime for easily building \
fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model \
that makes it lightweight and efficient, perfect for data-intensive real-time applications \
that run across distributed devices." \
NPM_CONFIG_PREFIX=$HOME/.npm-global \
PATH=$HOME/node_modules/.bin/:$HOME/.npm-global/bin/:$PATH

LABEL summary="$SUMMARY" \
description="$DESCRIPTION" \
io.k8s.description="$DESCRIPTION" \
io.k8s.display-name="Node.js $NODEJS_VERSION Micro" \
io.openshift.expose-services="8080:http" \
io.openshift.tags="builder,$NAME,${NAME}${NODEJS_VERSION}" \
io.openshift.s2i.scripts-url="image:///usr/libexec/s2i" \
io.s2i.scripts-url="image:///usr/libexec/s2i" \
com.redhat.dev-mode="DEV_MODE:false" \
com.redhat.deployments-dir="${APP_ROOT}/src" \
com.redhat.dev-mode.port="DEBUG_PORT:5858" \
com.redhat.component="${NAME}-${NODEJS_VERSION}-minimal-container" \
name="fedora/$NAME-$NODEJS_VERSION-minimal" \
version="1" \
maintainer="SoftwareCollections.org <[email protected]>" \
help="For more information visit https://github.com/sclorg/s2i-nodejs-container"

# nodejs-full-i18n is included for error strings
ADD https://copr.fedorainfracloud.org/coprs/hhorak/nodemon-for-all/repo/fedora-38/hhorak-nodemon-for-all-fedora-38.repo /etc/yum.repos.d/hhorak-nodemon-for-all-fedora-38.repo
RUN INSTALL_PKGS="nodejs$NODEJS_VERSION nodejs-nodemon nodejs$NODEJS_VERSION-full-i18n nodejs$NODEJS_VERSION-npm findutils tar nss_wrapper-libs" && \
microdnf -y --nodocs --setopt=install_weak_deps=0 install $INSTALL_PKGS && \
microdnf clean all && \
ln -s /usr/bin/node-20 /usr/bin/node && \
ln -s /usr/bin/npm-20 /usr/bin/npm && \
ln -s /usr/bin/npx-20 /usr/bin/npx && \
ln -s /usr/lib/node_modules_18/nodemon /usr/lib/node_modules_20/nodemon && \
node -v | grep -qe "^v$NODEJS_VERSION\." && echo "Found VERSION $NODEJS_VERSION" && \
rm -rf /mnt/rootfs/var/cache/* /mnt/rootfs/var/log/dnf* /mnt/rootfs/var/log/yum.*

#
COPY ./s2i/bin/ /usr/libexec/s2i

# Copy extra files to the image.
COPY ./root/ /

# Drop the root user and make the content of /opt/app-root owned by user 1001
RUN mkdir -p "$HOME" && chown -R 1001:0 "$APP_ROOT" && chmod -R ug+rwx "$APP_ROOT"
WORKDIR "$HOME"
USER 1001

0 comments on commit b37fecf

Please sign in to comment.