Mercurial > p > roundup > code
comparison scripts/Docker/Dockerfile @ 7604:d117ddcb0ed1
Update dockerfile build: new python base image, reduce disk space use
Use newest python:3-alpine.
Remove sphinxcontrib libraries and xapian docs that were left around
from the build saving 2M.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Tue, 15 Aug 2023 00:29:24 -0400 |
| parents | ed2bc951277b |
| children | 3f268f7157f3 |
comparison
equal
deleted
inserted
replaced
| 7603:7515d03fb26d | 7604:d117ddcb0ed1 |
|---|---|
| 25 # Python version as a.b Used for installation directory and | 25 # Python version as a.b Used for installation directory and |
| 26 # COPY from install dir in second stage. | 26 # COPY from install dir in second stage. |
| 27 ARG pythonversion=3.11 | 27 ARG pythonversion=3.11 |
| 28 | 28 |
| 29 #FROM python:3-alpine | 29 #FROM python:3-alpine |
| 30 FROM python@sha256:0a56f24afa1fc7f518aa690cb8c7be661225e40b157d9bb8c6ef402164d9faa7 as build | 30 FROM python@sha256:603975e62d85aa07578034d3d10ffa1983b7618a6abb6371cf51941be6b8842c as build |
| 31 | 31 |
| 32 # Inherit global values https://github.com/moby/moby/issues/37345 | 32 # Inherit global values https://github.com/moby/moby/issues/37345 |
| 33 ARG appdir | 33 ARG appdir |
| 34 | 34 |
| 35 WORKDIR $appdir | 35 WORKDIR $appdir |
| 95 sed -i -e '/PYTHON3_SO=/s/distutils\.//g' \ | 95 sed -i -e '/PYTHON3_SO=/s/distutils\.//g' \ |
| 96 -e '/PYTHON3_SO=/s/"SO"/"EXT_SUFFIX"/g' configure && \ | 96 -e '/PYTHON3_SO=/s/"SO"/"EXT_SUFFIX"/g' configure && \ |
| 97 ./configure --prefix=/usr/local --with-python3 --disable-documentation && \ | 97 ./configure --prefix=/usr/local --with-python3 --disable-documentation && \ |
| 98 make && make install && \ | 98 make && make install && \ |
| 99 pip uninstall --no-cache-dir -y sphinx && \ | 99 pip uninstall --no-cache-dir -y sphinx && \ |
| 100 pip uninstall --no-cache-dir -y -r $CWD/sphinxdeps.txt | 100 pip uninstall --no-cache-dir -y -r $CWD/sphinxdeps.txt && \ |
| 101 rm -rf /usr/local/share/doc/xapian-bindings | |
| 101 | 102 |
| 102 # add requirements for pip here, e.g. Whoosh, gpg, zstd or other | 103 # add requirements for pip here, e.g. Whoosh, gpg, zstd or other |
| 103 # modules not installed in the base library. | 104 # modules not installed in the base library. |
| 104 # ignore warnings from pip to use virtualenv | 105 # ignore warnings from pip to use virtualenv |
| 105 COPY scripts/Docker/requirements.txt . | 106 COPY scripts/Docker/requirements.txt . |
| 155 RUN if [ -n "$pip_mod" ]; then pip install --no-cache-dir ${pip_mod}; fi | 156 RUN if [ -n "$pip_mod" ]; then pip install --no-cache-dir ${pip_mod}; fi |
| 156 | 157 |
| 157 # build a new smaller docker image for execution. Build image above | 158 # build a new smaller docker image for execution. Build image above |
| 158 # is 1G in size. | 159 # is 1G in size. |
| 159 # FROM python:3-alpine | 160 # FROM python:3-alpine |
| 160 FROM python@sha256:0a56f24afa1fc7f518aa690cb8c7be661225e40b157d9bb8c6ef402164d9faa7 | 161 FROM python@sha256:603975e62d85aa07578034d3d10ffa1983b7618a6abb6371cf51941be6b8842c |
| 161 | 162 |
| 162 # import from global | 163 # import from global |
| 163 ARG appdir | 164 ARG appdir |
| 164 | 165 |
| 165 WORKDIR $appdir | 166 WORKDIR $appdir |
| 210 ARG pythonversion | 211 ARG pythonversion |
| 211 # pull over built assets | 212 # pull over built assets |
| 212 COPY --from=build /usr/local/lib/python${pythonversion}/site-packages /usr/local/lib/python${pythonversion}/site-packages/ | 213 COPY --from=build /usr/local/lib/python${pythonversion}/site-packages /usr/local/lib/python${pythonversion}/site-packages/ |
| 213 COPY --from=build /usr/local/bin/roundup* /usr/local/bin/ | 214 COPY --from=build /usr/local/bin/roundup* /usr/local/bin/ |
| 214 COPY --from=build /usr/local/share /usr/local/share/ | 215 COPY --from=build /usr/local/share /usr/local/share/ |
| 215 COPY scripts/Docker/roundup_start . | 216 COPY scripts/Docker/roundup_start scripts/Docker/roundup_healthcheck ./ |
| 216 COPY scripts/Docker/roundup_healthcheck . | |
| 217 | 217 |
| 218 # Do not run roundup as root. This creates roundup user and group. | 218 # Do not run roundup as root. This creates roundup user and group. |
| 219 ARG roundup_uid | 219 ARG roundup_uid |
| 220 RUN adduser -D -h ${appdir} -u ${roundup_uid:-1000} roundup | 220 RUN adduser -D -h ${appdir} -u ${roundup_uid:-1000} roundup |
| 221 | 221 |
