From dc6557a42ae252cf0f8d8bb95a7a0b17985b67d8 Mon Sep 17 00:00:00 2001 From: eecavanna <134325062+eecavanna@users.noreply.github.com> Date: Mon, 16 Sep 2024 18:47:49 -0700 Subject: [PATCH 1/2] Delete obsolete `Dockerfile`s and references to old Node versions --- .dockerignore | 2 - installation/README.md | 4 +- webapp-node16.Dockerfile | 112 ------------------------------------- webapp-node18.Dockerfile | 118 --------------------------------------- 4 files changed, 2 insertions(+), 234 deletions(-) delete mode 100644 webapp-node16.Dockerfile delete mode 100644 webapp-node18.Dockerfile diff --git a/.dockerignore b/.dockerignore index b258ffe4..9ce019f1 100644 --- a/.dockerignore +++ b/.dockerignore @@ -4,8 +4,6 @@ # We won't benefit from the container image, itself, having access to these files. /.dockerignore -/webapp-node16.Dockerfile -/webapp-node18.Dockerfile /docker-compose.yml # The container image's copies of these directories will be generated diff --git a/installation/README.md b/installation/README.md index 5028af72..219454e7 100644 --- a/installation/README.md +++ b/installation/README.md @@ -1,7 +1,7 @@ ## INSTALLATION PREREQUISITES -### Install Node16 -https://nodejs.org/dist/latest-v16.x/ +### Install Node v20 +https://nodejs.org/en/download/prebuilt-installer ### Install pm2 `npm install pm2@latest -g` diff --git a/webapp-node16.Dockerfile b/webapp-node16.Dockerfile deleted file mode 100644 index 16913cdf..00000000 --- a/webapp-node16.Dockerfile +++ /dev/null @@ -1,112 +0,0 @@ -############################################################################### -# This is a Dockerfile you can use to build a container image that runs the # -# NMDC EDGE Web App. Its design was influenced by the installation script # -# at `installation/install.sh`. # -############################################################################### - -FROM node:16-alpine - -# Add metadata to the Docker image. -# Reference: https://docs.docker.com/engine/reference/builder/#label -LABEL org.opencontainers.image.description="NMDC EDGE Web App (Node v16)" -LABEL org.opencontainers.image.source="https://github.com/microbiomedata/nmdc-edge" - -# Create an environment variable that contains the web app version identifier. -# -# Note: Its value will come from the `--build-arg NMDC_EDGE_WEB_APP_VERSION={value}` -# CLI option, if any, included in the `$ docker build` command. -# Reference: https://docs.docker.com/reference/dockerfile/#arg -# -ARG NMDC_EDGE_WEB_APP_VERSION -ENV NMDC_EDGE_WEB_APP_VERSION="$NMDC_EDGE_WEB_APP_VERSION" - -# Create ORCID-related environment variables Node.js will consume while building the React app. -ARG IS_ORCID_AUTH_ENABLED -ENV REACT_APP_IS_ORCID_AUTH_ENABLED="$IS_ORCID_AUTH_ENABLED" - -ARG ORCID_CLIENT_ID -ENV REACT_APP_ORCID_CLIENT_ID="$ORCID_CLIENT_ID" - -# Allow the developer to (optionally) customize the ID and name of the user by which PM2 will -# be launched; and the ID and name of the group to which that user will belong. -ARG USER_ID=60005 -ARG GROUP_ID=60005 -ARG USER_NAME=webuser -ARG GROUP_NAME=webuser - -# Install programs upon which the web app or its build process(es) depend. -# -# Note: `apk` (Alpine Package Keeper) is the Alpine Linux equivalent of `apt`. -# Docs: https://wiki.alpinelinux.org/wiki/Alpine_Package_Keeper -# -RUN apk update && apk add \ - zip - -# Install the latest version of PM2 globally (https://github.com/Unitech/pm2). -RUN npm install -g pm2@latest - -# Set up both the web app client and the web app server. -# -# Note: I am intentionally omitting this Dockerfile from this COPY operation because I don't -# want to trigger lots of cache misses while I'm still developing this Dockerfile. -# -# Note: By copying so much of the file tree this early in the Docker image build process, -# we may be missing out on some Docker image layer caching opportunities. -# -RUN mkdir /app -WORKDIR /app -COPY ./data /app/data -COPY ./installation /app/installation -COPY ./webapp /app/webapp -COPY ./nmdc-edge.jpg /app/nmdc-edge.jpg -COPY ./pm2.config.js /app/pm2.config.js -# -# Generate empty folders (like `installation/install.sh` does). -# Note: `mkdir -p` automatically creates any necessary intermediate folders. -# -RUN mkdir -p io -RUN cd io && mkdir -p upload/files upload/tmp log projects public db sra -# -# Generate an `imports.zip` file for each group of WDL files (like `installation/install.sh` does). -# -RUN cd /app/data/workflow/WDL/metaG && zip -r imports.zip *.wdl -RUN cd /app/data/workflow/WDL/metaP && zip -r imports.zip *.wdl -RUN cd /app/data/workflow/WDL/metaT && zip -r imports.zip *.wdl -RUN cd /app/data/workflow/WDL/organicMatter && zip -r imports.zip *.wdl -RUN cd /app/data/workflow/WDL/virusPlasmids && zip -r imports.zip *.wdl -RUN cd /app/data/workflow/WDL/sra && zip -r imports.zip *.wdl -# -# Install the npm packages upon which the web app client depends. -# -# Note: The `--legacy-peer-deps` option is here because some of the npm packages upon which the web app depends, -# have conflicting dependencies with one another. The `--legacy-peer-deps` option causes npm to be more -# lenient about stuff like that. Reference: https://stackoverflow.com/a/66620869 -# -RUN cd webapp/client && npm ci --legacy-peer-deps -# -# Build the web app client (i.e. React app). -# -RUN cd webapp/client && npm run build -# -# Build the web app server (e.g. Express app). -# -RUN cd webapp/server && npm ci - -# Create a group having the specified GID (Group ID) and group name, and create -# a user (in that group) having the specified UID (User ID) and user name. -# Reference: https://gist.github.com/utkuozdemir/3380c32dfee472d35b9c3e39bc72ff01 -RUN addgroup -g $GROUP_ID $GROUP_NAME && \ - adduser --shell /sbin/nologin --disabled-password \ - --ingroup $GROUP_NAME --uid $USER_ID $USER_NAME - -# Switch to that user before running the subsequent commands. -# Reference: https://docs.docker.com/reference/dockerfile/#user -USER $USER_NAME - -# Run PM2 in the foreground. PM2 will serve the NMDC EDGE web app. -# -# Note: We use `pm2-runtime` (instead of `pm2` directly), as shown in the PM2 -# documentation about using PM2 inside containers. -# Docs: https://pm2.keymetrics.io/docs/usage/docker-pm2-nodejs/ -# -CMD ["pm2-runtime", "start", "pm2.config.js"] diff --git a/webapp-node18.Dockerfile b/webapp-node18.Dockerfile deleted file mode 100644 index 914cf018..00000000 --- a/webapp-node18.Dockerfile +++ /dev/null @@ -1,118 +0,0 @@ -############################################################################### -# This is a Dockerfile you can use to build a container image that runs the # -# NMDC EDGE Web App. Its design was influenced by the installation script # -# at `installation/install.sh`. # -############################################################################### - -FROM node:18-alpine - -# Add metadata to the Docker image. -# Reference: https://docs.docker.com/engine/reference/builder/#label -LABEL org.opencontainers.image.description="NMDC EDGE Web App (Node v18)" -LABEL org.opencontainers.image.source="https://github.com/microbiomedata/nmdc-edge" - -# Create an environment variable that contains the web app version identifier. -# -# Note: Its value will come from the `--build-arg NMDC_EDGE_WEB_APP_VERSION={value}` -# CLI option, if any, included in the `$ docker build` command. -# Reference: https://docs.docker.com/reference/dockerfile/#arg -# -ARG NMDC_EDGE_WEB_APP_VERSION -ENV NMDC_EDGE_WEB_APP_VERSION="$NMDC_EDGE_WEB_APP_VERSION" - -# Create ORCID-related environment variables Node.js will consume while building the React app. -ARG IS_ORCID_AUTH_ENABLED -ENV REACT_APP_IS_ORCID_AUTH_ENABLED="$IS_ORCID_AUTH_ENABLED" - -ARG ORCID_CLIENT_ID -ENV REACT_APP_ORCID_CLIENT_ID="$ORCID_CLIENT_ID" - -# Allow the developer to (optionally) customize the ID and name of the user by which PM2 will -# be launched; and the ID and name of the group to which that user will belong. -ARG USER_ID=60005 -ARG GROUP_ID=60005 -ARG USER_NAME=webuser -ARG GROUP_NAME=webuser - -# Install programs upon which the web app or its build process(es) depend. -# -# Note: `apk` (Alpine Package Keeper) is the Alpine Linux equivalent of `apt`. -# Docs: https://wiki.alpinelinux.org/wiki/Alpine_Package_Keeper -# -RUN apk update && apk add \ - zip - -# Update npm, itself, to the latest version. -RUN npm install -g npm@latest - -# Install the latest version of PM2 globally (https://github.com/Unitech/pm2). -RUN npm install -g pm2@latest - -# Set up both the web app client and the web app server. -# -# Note: I am intentionally omitting this Dockerfile from this COPY operation because I don't -# want to trigger lots of cache misses while I'm still developing this Dockerfile. -# -# Note: By copying so much of the file tree this early in the Docker image build process, -# we may be missing out on some Docker image layer caching opportunities. -# -RUN mkdir /app -WORKDIR /app -COPY ./data /app/data -COPY ./installation /app/installation -COPY ./webapp /app/webapp -COPY ./nmdc-edge.jpg /app/nmdc-edge.jpg -COPY ./pm2.config.js /app/pm2.config.js -# -# Generate empty folders (like `installation/install.sh` does). -# Note: `mkdir -p` automatically creates any necessary intermediate folders. -# -RUN mkdir -p io -RUN cd io && mkdir -p upload/files upload/tmp log projects public db sra -# -# Generate an `imports.zip` file for each group of WDL files (like `installation/install.sh` does). -# -RUN cd /app/data/workflow/WDL/metaG && zip -r imports.zip *.wdl -RUN cd /app/data/workflow/WDL/metaP && zip -r imports.zip *.wdl -RUN cd /app/data/workflow/WDL/metaT && zip -r imports.zip *.wdl -RUN cd /app/data/workflow/WDL/organicMatter && zip -r imports.zip *.wdl -RUN cd /app/data/workflow/WDL/virusPlasmids && zip -r imports.zip *.wdl -RUN cd /app/data/workflow/WDL/sra && zip -r imports.zip *.wdl -# -# Install the npm packages upon which the web app client depends. -# -# Note: The `--legacy-peer-deps` option is here because some of the npm packages upon which the web app depends, -# have conflicting dependencies with one another. The `--legacy-peer-deps` option causes npm to be more -# lenient about stuff like that. Reference: https://stackoverflow.com/a/66620869 -# -RUN cd webapp/client && npm ci --legacy-peer-deps -# -# Build the web app client (i.e. React app). -# -# Note: Prefix the `npm run build` command with `NODE_OPTIONS=--openssl-legacy-provider` -# in order to work around https://github.com/microbiomedata/nmdc-edge/issues/15. -# -RUN cd webapp/client && NODE_OPTIONS=--openssl-legacy-provider npm run build -# -# Build the web app server (e.g. Express app). -# -RUN cd webapp/server && npm ci - -# Create a group having the specified GID (Group ID) and group name, and create -# a user (in that group) having the specified UID (User ID) and user name. -# Reference: https://gist.github.com/utkuozdemir/3380c32dfee472d35b9c3e39bc72ff01 -RUN addgroup -g $GROUP_ID $GROUP_NAME && \ - adduser --shell /sbin/nologin --disabled-password \ - --ingroup $GROUP_NAME --uid $USER_ID $USER_NAME - -# Switch to that user before running the subsequent commands. -# Reference: https://docs.docker.com/reference/dockerfile/#user -USER $USER_NAME - -# Run PM2 in the foreground. PM2 will serve the NMDC EDGE web app. -# -# Note: We use `pm2-runtime` (instead of `pm2` directly), as shown in the PM2 -# documentation about using PM2 inside containers. -# Docs: https://pm2.keymetrics.io/docs/usage/docker-pm2-nodejs/ -# -CMD ["pm2-runtime", "start", "pm2.config.js"] From f507fb84a78ecc2598f759ca1b8b84876065b385 Mon Sep 17 00:00:00 2001 From: eecavanna <134325062+eecavanna@users.noreply.github.com> Date: Mon, 16 Sep 2024 18:52:14 -0700 Subject: [PATCH 2/2] Remove qualifiers from `Dockerfile` name and update references accordingly --- .github/workflows/build-and-push-image.yml | 2 +- webapp-node20.Dockerfile => Dockerfile | 2 +- docker-compose.yml | 2 +- docs/docker-compose.prod.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) rename webapp-node20.Dockerfile => Dockerfile (98%) diff --git a/.github/workflows/build-and-push-image.yml b/.github/workflows/build-and-push-image.yml index ecbf6bd6..1344e18c 100644 --- a/.github/workflows/build-and-push-image.yml +++ b/.github/workflows/build-and-push-image.yml @@ -39,7 +39,7 @@ jobs: uses: docker/build-push-action@v5 with: context: . - file: webapp-node20.Dockerfile + file: Dockerfile push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/webapp-node20.Dockerfile b/Dockerfile similarity index 98% rename from webapp-node20.Dockerfile rename to Dockerfile index dd87c194..96f0f1c4 100644 --- a/webapp-node20.Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ FROM node:20-alpine # Add metadata to the Docker image. # Reference: https://docs.docker.com/engine/reference/builder/#label -LABEL org.opencontainers.image.description="NMDC EDGE Web App (Node v20)" +LABEL org.opencontainers.image.description="NMDC EDGE Web App" LABEL org.opencontainers.image.source="https://github.com/microbiomedata/nmdc-edge" # Create an environment variable that contains the web app version identifier. diff --git a/docker-compose.yml b/docker-compose.yml index 712d1579..6cbded07 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,7 +5,7 @@ services: # The NMDC EDGE web app (both client and server). webapp: - build: { context: ".", dockerfile: "webapp-node20.Dockerfile" } + build: { context: ".", dockerfile: "Dockerfile" } # Override the container image's default command (i.e. the `CMD` defined in the Dockerfile), so that # PM2 runs in "watch" mode (i.e. so that PM2 restarts the application whenever a file changes). # Reference: https://pm2.keymetrics.io/docs/usage/restart-strategies/ diff --git a/docs/docker-compose.prod.yml b/docs/docker-compose.prod.yml index 2ef079e9..3eeb6d43 100644 --- a/docs/docker-compose.prod.yml +++ b/docs/docker-compose.prod.yml @@ -44,7 +44,7 @@ services: # Alternatively, to build an image from a Dockerfile (which will allow you to specify args at build time): #build: # context: /path/to/repository/root/directory - # dockerfile: webapp-node20.Dockerfile + # dockerfile: Dockerfile # args: # - USER_ID: ${USER_ID:-60005} # - GROUP_ID: ${GROUP_ID:-60005}