Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docker/docker-development.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@ 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
docker compose -f docker-compose.yml -f docker-compose.development.yml -p ingest-ui stop
elif [ "$1" = "down" ]; then
docker compose -f docker-compose.yml -f docker-compose.development.yml -p ingest-ui down
fi
fi
fi
74 changes: 41 additions & 33 deletions docker/ingest-ui/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"

Expand All @@ -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

Expand Down
4 changes: 3 additions & 1 deletion docker/ingest-ui/start.sh
Original file line number Diff line number Diff line change
@@ -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;'
Loading