|
1 |
| -FROM python:3.9 |
| 1 | +# https://docs.docker.com/engine/reference/builder/ |
2 | 2 |
|
3 |
| -# Run python in unbuffered mode to allow for log messages to be |
4 |
| -# immediately dumped to the stream instead of being buffered. |
5 |
| -ENV PYTHONUNBUFFERED 1 |
| 3 | +# https://hub.docker.com/_/python/ |
| 4 | +FROM python:3.9-slim |
6 | 5 |
|
7 |
| -# Install Python and system dependencies |
8 |
| -RUN pip install --upgrade pip \ |
9 |
| - && pip install --upgrade setuptools \ |
10 |
| - && pip install --upgrade pipenv |
11 |
| -RUN apt-get update \ |
12 |
| - && apt-get install -y --no-install-recommends gettext |
| 6 | +# Configure apt not to prompt during docker build |
| 7 | +ARG DEBIAN_FRONTEND=noninteractive |
13 | 8 |
|
14 |
| -# Copy the Pipenv files into the container |
15 |
| -COPY Pipfile* /tmp/ |
| 9 | +# Python: disable bytecode (.pyc) files |
| 10 | +# https://docs.python.org/3.9/using/cmdline.html |
| 11 | +ENV PYTHONDONTWRITEBYTECODE=1 |
16 | 12 |
|
17 |
| -# Install the dependencies system-wide |
18 |
| -WORKDIR /tmp |
| 13 | +# Python: force the stdout and stderr streams to be unbuffered |
| 14 | +# https://docs.python.org/3.9/using/cmdline.html |
| 15 | +ENV PYTHONUNBUFFERED=1 |
| 16 | + |
| 17 | +# Python: enable faulthandler to dump Python traceback on catastrophic cases |
| 18 | +# https://docs.python.org/3.9/library/faulthandler.html |
| 19 | +ENV PYTHONFAULTHANDLER=1 |
| 20 | + |
| 21 | +WORKDIR /root |
| 22 | + |
| 23 | +# Configure apt to avoid installing recommended and suggested packages |
| 24 | +RUN apt-config dump \ |
| 25 | +| grep -E '^APT::Install-(Recommends|Suggests)' \ |
| 26 | +| sed -e's/1/0/' \ |
| 27 | +| tee /etc/apt/apt.conf.d/99no-recommends-no-suggests |
| 28 | + |
| 29 | +# Resynchronize apt package index |
| 30 | +RUN apt-get update |
| 31 | + |
| 32 | +# Install apt package dependencies |
| 33 | +RUN apt-get install -y gcc gettext postgresql-server-dev-all |
| 34 | + |
| 35 | +## Install pipenv |
| 36 | +RUN pip install --upgrade pip |
| 37 | +RUN pip install --upgrade setuptools |
| 38 | +RUN pip install --upgrade pipenv |
| 39 | + |
| 40 | +# Install python dependencies |
| 41 | +COPY Pipfile . |
| 42 | +COPY Pipfile.lock . |
19 | 43 | RUN pipenv sync --dev --system
|
20 | 44 |
|
21 | 45 | # Create mount point for docker-compose volume and set as current workdir
|
22 | 46 | WORKDIR /legaldb
|
23 | 47 |
|
24 |
| -#Creating a user |
25 |
| -RUN useradd -ms /bin/bash user |
| 48 | +# Create non-root user |
| 49 | +RUN useradd --create-home --shell /bin/bash user |
26 | 50 | USER user
|
0 commit comments