Repository: scality/utapi
Pull request #1311: UTAPI-110 update nodesvc-base image with node 22
Author: login: tcarmet
Created: 2025-04-02T00:14:20Z | Merged: 2025-04-09T23:21:06Z



Diff:
diff --git a/.github/workflows/build-dev.yaml b/.github/workflows/build-dev.yaml
index a87555c2..8821a81b 100644
--- a/.github/workflows/build-dev.yaml
+++ b/.github/workflows/build-dev.yaml
@@ -6,11 +6,20 @@ on:
     - 'development/**'
 
 jobs:
-  build-dev:
+  build-base:
     uses: scality/workflows/.github/workflows/docker-build.yaml@v2
-    secrets:
-      REGISTRY_LOGIN: ${{ github.repository_owner }}
-      REGISTRY_PASSWORD: ${{ github.token }}
     with:
       namespace: ${{ github.repository_owner }}
       name: ${{ github.event.repository.name }}
+
+  build-svc-base:
+    needs: build-base
+    uses: scality/workflows/.github/workflows/docker-build.yaml@v2
+    with:
+      namespace: ${{ github.repository_owner }}
+      name: ${{ github.event.repository.name }}
+      context: .
+      file: images/nodesvc-base/Dockerfile
+      tag: ${{ github.sha }}-svc-base
+      build-args: |
+        UTAPI_VERSION=${{ github.sha }}
diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml
index d0d64827..23f199d7 100644
--- a/.github/workflows/release.yaml
+++ b/.github/workflows/release.yaml
@@ -3,13 +3,6 @@ name: release
 on:
   workflow_dispatch:
     inputs:
-      dockerfile:
-        description: Dockerfile to build image from
-        type: choice
-        options:
-          - images/nodesvc-base/Dockerfile
-          - Dockerfile
-        required: true
       tag:
         type: string
         description: 'Tag to be released'
@@ -27,8 +20,19 @@ jobs:
       namespace: ${{ github.repository_owner }}
       name: ${{ github.event.repository.name }}
       context: .
-      file: ${{ github.event.inputs.dockerfile}}
-      tag: ${{ github.event.inputs.tag }}
+      tag: ${{ inputs.tag }}
+
+  build-nodesvc-base:
+    needs: build
+    uses: scality/workflows/.github/workflows/docker-build.yaml@v2
+    with:
+      namespace: ${{ github.repository_owner }}
+      name: ${{ github.event.repository.name }}
+      context: .
+      file: images/nodesvc-base/Dockerfile
+      tag: ${{ inputs.tag }}-nodesvc-base
+      build-args: |
+        UTAPI_VERSION=${{ inputs.tag }}
 
   release:
     if: ${{ inputs.create-github-release }}
diff --git a/Dockerfile b/Dockerfile
index d3a67b9d..65f173e6 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,4 +1,4 @@
-FROM node:22.11.0-bookworm-slim
+FROM node:22.14.0-bookworm-slim
 
 WORKDIR /usr/src/app
 
