diff --git a/.gitea/workflows/alpine-dockerio.yaml b/.gitea/workflows/alpine-dockerio.yaml index fc96ba0..c6d309b 100644 --- a/.gitea/workflows/alpine-dockerio.yaml +++ b/.gitea/workflows/alpine-dockerio.yaml @@ -6,7 +6,7 @@ on: jobs: build: - name: Build and push image (root user) + name: Build and push nodejs alpine based to docker.io runs-on: ubuntu-latest container: image: ghcr.io/catthehacker/ubuntu:act-latest @@ -29,6 +29,7 @@ jobs: ALPINE_VERSION=3.14 push: true tags: | + aprimediet/nodejs:14.21.3-alpine aprimediet/nodejs:14-alpine - name: Build and push 16.20.2 uses: docker/build-push-action@v5 @@ -40,6 +41,7 @@ jobs: ALPINE_VERSION=3.16 push: true tags: | + aprimediet/nodejs:16.20.2-alpine aprimediet/nodejs:16-alpine - name: Build and push 18.19.1 uses: docker/build-push-action@v5 @@ -51,6 +53,7 @@ jobs: ALPINE_VERSION=3.18 push: true tags: | + aprimediet/nodejs:18.19.1-alpine aprimediet/nodejs:18-alpine - name: Build and push 20.15.1 uses: docker/build-push-action@v5 @@ -62,6 +65,18 @@ jobs: ALPINE_VERSION=3.20 push: true tags: | + aprimediet/nodejs:20.15.1-alpine aprimediet/nodejs:20-alpine - aprimediet/nodejs:latest-alpine + - name: Build and push 22.11.0 + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.alpine + build-args: | + REGISTRY_URL=aprimediet + ALPINE_VERSION=3.21 + push: true + tags: | + aprimediet/nodejs:22.11.1-alpine + aprimediet/nodejs:22-alpine aprimediet/nodejs:alpine diff --git a/.gitea/workflows/alpine-winter.yaml b/.gitea/workflows/alpine-winter.yaml index 8689386..ed24373 100644 --- a/.gitea/workflows/alpine-winter.yaml +++ b/.gitea/workflows/alpine-winter.yaml @@ -6,28 +6,30 @@ on: jobs: build: - name: Build and push image (Root User) + name: Build and push nodejs alpine based to git.winteraccess.id runs-on: ubuntu-latest container: image: ghcr.io/catthehacker/ubuntu:act-latest steps: - name: Check out repository code uses: actions/checkout@v3 - - name: Login to Docker Winter Access Git Registry + - name: Login to Winter Access Git Registry uses: docker/login-action@v3 with: registry: git.winteraccess.id - username: aditya.prima - password: ${{ secrets.PATOKEN }} + username: ${{ vars.REGISTRY_USERNAME }} + password: ${{ secrets.REGISTRY_TOKEN }} - name: Build and push 14.21.3 uses: docker/build-push-action@v5 with: context: . file: Dockerfile.alpine build-args: | + REGISTRY_URL=git.winteraccess.id/docker ALPINE_VERSION=3.14 push: true tags: | + git.winteraccess.id/${{ gitea.repository }}:14.21.3-alpine git.winteraccess.id/${{ gitea.repository }}:14-alpine - name: Build and push 16.20.2 uses: docker/build-push-action@v5 @@ -35,9 +37,11 @@ jobs: context: . file: Dockerfile.alpine build-args: | + REGISTRY_URL=git.winteraccess.id/docker ALPINE_VERSION=3.16 push: true tags: | + git.winteraccess.id/${{ gitea.repository }}:16.20.2-alpine git.winteraccess.id/${{ gitea.repository }}:16-alpine - name: Build and push 18.19.1 uses: docker/build-push-action@v5 @@ -45,9 +49,11 @@ jobs: context: . file: Dockerfile.alpine build-args: | + REGISTRY_URL=git.winteraccess.id/docker ALPINE_VERSION=3.18 push: true tags: | + git.winteraccess.id/${{ gitea.repository }}:18.19.1-alpine git.winteraccess.id/${{ gitea.repository }}:18-alpine - name: Build and push 20.15.1 uses: docker/build-push-action@v5 @@ -55,9 +61,22 @@ jobs: context: . file: Dockerfile.alpine build-args: | + REGISTRY_URL=git.winteraccess.id/docker ALPINE_VERSION=3.20 push: true tags: | + git.winteraccess.id/${{ gitea.repository }}:20.15.1-alpine git.winteraccess.id/${{ gitea.repository }}:20-alpine - git.winteraccess.id/${{ gitea.repository }}:latest-alpine + - name: Build and push 22.11.1 + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.alpine + build-args: | + REGISTRY_URL=git.winteraccess.id/docker + ALPINE_VERSION=3.21 + push: true + tags: | + git.winteraccess.id/${{ gitea.repository }}:22.11.1-alpine + git.winteraccess.id/${{ gitea.repository }}:22-alpine git.winteraccess.id/${{ gitea.repository }}:alpine diff --git a/.gitea/workflows/ubi9-dockerio.yaml b/.gitea/workflows/ubi9-dockerio.yaml new file mode 100644 index 0000000..df7e94d --- /dev/null +++ b/.gitea/workflows/ubi9-dockerio.yaml @@ -0,0 +1,159 @@ +name: Build and Push UBI9 NodeJS Image to docker.io Registry +on: + push: + branches: + - master + +jobs: + build: + name: Build and push nodejs ubi9 based to docker.io + runs-on: ubuntu-latest + container: + image: ghcr.io/catthehacker/ubuntu:act-latest + steps: + - name: Check out repository code + uses: actions/checkout@v3 + - name: Login to docker.io Registry + uses: docker/login-action@v3 + with: + registry: docker.io + username: aprimediet + password: ${{ secrets.DOCKER_TOKEN }} + - name: Build and push 14.21.3 + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.ubi9 + build-args: | + NVM_VERSION=0.40.1 + NODE_VERSION=14.21.3 + push: true + tags: | + aprimediet/nodejs:14.21.3-ubi9 + aprimediet/nodejs:14-ubi9 + - name: Build and push 16.20.2 + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.ubi9 + build-args: | + NVM_VERSION=0.40.1 + NODE_VERSION=16.20.2 + push: true + tags: | + aprimediet/nodejs:16.20.2-ubi9 + aprimediet/nodejs:16-ubi9 + - name: Build and push 18.20.5 + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.ubi9 + build-args: | + NVM_VERSION=0.40.1 + NODE_VERSION=18.20.5 + push: true + tags: | + aprimediet/nodejs:18.20.5-ubi9 + aprimediet/nodejs:18-ubi9 + - name: Build and push 20.18.0 + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.ubi9 + build-args: | + NVM_VERSION=0.40.1 + NODE_VERSION=20.18.0 + push: true + tags: | + aprimediet/nodejs:20.18.0-ubi9 + aprimediet/nodejs:20-ubi9 + - name: Build and push 22.12.0 + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.ubi9 + build-args: | + NVM_VERSION=0.40.1 + NODE_VERSION=22.12.0 + push: true + tags: | + aprimediet/nodejs:22.12.0-ubi9 + aprimediet/nodejs:22-ubi9 + aprimediet/nodejs:ubi9 + build-micro: + name: Build and push nodejs ubi9-micro based to docker.io + runs-on: ubuntu-latest + needs: + - build + container: + image: ghcr.io/catthehacker/ubuntu:act-latest + steps: + - name: Check out repository code + uses: actions/checkout@v3 + - name: Login to docker.io Registry + uses: docker/login-action@v3 + with: + registry: docker.io + username: aprimediet + password: ${{ secrets.DOCKER_TOKEN }} + - name: Build and push 14.21.3 + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.ubi9-micro + build-args: | + NVM_VERSION=0.40.1 + NODE_VERSION=14.21.3 + push: true + tags: | + aprimediet/nodejs:14.21.3-ubi9-micro + aprimediet/nodejs:14-ubi9-micro + - name: Build and push 16.20.2 + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.ubi9-micro + build-args: | + NVM_VERSION=0.40.1 + NODE_VERSION=16.20.2 + push: true + tags: | + aprimediet/nodejs:16.20.2-ubi9-micro + aprimediet/nodejs:16-ubi9-micro + - name: Build and push 18.20.5 + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.ubi9-micro + build-args: | + NVM_VERSION=0.40.1 + NODE_VERSION=18.20.5 + push: true + tags: | + aprimediet/nodejs:18.20.5-ubi9-micro + aprimediet/nodejs:18-ubi9-micro + - name: Build and push 20.18.0 + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.ubi9-micro + build-args: | + NVM_VERSION=0.40.1 + NODE_VERSION=20.18.0 + push: true + tags: | + aprimediet/nodejs:20.18.0-ubi9-micro + aprimediet/nodejs:20-ubi9-micro + - name: Build and push 22.12.0 + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.ubi9-micro + build-args: | + NVM_VERSION=0.40.1 + NODE_VERSION=22.12.0 + push: true + tags: | + aprimediet/nodejs:22.12.0-ubi9-micro + aprimediet/nodejs:22-ubi9-micro + aprimediet/nodejs:ubi9-micro diff --git a/.gitea/workflows/ubi9-winter.yaml b/.gitea/workflows/ubi9-winter.yaml new file mode 100644 index 0000000..064f6ec --- /dev/null +++ b/.gitea/workflows/ubi9-winter.yaml @@ -0,0 +1,159 @@ +name: Build and Push UBI9 NodeJS Image to git.winteraccess.id Registry +on: + push: + branches: + - master + +jobs: + build: + name: Build and push nodejs ubi9 based to git.winteraccess.id + runs-on: ubuntu-latest + container: + image: ghcr.io/catthehacker/ubuntu:act-latest + steps: + - name: Check out repository code + uses: actions/checkout@v3 + - name: Login to git.winteraccess.id Registry + uses: docker/login-action@v3 + with: + registry: git.winteraccess.id + username: ${{ vars.REGISTRY_USERNAME }} + password: ${{ secrets.REGISTRY_TOKEN }} + - name: Build and push 14.21.3 + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.ubi9 + build-args: | + NVM_VERSION=0.40.1 + NODE_VERSION=14.21.3 + push: true + tags: | + git.winteraccess.id/${{ gitea.repository }}:14.21.3-ubi9 + git.winteraccess.id/${{ gitea.repository }}:14-ubi9 + - name: Build and push 16.20.2 + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.ubi9 + build-args: | + NVM_VERSION=0.40.1 + NODE_VERSION=16.20.2 + push: true + tags: | + git.winteraccess.id/${{ gitea.repository }}:16.20.2-ubi9 + git.winteraccess.id/${{ gitea.repository }}:16-ubi9 + - name: Build and push 18.20.5 + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.ubi9 + build-args: | + NVM_VERSION=0.40.1 + NODE_VERSION=18.20.5 + push: true + tags: | + git.winteraccess.id/${{ gitea.repository }}:18.20.5-ubi9 + git.winteraccess.id/${{ gitea.repository }}:18-ubi9 + - name: Build and push 20.18.0 + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.ubi9 + build-args: | + NVM_VERSION=0.40.1 + NODE_VERSION=20.18.0 + push: true + tags: | + git.winteraccess.id/${{ gitea.repository }}:20.18.0-ubi9 + git.winteraccess.id/${{ gitea.repository }}:20-ubi9 + - name: Build and push 22.12.0 + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.ubi9 + build-args: | + NVM_VERSION=0.40.1 + NODE_VERSION=22.12.0 + push: true + tags: | + git.winteraccess.id/${{ gitea.repository }}:22.12.0-ubi9 + git.winteraccess.id/${{ gitea.repository }}:22-ubi9 + git.winteraccess.id/${{ gitea.repository }}:ubi9 + build-micro: + name: Build and push nodejs ubi9-micro based to git.winteraccess.id + runs-on: ubuntu-latest + needs: + - build + container: + image: ghcr.io/catthehacker/ubuntu:act-latest + steps: + - name: Check out repository code + uses: actions/checkout@v3 + - name: Login to git.winteraccess.id Registry + uses: docker/login-action@v3 + with: + registry: git.winteraccess.id + username: ${{ vars.REGISTRY_USERNAME }} + password: ${{ secrets.REGISTRY_TOKEN }} + - name: Build and push 14.21.3 + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.ubi9-micro + build-args: | + NVM_VERSION=0.40.1 + NODE_VERSION=14.21.3 + push: true + tags: | + git.winteraccess.id/${{ gitea.repository }}:14.21.3-ubi9-micro + git.winteraccess.id/${{ gitea.repository }}:14-ubi9-micro + - name: Build and push 16.20.2 + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.ubi9-micro + build-args: | + NVM_VERSION=0.40.1 + NODE_VERSION=16.20.2 + push: true + tags: | + git.winteraccess.id/${{ gitea.repository }}:16.20.2-ubi9-micro + git.winteraccess.id/${{ gitea.repository }}:16-ubi9-micro + - name: Build and push 18.20.5 + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.ubi9-micro + build-args: | + NVM_VERSION=0.40.1 + NODE_VERSION=18.20.5 + push: true + tags: | + git.winteraccess.id/${{ gitea.repository }}:18.20.5-ubi9-micro + git.winteraccess.id/${{ gitea.repository }}:18-ubi9-micro + - name: Build and push 20.18.0 + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.ubi9-micro + build-args: | + NVM_VERSION=0.40.1 + NODE_VERSION=20.18.0 + push: true + tags: | + git.winteraccess.id/${{ gitea.repository }}:20.18.0-ubi9-micro + git.winteraccess.id/${{ gitea.repository }}:20-ubi9-micro + - name: Build and push 22.12.0 + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.ubi9-micro + build-args: | + NVM_VERSION=0.40.1 + NODE_VERSION=22.12.0 + push: true + tags: | + git.winteraccess.id/${{ gitea.repository }}:22.12.0-ubi9-micro + git.winteraccess.id/${{ gitea.repository }}:22-ubi9-micro + git.winteraccess.id/${{ gitea.repository }}:ubi9-micro diff --git a/.gitea/workflows/ubuntu-dockerio.yaml b/.gitea/workflows/ubuntu-dockerio.yaml deleted file mode 100644 index e35aebf..0000000 --- a/.gitea/workflows/ubuntu-dockerio.yaml +++ /dev/null @@ -1,75 +0,0 @@ -name: Build and Push Ubuntu NodeJS Image to docker.io Registry -on: - push: - branches: - - master - -jobs: - build: - name: Build and push image (root user) - runs-on: ubuntu-latest - container: - image: ghcr.io/catthehacker/ubuntu:act-latest - steps: - - name: Check out repository code - uses: actions/checkout@v3 - - name: Login to docker.io Registry - uses: docker/login-action@v3 - with: - registry: docker.io - username: aprimediet - password: ${{ secrets.DOCKER_TOKEN }} - - name: Build and push 14.21.3 - uses: docker/build-push-action@v5 - with: - context: . - file: Dockerfile.ubuntu - build-args: | - REGISTRY_URL=aprimediet - UBUNTU_VERSION=noble - NODE_VERSION=14.21.3 - push: true - tags: | - aprimediet/nodejs:14-ubuntu - aprimediet/nodejs:14 - - name: Build and push 16.20.2 - uses: docker/build-push-action@v5 - with: - context: . - file: Dockerfile.ubuntu - build-args: | - REGISTRY_URL=aprimediet - UBUNTU_VERSION=noble - NODE_VERSION=16.20.2 - push: true - tags: | - aprimediet/nodejs:16-ubuntu - aprimediet/nodejs:16 - - name: Build and push 18.19.1 - uses: docker/build-push-action@v5 - with: - context: . - file: Dockerfile.ubuntu - build-args: | - REGISTRY_URL=aprimediet - UBUNTU_VERSION=noble - NODE_VERSION=18.19.1 - push: true - tags: | - aprimediet/nodejs:18-ubuntu - aprimediet/nodejs:18 - - name: Build and push 20.11.1 - uses: docker/build-push-action@v5 - with: - context: . - file: Dockerfile.ubuntu - build-args: | - REGISTRY_URL=aprimediet - UBUNTU_VERSION=noble - NODE_VERSION=20.15.1 - push: true - tags: | - aprimediet/nodejs:20-ubuntu - aprimediet/nodejs:20 - aprimediet/nodejs:latest-ubuntu - aprimediet/nodejs:latest diff --git a/.gitea/workflows/ubuntu-winter.yaml b/.gitea/workflows/ubuntu-winter.yaml deleted file mode 100644 index b9180e5..0000000 --- a/.gitea/workflows/ubuntu-winter.yaml +++ /dev/null @@ -1,71 +0,0 @@ -name: Build and Push Ubuntu NodeJS Image to Winter Access Registry -on: - push: - branches: - - master - -jobs: - build: - name: Build and push image (root user) - runs-on: ubuntu-latest - container: - image: ghcr.io/catthehacker/ubuntu:act-latest - steps: - - name: Check out repository code - uses: actions/checkout@v3 - - name: Login to Docker Winter Access Git Registry - uses: docker/login-action@v3 - with: - registry: git.winteraccess.id - username: aditya.prima - password: ${{ secrets.PATOKEN }} - - name: Build and push 14.21.3 - uses: docker/build-push-action@v5 - with: - context: . - file: Dockerfile.ubuntu - build-args: | - UBUNTU_VERSION=noble - NODE_VERSION=14.21.3 - push: true - tags: | - git.winteraccess.id/${{ gitea.repository }}:14-ubuntu - git.winteraccess.id/${{ gitea.repository }}:14 - - name: Build and push 16.20.2 - uses: docker/build-push-action@v5 - with: - context: . - file: Dockerfile.ubuntu - build-args: | - UBUNTU_VERSION=noble - NODE_VERSION=16.20.2 - push: true - tags: | - git.winteraccess.id/${{ gitea.repository }}:16-ubuntu - git.winteraccess.id/${{ gitea.repository }}:16 - - name: Build and push 18.19.1 - uses: docker/build-push-action@v5 - with: - context: . - file: Dockerfile.ubuntu - build-args: | - UBUNTU_VERSION=noble - NODE_VERSION=18.19.1 - push: true - tags: | - git.winteraccess.id/${{ gitea.repository }}:18-ubuntu - git.winteraccess.id/${{ gitea.repository }}:18 - - name: Build and push 20.11.1 - uses: docker/build-push-action@v5 - with: - context: . - file: Dockerfile.ubuntu - build-args: | - UBUNTU_VERSION=noble - NODE_VERSION=20.15.1 - push: true - tags: | - git.winteraccess.id/${{ gitea.repository }}:20-ubuntu - git.winteraccess.id/${{ gitea.repository }}:20 - git.winteraccess.id/${{ gitea.repository }}:latest-ubuntu - git.winteraccess.id/${{ gitea.repository }}:latest diff --git a/Dockerfile.alpine b/Dockerfile.alpine index 2fe28a4..7091fcf 100644 --- a/Dockerfile.alpine +++ b/Dockerfile.alpine @@ -3,19 +3,24 @@ # 18.19.1 = 3.18 # 20.11.1 = 3.19 # 20.15.1 = 3.20 -ARG REGISTRY_URL=git.winteraccess.id/docker -ARG ALPINE_VERSION=3.20 +# 22.11.0 = 3.21 +ARG REGISTRY_URL=docker.io/aprimediet +ARG ALPINE_VERSION=3.21 FROM ${REGISTRY_URL}/alpine:${ALPINE_VERSION} LABEL maintainer=" aprimediet@gmail.com" +USER root WORKDIR / -# SET CACHE DIR +# Set Cache Directory ENV NODE_DIR=/usr/local/share/nodejs ENV NPM_CACHE_DIR=${NODE_DIR}/.npm-cache ENV YARN_CACHE_DIR=${NODE_DIR}/.yarn-cache +RUN addgroup -g 10001 nodejs && \ + adduser -D -u 10001 -G nodejs -s /bin/sh -h /app nodejs + # INSTALL WGET AND REQUIRED BUILD TOOLS RUN --mount=type=cache,target=/var/cache/apk \ apk update && apk upgrade && apk add \ @@ -39,4 +44,10 @@ RUN yarn config set cache-folder ${YARN_CACHE_DIR} RUN apk del curl && \ rm -rf /var/cache/apk/* && \ npm cache clean --force && \ - npm -g cache clean --force \ No newline at end of file + npm -g cache clean --force + +USER nodejs + +WORKDIR /app + +CMD ["node"] \ No newline at end of file diff --git a/Dockerfile.ubi9 b/Dockerfile.ubi9 new file mode 100644 index 0000000..cd35dd5 --- /dev/null +++ b/Dockerfile.ubi9 @@ -0,0 +1,77 @@ +ARG REGISTRY_URL=docker.io/aprimediet +ARG UBI_VERSION=9.5 + +FROM ${REGISTRY_URL}/ubi9:${UBI_VERSION} +LABEL maintainer=" aprimediet@gmail.com" + +ARG NVM_VERSION=0.40.1 +ARG NODE_VERSION=22.12.0 + +USER root + +WORKDIR /tmp + +# Set Cache Directory +ENV NVM_DIR=/usr/local/share/nvm +ENV NODE_DIR=/usr/local/share/nodejs +ENV NPM_CACHE_DIR=${NODE_DIR}/.npm-cache +ENV YARN_CACHE_DIR=${NODE_DIR}/.yarn-cache + +# Setup composer user and required directories +RUN groupadd -g 10001 nodejs && \ + useradd -u 10001 -g 10001 -m -d /app -s /sbin/nologin nodejs && \ + mkdir -p ${NVM_DIR} && \ + mkdir -p ${NPM_CACHE_DIR} && \ + mkdir -p ${YARN_CACHE_DIR}/repo && \ + chown -R nodejs:nodejs ${NPM_CACHE_DIR} && \ + chown -R nodejs:nodejs ${YARN_CACHE_DIR} + +# Get latest nvm +ADD https://raw.githubusercontent.com/nvm-sh/nvm/v${NVM_VERSION}/install.sh ./ + +# INSTALL NVM AND DESIGNATED NODE VERSION +RUN bash /tmp/install.sh && \ + . $NVM_DIR/nvm.sh && \ + nvm install v${NODE_VERSION} && \ + nvm alias default v${NODE_VERSION} && \ + nvm use default + +ENV NODE_PATH=$NVM_DIR/versions/node/v${NODE_VERSION}/lib/node_modules +ENV PATH=$PATH:$NVM_DIR/versions/node/v${NODE_VERSION}/bin + +# Set global npm cache +RUN npm -g config set cache ${NPM_CACHE_DIR} && \ + npm config set cache ${NPM_CACHE_DIR} + +# Install Yarn +RUN --mount=type=cache,target=${NPM_CACHE_DIR} \ + npm i -g npm@latest && \ + npm i -g yarn@latest && \ + yarn config set cache-folder ${YARN_CACHE_DIR} && \ + dnf -y autoremove && \ + dnf -y clean all + +# Set binary simlinks +RUN ln -ns $NVM_DIR/versions/node/v${NODE_VERSION}/bin/corepack \ + /usr/bin/corepack && \ + ln -ns $NVM_DIR/versions/node/v${NODE_VERSION}/bin/node \ + /usr/bin/node && \ + ln -ns $NVM_DIR/versions/node/v${NODE_VERSION}/bin/npm \ + /usr/bin/npm && \ + ln -ns $NVM_DIR/versions/node/v${NODE_VERSION}/bin/npx \ + /usr/bin/npx && \ + ln -ns $NVM_DIR/versions/node/v${NODE_VERSION}/bin/yarn \ + /usr/bin/yarn && \ + ln -ns $NVM_DIR/versions/node/v${NODE_VERSION}/bin/yarnpkg \ + /usr/bin/yarnpkg + +# Clean Caches +RUN rm -rf ${NPM_CACHE_DIR}/* && \ + rm -rf ${YARN_CACHE_DIR}/* && \ + rm -rf ${NVM_DIR}/.cache/bin/* + +USER nodejs + +WORKDIR /app + +CMD ["/usr/bin/node"] \ No newline at end of file diff --git a/Dockerfile.ubi9-micro b/Dockerfile.ubi9-micro new file mode 100644 index 0000000..45c1b31 --- /dev/null +++ b/Dockerfile.ubi9-micro @@ -0,0 +1,67 @@ +ARG REGISTRY_URL=docker.io/aprimediet +ARG UBI_VERSION=9.5 +ARG NODE_VERSION=22.12.0 + +FROM ${REGISTRY_URL}/nodejs:${NODE_VERSION}-ubi9 AS builder +LABEL maintainer=" aprimediet@gmail.com" + +FROM ${REGISTRY_URL}/ubi9:${UBI_VERSION}-micro AS runtime +LABEL maintainer=" aprimediet@gmail.com" + +ARG NODE_VERSION=22.12.0 + +USER root + +WORKDIR /tmp + +# Set Cache Directory +ENV NVM_DIR=/usr/local/share/nvm +ENV NODE_DIR=/usr/local/share/nodejs +ENV NPM_CACHE_DIR=${NODE_DIR}/.npm-cache +ENV YARN_CACHE_DIR=${NODE_DIR}/.yarn-cache + +# Create user and group and required directories +RUN echo "nodejs:x:10001:" >> /etc/group && \ + echo "nodejs:x:10001:10001:nodejs:/app:/sbin/nologin" >> /etc/passwd && \ + echo "nodejs:!!:20070::::::" >> /etc/shadow && \ + mkdir -p /app && \ + mkdir -p ${NVM_DIR} && \ + mkdir -p ${NPM_CACHE_DIR} && \ + mkdir -p ${YARN_CACHE_DIR}/repo && \ + chown -R nodejs:nodejs ${NPM_CACHE_DIR} && \ + chown -R nodejs:nodejs ${YARN_CACHE_DIR} && \ + chown -R nodejs:nodejs /app + +# Copy required libs +COPY --from=builder \ + /usr/lib64/libstdc* \ + /usr/lib64 + +# Copy nvm dir +COPY --from=builder /usr/local/share/nvm /usr/local/share/nvm + +# Set node env +ENV NODE_PATH=$NVM_DIR/versions/node/v${NODE_VERSION}/lib/node_modules +ENV PATH=$PATH:$NVM_DIR/versions/node/v${NODE_VERSION}/bin + +# Set binary simlinks and set global npm cache +RUN ln -ns $NVM_DIR/versions/node/v${NODE_VERSION}/bin/corepack \ + /usr/bin/corepack && \ + ln -ns $NVM_DIR/versions/node/v${NODE_VERSION}/bin/node \ + /usr/bin/node && \ + ln -ns $NVM_DIR/versions/node/v${NODE_VERSION}/bin/npm \ + /usr/bin/npm && \ + ln -ns $NVM_DIR/versions/node/v${NODE_VERSION}/bin/npx \ + /usr/bin/npx && \ + ln -ns $NVM_DIR/versions/node/v${NODE_VERSION}/bin/yarn \ + /usr/bin/yarn && \ + ln -ns $NVM_DIR/versions/node/v${NODE_VERSION}/bin/yarnpkg \ + /usr/bin/yarnpkg && \ + npm -g config set cache ${NPM_CACHE_DIR} && \ + npm config set cache ${NPM_CACHE_DIR} + +USER nodejs + +WORKDIR /app + +CMD ["/usr/bin/node"] \ No newline at end of file