diff --git a/Dockerfile b/Dockerfile index a4c897d8f..0cf231c1b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,6 +27,11 @@ ENV DEBIAN_FRONTEND=noninteractive \ LANG=C.UTF-8 \ PYTHONFAULTHANDLER=1 +# Environment can be whatever is supported by setup.py +# so, either deployment, test +ARG ENVIRONMENT=deployment +# ARG ENVIRONMENT=test + # Apt installation # git: required by setuptools_scm. RUN apt-get update && \ @@ -40,35 +45,27 @@ RUN apt-get update && \ python3-pip \ && apt-get autoclean && \ apt-get autoremove && \ - rm -rf /var/lib/{apt,dpkg,cache,log} - -# Environment can be whatever is supported by setup.py -# so, either deployment, test -ARG ENVIRONMENT=deployment -# ARG ENVIRONMENT=test - -RUN echo "Environment is: $ENVIRONMENT" && \ - [ "$ENVIRONMENT" = "deployment" ] || \ - pip install --disable-pip-version-check pip-tools pytest-cov + rm -rf /var/lib/{apt,dpkg,cache,log} && \ + echo "Environment is: $ENVIRONMENT" && \ + ([ "$ENVIRONMENT" = "deployment" ] || \ + pip install --disable-pip-version-check pip-tools pytest-cov) # Set up a nice workdir and add the live code ENV APPDIR=/code WORKDIR $APPDIR COPY . $APPDIR -COPY --from=builder --link /build/*.whl ./ -RUN python3.10 -m pip --disable-pip-version-check -q install *.whl && \ - rm *.whl - # These ENVIRONMENT flags make this a bit complex, but basically, if we are in dev # then we want to link the source (with the -e flag) and if we're in prod, we # want to delete the stuff in the /code folder to keep it simple. -RUN if [ "$ENVIRONMENT" = "deployment" ] ; then\ - pip --no-cache-dir --disable-pip-version-check install .[$ENVIRONMENT]; \ - rm -rf /code/* /code/.git* ; \ - else \ - pip --disable-pip-version-check install --editable .[$ENVIRONMENT]; \ - fi && \ +COPY --from=builder --link /build/*.whl ./ +RUN python3.10 -m pip --disable-pip-version-check -q install *.whl && \ + rm *.whl && \ + ([ "$ENVIRONMENT" = "deployment" ] || \ + pip --disable-pip-version-check install --editable .[$ENVIRONMENT]) && \ + ([ "$ENVIRONMENT" != "deployment" ] || \ + (pip --no-cache-dir --disable-pip-version-check install .[$ENVIRONMENT] && \ + rm -rf /code/* /code/.git*)) && \ pip freeze && \ ([ "$ENVIRONMENT" != "deployment" ] || \ apt-get remove -y \