diff --git a/images/nodesvc-base/Dockerfile b/images/nodesvc-base/Dockerfile
index 2f0fb3b6..66144eba 100644
--- a/images/nodesvc-base/Dockerfile
+++ b/images/nodesvc-base/Dockerfile
@@ -1,20 +1,43 @@
-FROM ghcr.io/scality/federation/nodesvc-base:7.10.5.0
-
-ENV UTAPI_CONFIG_FILE=${CONF_DIR}/config.json
+ARG DEBIAN_FRONTEND=noninteractive
+ARG UTAPI_VERSION=latest
+FROM ghcr.io/scality/utapi:${UTAPI_VERSION} AS base
+
+FROM node:22.14.0-bookworm-slim
+
+# Prepare runtime environment
+ENV USER="scality"
+ENV HOME_DIR="/home/${USER}" \
+    LOG_DIR="/logs" \
+    CONF_DIR="/conf" \
+    DATA_DIR="/data" \
+    SUP_RUN_DIR="/var/run/supervisor"
+
+RUN mv /home/node ${HOME_DIR} && \
+    useradd -ms /bin/bash ${USER} && \
+    usermod -aG node ${USER} && \
+    mkdir ${LOG_DIR} && chown ${USER} ${LOG_DIR} && \
+    mkdir ${CONF_DIR} && chown ${USER} ${CONF_DIR} && \
+    mkdir ${DATA_DIR} && chown ${USER} ${DATA_DIR} && \
+    mkdir -m 777 ${SUP_RUN_DIR} && chown ${USER} ${SUP_RUN_DIR}
+
+RUN apt-get update \
+    && apt-get install -y --no-install-recommends \
+    logrotate \
+    supervisor \
+    && apt-get clean \
+    && apt-get -y autoremove
+
+ARG BALLOT_VERSION=1.0.2
+ADD --chmod=0755 https://github.com/scality/ballot/releases/download/v${BALLOT_VERSION}/ballot-v${BALLOT_VERSION}-linux-amd64 /usr/local/bin/ballot
+
+COPY --from=base --chown=${USER}:${USER} /usr/src/app/node_modules ${HOME_DIR}/utapi/node_modules
+COPY --chown=${USER}:${USER} . ${HOME_DIR}/utapi
 
+USER ${USER}
 WORKDIR ${HOME_DIR}/utapi
 
-COPY ./package.json ./yarn.lock ${HOME_DIR}/utapi
-
-# Remove when gitcache is sorted out
-RUN rm /root/.gitconfig
-
-RUN yarn install --production --frozen-lockfile --network-concurrency 1
-
-COPY . ${HOME_DIR}/utapi
-
-RUN chown -R ${USER} ${HOME_DIR}/utapi
+ENV UTAPI_CONFIG_FILE=${CONF_DIR}/config.json
 
-USER ${USER}
+EXPOSE 8100
 
-CMD bash -c "source ${CONF_DIR}/env && export && supervisord -c ${CONF_DIR}/${SUPERVISORD_CONF}"
+CMD ["bash", "-c", "source ${CONF_DIR}/env && export && supervisord -c ${CONF_DIR}/${SUPERVISORD_CONF}"]


Reviews:
user: login: BourgoisMickael
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-04-02T19:04:52Z
user: login: tcarmet
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-02T19:54:48Z
user: login: tcarmet
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-02T20:04:52Z
user: login: BourgoisMickael
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-02T20:23:25Z
user: login: BourgoisMickael
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-08T08:22:33Z
user: login: tcarmet
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-08T20:00:42Z
user: login: tcarmet
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-08T20:01:10Z
user: login: BourgoisMickael
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-04-08T22:46:04Z
user: login: tmacro
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-04-09T21:20:18Z
user: login: anurag4DSB
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-04-10T04:21:58Z

Review comments:
diff_hunk: @@ -1,20 +1,43 @@
-FROM ghcr.io/scality/federation/nodesvc-base:7.10.5.0
-
-ENV UTAPI_CONFIG_FILE=${CONF_DIR}/config.json
+ARG DEBIAN_FRONTEND=noninteractive
+ARG UTAPI_VERSION=latest
+FROM ghcr.io/scality/utapi:${UTAPI_VERSION} AS base
path: images/nodesvc-base/Dockerfile
user: login: BourgoisMickael
body: So we really need 2 images for utapi ? Can we use only 1 image ? The other one doesn't use the same node version 
created_at: 2025-04-02T19:04:48Z
author_association: CONTRIBUTOR
diff_hunk: @@ -1,20 +1,43 @@
-FROM ghcr.io/scality/federation/nodesvc-base:7.10.5.0
-
-ENV UTAPI_CONFIG_FILE=${CONF_DIR}/config.json
+ARG DEBIAN_FRONTEND=noninteractive
+ARG UTAPI_VERSION=latest
+FROM ghcr.io/scality/utapi:${UTAPI_VERSION} AS base
path: images/nodesvc-base/Dockerfile
user: login: tcarmet
body: I think we need two, because UTAPI is used on both ARTESCA and RING:
- Artesca uses the default image and does not use `supervisord` to starts its container
- I don't think they use `ballot` on artesca side
- They also don't have this requirement of having CONF_DIR DATA_DIR and all that stuff.

