Skip to content

Commit 6e35dac

Browse files
authored
Merge pull request #957 from hubmapconsortium/karlburke/MoveToBaseImage1.2.0WithPython3.13
Karlburke/move to base image1.2.0 with python3.13
2 parents 8cc8421 + 32e0881 commit 6e35dac

File tree

4 files changed

+47
-30
lines changed

4 files changed

+47
-30
lines changed

docker/docker-development.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ else
106106
cp ../VERSION entity-api
107107
cp ../BUILD entity-api
108108

109-
docker compose -f docker-compose.yml -f docker-compose.development.yml -p entity-api build
109+
docker compose -f docker-compose.yml -f docker-compose.development.yml -p entity-api build --no-cache
110110
elif [ "$1" = "start" ]; then
111111
docker compose -f docker-compose.yml -f docker-compose.development.yml -p entity-api up -d
112112
elif [ "$1" = "stop" ]; then

docker/entity-api/Dockerfile

Lines changed: 44 additions & 27 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,62 @@ 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 stable 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-stable]
21+
name=nginx stable repo
22+
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
23+
gpgcheck=1
24+
enabled=1
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
29-
# 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)
31+
# 2 - By default, the repository for stable nginx packages is used.
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 nginx && \
41+
# Push aside nginx default.conf files that may exist on the system
42+
[ ! -f /etc/nginx/conf.d/default.conf ] || mv /etc/nginx/conf.d/default.conf /tmp/etc_nginx_conf.d_default.conf.ORIGINAL && \
43+
[ ! -f /etc/nginx/nginx.conf ] || mv /etc/nginx/nginx.conf /tmp/etc_nginx_nginx.conf.ORIGINAL && \
44+
# Install the nginx default.conf file just installed in WORKDIR
45+
mv nginx/nginx.conf /etc/nginx/nginx.conf && \
46+
# Clean up the nginx install directory in WORKDIR
47+
[ ! -d nginx ] || mv nginx /tmp/nginx_from_WORKDIR && \
48+
# Push aside the verification file from the base image which will
49+
# no longer report correctly once uWSGI is started for the service.
50+
[ ! -f /tmp/verify_uwsgi.sh ] || mv /tmp/verify_uwsgi.sh /tmp/verify_uwsgi.sh.ORIGINAL && \
51+
# Install the requirements.txt file for the service
52+
pip3.13 install --no-cache-dir --upgrade pip -r src/requirements.txt && \
53+
# Make the script referenced in the CMD directive below executable.
54+
chmod a+x start.sh && \
55+
# Clean up artifacts to slim down this layer of the Docker Image
56+
dnf clean all && \
57+
rm -rf /var/cache/dnf \
58+
/var/log/dnf \
59+
/var/log/yum \
60+
/root/.cache
4661

4762
# The EXPOSE instruction informs Docker that the container listens on the specified network ports at runtime.
4863
# EXPOSE does not make the ports of the container accessible to the host.
4964
# Here 5000 is for the uwsgi socket, 8080 for nginx
5065
EXPOSE 5000 8080
5166

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

5673
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
5774

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)