Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dockerfile: fail on errors #596

Merged
merged 3 commits into from
Jun 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 17 additions & 20 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 && \
Expand All @@ -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 \
Expand Down
Loading