I can match the node version and image though. 
created_at: 2025-04-02T19:54:48Z
author_association: CONTRIBUTOR
diff_hunk: @@ -1,20 +1,43 @@
-FROM ghcr.io/scality/federation/nodesvc-base:7.10.5.0
-
-ENV UTAPI_CONFIG_FILE=${CONF_DIR}/config.json
+ARG DEBIAN_FRONTEND=noninteractive
+ARG UTAPI_VERSION=latest
+FROM ghcr.io/scality/utapi:${UTAPI_VERSION} AS base
path: images/nodesvc-base/Dockerfile
user: login: tcarmet
body: Also I might have misunderstood what you meant, did you meant to use only the `FROM ghcr.io/scality/utapi:${UTAPI_VERSION}` and install and configure the necessary thing on top of it instead of using a multi stage build?
created_at: 2025-04-02T20:04:52Z
author_association: CONTRIBUTOR
diff_hunk: @@ -1,20 +1,43 @@
-FROM ghcr.io/scality/federation/nodesvc-base:7.10.5.0
-
-ENV UTAPI_CONFIG_FILE=${CONF_DIR}/config.json
+ARG DEBIAN_FRONTEND=noninteractive
+ARG UTAPI_VERSION=latest
+FROM ghcr.io/scality/utapi:${UTAPI_VERSION} AS base
path: images/nodesvc-base/Dockerfile
user: login: BourgoisMickael
body: No, multi stage is better we've got things we don't need in the other image.

But can we keep the same nodejs version in every repo for the final stage.

Maybe if we can't touch the version for the artesca one we can have a local build stage if it's only to `yarn install` we don't need to be dependant on the other image
created_at: 2025-04-02T20:23:25Z
author_association: CONTRIBUTOR
diff_hunk: @@ -1,20 +1,43 @@
-FROM ghcr.io/scality/federation/nodesvc-base:7.10.5.0
-
-ENV UTAPI_CONFIG_FILE=${CONF_DIR}/config.json
+ARG DEBIAN_FRONTEND=noninteractive
+ARG UTAPI_VERSION=latest
+FROM ghcr.io/scality/utapi:${UTAPI_VERSION} AS base
+
+FROM node:22.11.0-bookworm-slim
path: images/nodesvc-base/Dockerfile
user: login: BourgoisMickael
body: We should be able to use `node:22.14` in this repo as well, even for artesca and the CI, I don't see any breaking or big changes in the changelog
created_at: 2025-04-08T08:22:33Z
author_association: CONTRIBUTOR
diff_hunk: @@ -1,20 +1,43 @@
-FROM ghcr.io/scality/federation/nodesvc-base:7.10.5.0
-
-ENV UTAPI_CONFIG_FILE=${CONF_DIR}/config.json
+ARG DEBIAN_FRONTEND=noninteractive
+ARG UTAPI_VERSION=latest
+FROM ghcr.io/scality/utapi:${UTAPI_VERSION} AS base
path: images/nodesvc-base/Dockerfile
user: login: tcarmet
body: I have aligned the two images with the same base image. 
created_at: 2025-04-08T20:00:42Z
author_association: CONTRIBUTOR
diff_hunk: @@ -1,20 +1,43 @@
-FROM ghcr.io/scality/federation/nodesvc-base:7.10.5.0
-
-ENV UTAPI_CONFIG_FILE=${CONF_DIR}/config.json
+ARG DEBIAN_FRONTEND=noninteractive
+ARG UTAPI_VERSION=latest
+FROM ghcr.io/scality/utapi:${UTAPI_VERSION} AS base
+
+FROM node:22.11.0-bookworm-slim
path: images/nodesvc-base/Dockerfile
user: login: tcarmet
body: using `node:22.14.0-bookworm-slim` now, on both images.
created_at: 2025-04-08T20:01:10Z
author_association: CONTRIBUTOR

