From 0fdd7b509d4a4e880fdf88d164d1957b6e1b8213 Mon Sep 17 00:00:00 2001 From: Dustin Black Date: Wed, 5 Jul 2023 23:21:51 +0200 Subject: [PATCH] Use new base images (#39) * Convert Dockerfile to use new standard base images * improve Dockerfile comments * version set the base images --- Dockerfile | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/Dockerfile b/Dockerfile index d2b6cc3..60252c7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,46 +1,41 @@ +# Package path for this plugin module relative to the repo root ARG package=arcaflow_plugin_template_python -# build poetry -FROM quay.io/centos/centos:stream8 as poetry +# STAGE 1 -- Build module dependencies and run tests +# The 'poetry' and 'coverage' modules are installed and verson-controlled in the +# quay.io/arcalot/arcaflow-plugin-baseimage-python-buildbase image to limit drift +FROM quay.io/arcalot/arcaflow-plugin-baseimage-python-buildbase:0.1.0 as build ARG package -RUN dnf -y module install python39 && dnf -y install python39 python39-pip - -WORKDIR /app COPY poetry.lock /app/ COPY pyproject.toml /app/ -RUN python3.9 -m pip install poetry==1.4.2 \ - && python3.9 -m poetry config virtualenvs.create false \ - && python3.9 -m poetry install --without dev --no-root \ +# Convert the dependencies from poetry to a static requirements.txt file +RUN python3.9 -m poetry install --without dev --no-root \ && python3.9 -m poetry export -f requirements.txt --output requirements.txt --without-hashes -# run tests COPY ${package}/ /app/${package} COPY tests /app/${package}/tests ENV PYTHONPATH /app/${package} WORKDIR /app/${package} -RUN mkdir /htmlcov -RUN python3.9 -m pip install coverage==7.2.7 \ - && python3.9 -m coverage run tests/test_${package}.py \ +# Run tests and return coverage analysis +RUN python3.9 -m coverage run tests/test_${package}.py \ && python3.9 -m coverage html -d /htmlcov --omit=/usr/local/* -# final image -FROM quay.io/centos/centos:stream8 +# STAGE 2 -- Build final plugin image +FROM quay.io/arcalot/arcaflow-plugin-baseimage-python-osbase:0.1.0 ARG package -RUN dnf -y module install python39 && dnf -y install python39 python39-pip - -WORKDIR /app -COPY --from=poetry /app/requirements.txt /app/ -COPY --from=poetry /htmlcov /htmlcov/ +COPY --from=build /app/requirements.txt /app/ +COPY --from=build /htmlcov /htmlcov/ COPY LICENSE /app/ COPY README.md /app/ COPY ${package}/ /app/${package} +# Install all plugin dependencies from the generated requirements.txt file RUN python3.9 -m pip install -r requirements.txt WORKDIR /app/${package}