|
1 | | -FROM registry.access.redhat.com/ubi8/python-38:1-71.1634036286 |
| 1 | +FROM python:3.9.13-slim-buster as base |
2 | 2 |
|
3 | | -WORKDIR /opt/app-root/src |
| 3 | +# Setup env |
| 4 | +ENV LANG C.UTF-8 |
| 5 | +ENV LC_ALL C.UTF-8 |
| 6 | +ENV PYTHONDONTWRITEBYTECODE 1 |
| 7 | +ENV PYTHONFAULTHANDLER 1 |
4 | 8 |
|
5 | | -COPY --chown=1001:0 . . |
6 | | -RUN chmod -R g=u . |
7 | 9 |
|
8 | | -USER 1001 |
| 10 | +FROM base AS python-deps |
| 11 | + |
| 12 | +# Install pipenv and compilation dependencies |
| 13 | +RUN pip install --no-cache-dir --upgrade pip==22.2.2 && \ |
| 14 | + pip install --no-cache-dir pipenv==2022.8.24 gunicorn==20.1.0 django==4.1 django_bootstrap4==22.2 django_extensions==3.2.0 django-allow-cidr==0.5.0 django_q==1.3.9 psycopg2-binary==2.9.3 whitenoise==6.2.0 |
| 15 | + |
| 16 | +# Install python dependencies in /.venv |
| 17 | +WORKDIR / |
| 18 | +COPY Pipfile Pipfile.lock ./ |
| 19 | + |
| 20 | +RUN PIPENV_VENV_IN_PROJECT=1 pipenv install --deploy |
| 21 | + |
9 | 22 |
|
10 | | -ENV LC_ALL=C.UTF-8 \ |
11 | | - LANG=C.UTF-8 \ |
12 | | - PYTHONDONTWRITEBYTECODE=1 \ |
13 | | - PYTHONFAULTHANDLER=1 |
| 23 | +FROM base AS runtime |
| 24 | + |
| 25 | +# Install extra packages |
| 26 | +RUN apt-get update && \ |
| 27 | + apt-get install -y --no-install-recommends postgresql-client=11+200+deb10u4 iputils-ping=3:20180629-2+deb10u2 curl=7.64.0-4+deb10u3 && rm -rf /var/lib/apt/lists/* |
| 28 | + |
| 29 | +# Create and switch to a new user |
| 30 | +RUN useradd --create-home --uid 1001 --gid 0 appuser |
| 31 | +WORKDIR /home/appuser |
| 32 | + |
| 33 | +# Copy virtual env from python-deps stage |
| 34 | +COPY --from=python-deps /.venv /.venv |
| 35 | +ENV PATH="/.venv/bin:$PATH" |
| 36 | + |
| 37 | +# Install application into container |
| 38 | +COPY --chown=1001:0 . . |
| 39 | +RUN chmod -R g=u . |
14 | 40 |
|
15 | | -# see issue https://github.com/pypa/pipenv/issues/4220 for pipenv version |
16 | | -RUN pip install --no-cache-dir --upgrade pip==21.3.1 && \ |
17 | | - pip install --no-cache-dir pipenv==2018.11.26 && \ |
18 | | - pipenv install --system --dev |
| 41 | +USER appuser |
19 | 42 |
|
20 | 43 | EXPOSE 8080 |
21 | 44 |
|
22 | | -ENTRYPOINT ["sh", "entrypoint.sh"] |
23 | | -CMD ["gunicorn", "-b", "0.0.0.0:8080", "--env", "DJANGO_SETTINGS_MODULE=cfc_project.settings", "cfc_project.wsgi", "--timeout 120"] |
| 45 | +CMD ["bash", "entrypoint.sh"] |
0 commit comments