1+ # hadolint global ignore=DL3008,SC2046
12FROM python:3.12.6
2- LABEL maintainer
"ODL DevOps <[email protected] >" 3+ LABEL org.opencontainers.image.authors=
"ODL DevOps <[email protected] >" 4+
5+ # Set shell to bash with pipefail
6+ SHELL ["/bin/bash" , "-o" , "pipefail" , "-c" ]
37
48# Add package files, install updated node and pip
59WORKDIR /tmp
610
711# Install packages
812COPY apt.txt /tmp/apt.txt
9- RUN apt-get update
10- RUN apt-get install -y $(grep -vE "^\s *#" apt.txt | tr "\n " " " )
11- RUN apt-get update && apt-get install libpq-dev postgresql-client -y
12-
13- # pip
14- RUN curl --silent --location https://bootstrap.pypa.io/get-pip.py | python3 -
13+ RUN apt-get update \
14+ && apt-get install -y \
15+ --no-install-recommends \
16+ libpq-dev \
17+ postgresql-client \
18+ $(grep -vE '^\s *#' apt.txt | tr '\n ' ' ' ) \
19+ && apt-get clean \
20+ && apt-get purge \
21+ && rm -rf /var/lib/apt/lists/*
1522
1623# Add, and run as, non-root user.
17- RUN mkdir /src
18- RUN adduser --disabled-password --gecos "" mitodl
19- RUN mkdir /var/media && chown -R mitodl:mitodl /var/media
24+ RUN mkdir /src \
25+ && adduser --disabled-password --gecos "" mitodl \
26+ && mkdir /var/media && chown -R mitodl:mitodl /var/media
2027
2128# # Set some poetry config
2229ENV \
23- POETRY_VERSION=1.7.1 \
30+ PYTHON_UNBUFFERED=1 \
31+ POETRY_VERSION=1.8.5 \
2432 POETRY_VIRTUALENVS_CREATE=true \
2533 POETRY_CACHE_DIR='/tmp/cache/poetry' \
2634 POETRY_HOME='/home/mitodl/.local' \
2735 VIRTUAL_ENV="/opt/venv"
2836ENV PATH="$VIRTUAL_ENV/bin:$POETRY_HOME/bin:$PATH"
2937
3038# Install poetry
31- RUN pip install "poetry==$POETRY_VERSION"
39+ RUN pip install --no-cache-dir "poetry==$POETRY_VERSION"
3240
3341COPY pyproject.toml /src
3442COPY poetry.lock /src
35- RUN chown -R mitodl:mitodl /src
36- RUN mkdir ${VIRTUAL_ENV} && chown -R mitodl:mitodl ${VIRTUAL_ENV}
43+ RUN chown -R mitodl:mitodl /src && \
44+ mkdir ${VIRTUAL_ENV} && \
45+ chown -R mitodl:mitodl ${VIRTUAL_ENV}
3746
3847# # Install poetry itself, and pre-create a venv with predictable name
3948USER mitodl
40- RUN curl -sSL https://install.python-poetry.org \
41- | \
42- POETRY_VERSION=${POETRY_VERSION} \
43- POETRY_HOME=${POETRY_HOME} \
44- python3 -q
4549WORKDIR /src
46- RUN python3 -m venv $VIRTUAL_ENV
47- RUN poetry install
50+ RUN python3 -m venv $VIRTUAL_ENV && \
51+ poetry install
4852
4953# Add project
5054USER root
@@ -53,28 +57,12 @@ WORKDIR /src
5357
5458# Generate commit hash file
5559ARG GIT_REF
56- RUN mkdir -p /src/static
57- RUN echo $GIT_REF >> /src/static/hash.txt
58-
59- # Run collectstatic
60- ENV DATABASE_URL="postgres://postgres:postgres@localhost:5433/postgres"
61- ENV MITOL_SECURE_SSL_REDIRECT="False"
62- ENV MITOL_DB_DISABLE_SSL="True"
63- ENV MITOL_FEATURES_DEFAULT="True"
64- ENV CELERY_TASK_ALWAYS_EAGER="True"
65- ENV CELERY_BROKER_URL="redis://localhost:6379/4"
66- ENV CELERY_RESULT_BACKEND="redis://localhost:6379/4"
67- ENV MITOL_APP_BASE_URL="http://localhost:8002/"
68- ENV MAILGUN_KEY="fake_mailgun_key"
69- ENV MAILGUN_SENDER_DOMAIN="other.fake.site"
70- ENV MITOL_COOKIE_DOMAIN="localhost"
71- ENV MITOL_COOKIE_NAME="cookie_monster"
72- RUN python3 manage.py collectstatic --noinput --clear
73-
74- RUN apt-get clean && apt-get purge
60+ ARG RELEASE_VERSION
61+ RUN mkdir -p /src/static \
62+ && echo "{\" version\" : \" $RELEASE_VERSION\" , \" hash\" : \" $GIT_REF\" }" >> /src/static/hash.txt
7563
7664USER mitodl
7765
7866EXPOSE 8888
7967EXPOSE 8001
80- ENV PORT 8001
68+ ENV PORT= 8001
0 commit comments