-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.python
49 lines (36 loc) · 1.25 KB
/
Dockerfile.python
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# syntax=docker/dockerfile:1.2
ARG PYTHON_VERSION=3.8
# Get watchman
FROM debian:bullseye AS watchman
RUN apt-get update && apt-get install -y watchman
# Done
# Create the project image
FROM python:$PYTHON_VERSION
# Get the watchman binary from the previous stage
RUN mkdir -p /usr/local/bin /usr/local/var/run/watchman
COPY --from=watchman /usr/bin/watchman /usr/local/bin/
RUN chmod 2777 /usr/local/var/run/watchman
# Install extras packages
RUN apt-get update && apt-get install -y \
sudo \
&& rm -rf /var/lib/apt/lists/*
# Create a "developer" user, with sudo privileges (no password)
RUN useradd -ms /bin/bash developer && \
echo "developer ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
USER developer
# Make sure stdout is not buffered, in order to see output in real time
ENV PYTHONUNBUFFERED 1
# Require an active virtualenv for pip
ENV PIP_REQUIRE_VIRTUALENV true
# Configure watchman
ENV DJANGO_WATCHMAN_TIMEOUT 30
WORKDIR /code
# Create the project layout and install the dependencies
COPY requirements_local.txt ./
# Create and activate the virtualenv
RUN python -m venv /code/var/venv
ENV VIRTUAL_ENV /code/var/venv
ENV PATH $VIRTUAL_ENV/bin:$PATH
# Install dependencies
python -m pip install -U pip
python -m pip install -r requirements_local.txt