Skip to content

Commit c9ba8c0

Browse files
committed
update docker config
1 parent 190d73a commit c9ba8c0

File tree

2 files changed

+46
-18
lines changed

2 files changed

+46
-18
lines changed

Dockerfile

+40-16
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,50 @@
1-
FROM python:3.9
1+
# https://docs.docker.com/engine/reference/builder/
22

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
65

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
138

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
1612

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 .
1943
RUN pipenv sync --dev --system
2044

2145
# Create mount point for docker-compose volume and set as current workdir
2246
WORKDIR /legaldb
2347

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
2650
USER user

docker-compose.yml

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# https://docs.docker.com/compose/compose-file/compose-file-v3/
12
version: "3"
23

34
services:
@@ -10,7 +11,7 @@ services:
1011
- ./:/legaldb
1112
command: >
1213
bash -c " while !</dev/tcp/db/${DJANGO_DATABASE_PORT}; do sleep 1; done;
13-
python manage.py runserver 0.0.0.0:8000"
14+
./manage.py runserver 0.0.0.0:8000"
1415
environment:
1516
- DJANGO_DATABASE_HOST=db
1617
- DJANGO_DATABASE_PASSWORD=${DJANGO_DATABASE_PASSWORD:-postgres}
@@ -20,7 +21,10 @@ services:
2021
- db
2122

2223
db:
23-
image: postgres:12.5-alpine
24+
# https://hub.docker.com/_/postgres
25+
#
26+
# Match version to Heroku app
27+
image: postgres:12.9-alpine
2428
environment:
2529
- POSTGRES_DB=${DJANGO_DATABASE_NAME}
2630
- POSTGRES_USER=${DJANGO_DATABASE_USER}

0 commit comments

Comments
 (0)