PR comments:
user: login: bert-e
created_at: 2025-04-02T00:14:24Z
body: # Hello tcarmet,



My role is to assist you with the merge of this
pull request. Please type `@bert-e help` to get information
on this process, or consult the [user documentation](
https://bert-e.scality.net/scality/utapi/doc/user).


<details>
  <summary><b>Available options</b></summary>

  name   | description  | privileged   | authored
  ------ | ------------ | ------------ |----------
  `/after_pull_request` | Wait for the given pull request id to be merged before continuing with the current one. |  | 
  `/bypass_author_approval` | Bypass the pull request author's approval |  :star:  | 
  `/bypass_build_status` | Bypass the build and test status |  :star:  | 
  `/bypass_commit_size` | Bypass the check on the size of the changeset ```TBA``` |  :star:  | 
  `/bypass_incompatible_branch` | Bypass the check on the source branch prefix |  :star:  | 
  `/bypass_jira_check` | Bypass the Jira issue check |  :star:  | 
  `/bypass_peer_approval` | Bypass the pull request peers' approval |  :star:  | 
  `/bypass_leader_approval` | Bypass the pull request leaders' approval |  :star:  | 
  `/approve` | Instruct Bert-E that the author has approved the pull request. |  |  :writing_hand: 
  `/create_pull_requests` | Allow the creation of integration pull requests. |  | 
  `/create_integration_branches` | Allow the creation of integration branches. |  | 
  `/no_octopus` | Prevent Wall-E from doing any octopus merge and use multiple consecutive merge instead |  | 
  `/unanimity` | Change review acceptance criteria from `one reviewer at least` to `all reviewers` |  | 
  `/wait` | Instruct Bert-E not to run until further notice. |  | 
  

</details>



<details>
  <summary><b>Available commands</b></summary>

  name   | description  | privileged
  ------ | ------------ | ------------
  `/help` | Print Bert-E's manual in the pull request. | 
  `/status` | Print Bert-E's current status in the pull request ```TBA``` | 
  `/clear` | Remove all comments from Bert-E from the history ```TBA``` | 
  `/retry` | Re-start a fresh build ```TBA``` | 
  `/build` | Re-start a fresh build ```TBA``` | 
  `/force_reset` | Delete integration branches & pull requests, and restart merge process from the beginning. | 
  `/reset` | Try to remove integration branches unless there are commits on them which do not appear on the source branch. | 
  
</details>




*Status report is not available.*







author_association: CONTRIBUTOR
user: login: bert-e
created_at: 2025-04-02T00:14:28Z
body: # Incorrect fix version



The `Fix Version/s` in issue UTAPI-110 contains:


* *None*



Considering where you are trying to merge, I ignored possible hotfix versions and I expected to find:



* `8.2.1`


Please check the `Fix Version/s` of UTAPI-110, or the target
branch of this pull request.





author_association: CONTRIBUTOR
user: login: bert-e
created_at: 2025-04-09T21:20:25Z
body: # Waiting for approval



The following approvals are needed before I can proceed with the merge:


* the author


* 2 peers












author_association: CONTRIBUTOR
user: login: tcarmet
created_at: 2025-04-09T23:20:55Z
body: /approve
author_association: CONTRIBUTOR
user: login: bert-e
created_at: 2025-04-09T23:21:06Z
body: # 


I have successfully merged the changeset of this pull request
into targetted development branches:


* :heavy_check_mark: `development/8.2`



The following branches have **NOT** changed:

* `development/6.4`
* `development/7.10`
* `development/7.4`
* `development/7.70`
* `development/8.1`



Please check the status of the associated issue UTAPI-110.

Goodbye tcarmet.




*The following options are set:* **approve**


author_association: CONTRIBUTOR