diff --git a/docker/docker-development.sh b/docker/docker-development.sh index ec210f66..a35c84cf 100755 --- a/docker/docker-development.sh +++ b/docker/docker-development.sh @@ -89,7 +89,7 @@ else # Also explicitly copy the .env file cp ../src/.env ingest-ui/src - docker compose -f docker-compose.yml -f docker-compose.development.yml -p ingest-ui build + docker compose -f docker-compose.yml -f docker-compose.development.yml -p ingest-ui build --no-cache elif [ "$1" = "start" ]; then docker compose -f docker-compose.yml -f docker-compose.development.yml -p ingest-ui up -d elif [ "$1" = "stop" ]; then @@ -97,4 +97,4 @@ else elif [ "$1" = "down" ]; then docker compose -f docker-compose.yml -f docker-compose.development.yml -p ingest-ui down fi -fi +fi \ No newline at end of file diff --git a/docker/ingest-ui/Dockerfile b/docker/ingest-ui/Dockerfile index 72da03c3..1e9da01d 100644 --- a/docker/ingest-ui/Dockerfile +++ b/docker/ingest-ui/Dockerfile @@ -1,5 +1,5 @@ # Parent image -FROM hubmap/api-base-image:1.1.0 +FROM hubmap/api-base-image:1.2.0 LABEL description="HuBMAP Ingest UI" @@ -9,46 +9,54 @@ WORKDIR /usr/src/app # Copy from host to image COPY . . -# http://nginx.org/en/linux_packages.html#RHEL-CentOS -# Set up the yum repository to install the latest mainline version of Nginx -RUN echo $'[nginx-mainline]\n\ -name=nginx mainline repo\n\ -baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/\n\ -gpgcheck=1\n\ -enabled=0\n\ -gpgkey=https://nginx.org/keys/nginx_signing.key\n\ -module_hotfixes=true\n'\ ->> /etc/yum.repos.d/nginx.repo +# Set up the repository file for the stable version of +# nginx which dnf should use (in the legacy "yum" location.) +RUN set -eux && \ + cat <<'EOF' > /etc/yum.repos.d/nginx.repo +[nginx-stable] +name=nginx stable repo +baseurl=http://nginx.org/packages/centos/$releasever/$basearch/ +gpgcheck=1 +enabled=1 +gpgkey=https://nginx.org/keys/nginx_signing.key +module_hotfixes=true +EOF # Reduce the number of layers in image by minimizing the number of separate RUN commands -# 1 - Install the prerequisites -# 2 - By default, the repository for stable nginx packages is used. We would like to use mainline nginx packages -# 3 - Install nginx (using the custom yum repo specified earlier) -# 4 - Remove the default nginx config file -# 5 - Overwrite the nginx.conf with ours to run nginx as non-root -# 6 - Use our nginx config file for ingest-ui -# 7 - Install Node.js v20.x (includes npm) -# 8 - Update npm to the latest version -# 9 - Make the start.sh executable -# 10 - Clean all yum cache -RUN yum install -y yum-utils && \ - yum-config-manager --enable nginx-mainline && \ - yum install -y nginx && \ - rm /etc/nginx/conf.d/default.conf && \ +# 1 - Install nginx (using the custom dnf/yum repo specified earlier) +# 2 - Remove the default nginx config file +# 3 - Overwrite the nginx.conf with ours to run nginx as non-root +# 4 - Use our nginx config file for ingest-ui +# 5 - Make the start.sh executable +# 6 - Clean the dnf/yum cache and other locations to reduce Docker Image layer size +RUN dnf install -y nginx && \ + [ ! -f /etc/nginx/conf.d/default.conf ] || mv /etc/nginx/conf.d/default.conf /tmp/etc_nginx_conf.d_default.conf.ORIGINAL && \ + [ ! -f /etc/nginx/nginx.conf ] || mv /etc/nginx/nginx.conf /tmp/etc_nginx_nginx.conf.ORIGINAL && \ mv nginx.conf /etc/nginx/nginx.conf && \ mv ingest-ui.conf /etc/nginx/conf.d && \ - curl -fsSL https://rpm.nodesource.com/setup_20.x | bash - && \ - yum install -y nodejs && \ - npm install npm@latest -g && \ - chmod +x start.sh && \ - yum clean all + [ ! -d nginx ] || mv nginx /tmp/nginx_from_WORKDIR && \ + chmod a+x start.sh && \ + dnf clean all && \ + rm -rf /var/cache/dnf \ + /var/log/dnf \ + /var/log/yum \ + /root/.cache # Change to source code directory WORKDIR /usr/src/app/src -# Install dependencies and generate static production bundle with our custom tags -# Delete node_modules to reduce image size -RUN npm install && \ +# Reduce the number of layers in image by minimizing the number of separate RUN commands +# 1 - Download and install nvm: +# 2 - In lieu of restarting the shell +# 3 - Download and install Node.js v24 +# 4 - Update npm to the latest version +# 5 - Install dependencies and generate static production bundle with our custom tags +# 6 - Delete node_modules to reduce image size +RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash && \ + \. "$HOME/.nvm/nvm.sh" && \ + nvm install 24 && \ + npm install npm@latest -g && \ + npm install && \ npm run build:tags && \ rm -rf node_modules diff --git a/docker/ingest-ui/start.sh b/docker/ingest-ui/start.sh index f6fe6c52..8393411f 100755 --- a/docker/ingest-ui/start.sh +++ b/docker/ingest-ui/start.sh @@ -1,7 +1,9 @@ #!/bin/bash # Replace the custom tags with deployment specific .env -python /usr/src/app/src/envs/env_tool.py /usr/src/app/src/.env /usr/src/app/src/build & +# NOTE: Explicitly call the Python executable with its full path instead of just `python` or `python3.13` +# This is due to the api-base-image v1.2.0 uses aliases +/usr/local/bin/python3.13 /usr/src/app/src/envs/env_tool.py /usr/src/app/src/.env /usr/src/app/src/build & # Start nginx to serve the static build nginx -g 'daemon off;' \ No newline at end of file