1
+ # hadolint global ignore=DL3008,SC2046
1
2
FROM 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" ]
3
7
4
8
# Add package files, install updated node and pip
5
9
WORKDIR /tmp
6
10
7
11
# Install packages
8
12
COPY 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/*
15
22
16
23
# 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
20
27
21
28
# # Set some poetry config
22
29
ENV \
23
- POETRY_VERSION=1.7.1 \
30
+ PYTHON_UNBUFFERED=1 \
31
+ POETRY_VERSION=1.8.5 \
24
32
POETRY_VIRTUALENVS_CREATE=true \
25
33
POETRY_CACHE_DIR='/tmp/cache/poetry' \
26
34
POETRY_HOME='/home/mitodl/.local' \
27
35
VIRTUAL_ENV="/opt/venv"
28
36
ENV PATH="$VIRTUAL_ENV/bin:$POETRY_HOME/bin:$PATH"
29
37
30
38
# Install poetry
31
- RUN pip install "poetry==$POETRY_VERSION"
39
+ RUN pip install --no-cache-dir "poetry==$POETRY_VERSION"
32
40
33
41
COPY pyproject.toml /src
34
42
COPY 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}
37
46
38
47
# # Install poetry itself, and pre-create a venv with predictable name
39
48
USER mitodl
40
- RUN curl -sSL https://install.python-poetry.org \
41
- | \
42
- POETRY_VERSION=${POETRY_VERSION} \
43
- POETRY_HOME=${POETRY_HOME} \
44
- python3 -q
45
49
WORKDIR /src
46
- RUN python3 -m venv $VIRTUAL_ENV
47
- RUN poetry install
50
+ RUN python3 -m venv $VIRTUAL_ENV && \
51
+ poetry install
48
52
49
53
# Add project
50
54
USER root
@@ -53,28 +57,12 @@ WORKDIR /src
53
57
54
58
# Generate commit hash file
55
59
ARG 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
75
63
76
64
USER mitodl
77
65
78
66
EXPOSE 8888
79
67
EXPOSE 8001
80
- ENV PORT 8001
68
+ ENV PORT= 8001
0 commit comments