Skip to content

Commit e04e555

Browse files
committed
Switch to api_base_image 1.2.0, including dual-installation of Python 3.13 for uWSGI to use.
1 parent 0352b6b commit e04e555

3 files changed

Lines changed: 47 additions & 28 deletions

File tree

docker/entity-api/Dockerfile

Lines changed: 45 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Parent image
2-
FROM hubmap/api-base-image:1.1.0
2+
FROM hubmap/api-base-image:1.2.0
33

44
LABEL description="HuBMAP Entity API Service"
55

@@ -13,45 +13,64 @@ WORKDIR /usr/src/app
1313
# Copy from host to image
1414
COPY . .
1515

16-
# http://nginx.org/en/linux_packages.html#RHEL-CentOS
17-
# Set up the yum repository to install the latest mainline version of Nginx
18-
RUN echo $'[nginx-mainline]\n\
19-
name=nginx mainline repo\n\
20-
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/\n\
21-
gpgcheck=1\n\
22-
enabled=0\n\
23-
gpgkey=https://nginx.org/keys/nginx_signing.key\n\
24-
module_hotfixes=true\n'\
25-
>> /etc/yum.repos.d/nginx.repo
16+
# Set up the repository file for the mainline version of
17+
# nginx which dnf should use (in the legacy "yum" location.)
18+
RUN set -eux && \
19+
cat <<'EOF' > /etc/yum.repos.d/nginx.repo
20+
[nginx-mainline]
21+
name=nginx mainline repo
22+
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
23+
gpgcheck=1
24+
enabled=0
25+
gpgkey=https://nginx.org/keys/nginx_signing.key
26+
module_hotfixes=true
27+
EOF
2628

2729
# Reduce the number of layers in image by minimizing the number of separate RUN commands
2830
# 1 - Install the prerequisites
2931
# 2 - By default, the repository for stable nginx packages is used. We would like to use mainline nginx packages
30-
# 3 - Install nginx (using the custom yum repo specified earlier)
32+
# 3 - Install nginx (using the custom dnf/yum repo specified earlier)
3133
# 4 - Remove the default nginx config file
3234
# 5 - Overwrite the nginx.conf with ours to run nginx as non-root
3335
# 6 - Remove the nginx directory copied from host machine (nginx/conf.d gets mounted to the container)
34-
# 7 - Upgrade pip (the one installed in base image may be old) and install flask app dependencies (pip3 also works)
36+
# 7 - Upgrade pip (the one installed in base image may be old) and install service requirements.txt packages
3537
# 8 - Make the start script executable
36-
# 9 - Clean all yum cache
37-
RUN yum install -y yum-utils && \
38-
yum-config-manager --enable nginx-mainline && \
39-
yum install -y nginx && \
40-
rm /etc/nginx/conf.d/default.conf && \
41-
mv nginx/nginx.conf /etc/nginx/nginx.conf && \
42-
rm -rf nginx && \
43-
pip install --upgrade pip -r src/requirements.txt && \
44-
chmod +x start.sh && \
45-
yum clean all
38+
# 9 - Clean the dnf/yum cache and other locations to reduce Docker Image layer size.
39+
# Assume the base image has upgraded dnf and installed its dnf-plugins-core
40+
RUN dnf install --assumeyes dnf-plugins-core && \
41+
dnf config-manager --enable nginx-mainline && \
42+
dnf install --assumeyes nginx && \
43+
# Push aside nginx default.conf files that may exist on the system
44+
[ ! -f /etc/nginx/conf.d/default.conf ] || mv /etc/nginx/conf.d/default.conf /tmp/etc_nginx_conf.d_default.conf.ORIGINAL && \
45+
[ ! -f /etc/nginx/nginx.conf ] || mv /etc/nginx/nginx.conf /tmp/etc_nginx_nginx.conf.ORIGINAL && \
46+
# Install the nginx default.conf file just installed in WORKDIR
47+
mv nginx/nginx.conf /etc/nginx/nginx.conf && \
48+
# Clean up the nginx install directory in WORKDIR
49+
[ ! -d nginx ] || mv nginx /tmp/nginx_from_WORKDIR && \
50+
# Push aside the verification file from the base image which will
51+
# no longer report correctly once uWSGI is started for the service.
52+
[ ! -f /tmp/verify_uwsgi.sh ] || mv /tmp/verify_uwsgi.sh /tmp/verify_uwsgi.sh.ORIGINAL && \
53+
# Install the requirements.txt file for the service
54+
pip3.13 install --no-cache-dir --upgrade pip -r src/requirements.txt && \
55+
# Make the script referenced in the CMD directive below executable.
56+
chmod 755 start.sh && \
57+
# Clean up artifacts to slim down this layer of the Docker Image
58+
dnf clean all && \
59+
rm -rf /var/cache/dnf \
60+
/var/log/dnf \
61+
/var/log/yum \
62+
/root/.cache
4663

4764
# The EXPOSE instruction informs Docker that the container listens on the specified network ports at runtime.
4865
# EXPOSE does not make the ports of the container accessible to the host.
4966
# Here 5000 is for the uwsgi socket, 8080 for nginx
5067
EXPOSE 5000 8080
5168

52-
# Set an entrypoint
53-
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
54-
RUN chmod +x /usr/local/bin/entrypoint.sh
69+
# Set an entrypoint by moving the file copied into the WORKDIR to
70+
# the location referenced by the ENTRYPOINT directive below, and
71+
# make it executable.
72+
RUN mv entrypoint.sh /usr/local/bin/entrypoint.sh && \
73+
chmod 755 /usr/local/bin/entrypoint.sh
5574

5675
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
5776

docker/entity-api/start.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
nginx -g 'daemon off;' &
66

77
# Start uwsgi and keep it running in foreground
8-
uwsgi --ini /usr/src/app/src/uwsgi.ini
8+
/usr/local/python3.13/bin/uwsgi --ini /usr/src/app/src/uwsgi.ini

src/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ nested-lookup==0.2.22
1212

1313
# The commons package requires requests>=2.22.0 and PyYAML>=5.3.1
1414
requests==2.32.3
15-
PyYAML==5.4.1
15+
PyYAML==6.0.3
1616

1717
# Use the published package from PyPI as default
1818
# Use the branch name of commons from github for testing new changes made in commons from different branch

0 commit comments

Comments
 (0)