-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
89 lines (75 loc) · 3 KB
/
Dockerfile
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# vim: set syntax=dockerfile:
FROM ubuntu:bionic
ARG PYTHON_VERSION
ARG PIPENV_VERSION
ARG POETRY_VERSION
ENV DEBIAN_FRONTEND=noninteractive
ENV PYTHON_BIN=/usr/bin/python
ENV PIP_BIN=/usr/bin/pip
ENV PIPENV_VENV_IN_PROJECT=yes
ENV DEV_USER=dev
RUN apt-get update \
&& apt-get upgrade --quiet --yes \
&& apt-get update --quiet \
&& apt-get install --quiet --yes \
build-essential \
curl \
git \
locales \
python${PYTHON_VERSION} \
python${PYTHON_VERSION}-dev \
python${PYTHON_VERSION}-distutils \
python${PYTHON_VERSION}-venv \
software-properties-common \
tzdata \
unzip \
&& apt-get autoremove --quiet --yes \
&& apt-get clean \
&& curl --silent https://bootstrap.pypa.io/get-pip.py | python${PYTHON_VERSION} \
&& pip3 install pipenv==${PIPENV_VERSION} poetry==${POETRY_VERSION}
# Set the locale
RUN locale-gen en_US
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
# Set timezone
RUN rm /etc/localtime
RUN ln -s /usr/share/zoneinfo/Europe/Zurich /etc/localtime
# Create symbolic link to Python 3 binaries
RUN ln -sf $(which python${PYTHON_VERSION}) ${PYTHON_BIN}
RUN ln -sf $(which python${PYTHON_VERSION}) ${PYTHON_BIN}3
EXPOSE 8000
# Mount your app source code directory into that folder
WORKDIR /var/www/app
# Create less privileged user
RUN groupadd --gid 1000 ${DEV_USER} \
&& useradd --uid 1000 --gid ${DEV_USER} --shell /bin/bash --create-home ${DEV_USER}
# Fix permissions issues
RUN chmod --recursive a+wrx /var/www/app
RUN chmod a+wrx ${PYTHON_BIN}
RUN chmod a+wrx ${PYTHON_BIN}3
# Copy Poetry configuration file
COPY config/poetry/config.toml /root/.config/pypoetry/config.toml
COPY config/poetry/config.toml /home/${DEV_USER}/.config/pypoetry/config.toml
RUN chmod -R 775 /root/.config
RUN chown -R ${DEV_USER}:${DEV_USER} /home/${DEV_USER}/.config && chmod -R 775 /home/${DEV_USER}/.config
# Label schema related variables and metadata
ARG BUILD_DATE
ARG VCS_REF
LABEL maintainer="Julien M'Poy <[email protected]>" \
org.label-schema.build-date=${BUILD_DATE} \
org.label-schema.schema-version="1.0" \
org.label-schema.url="https://github.com/groovytron/python-container" \
org.label-schema.vcs-ref=${VCS_REF} \
org.label-schema.vcs-url="https://github.com/groovytron/python-container" \
org.opencontainers.image.authors="Julien M'Poy <[email protected]>" \
org.opencontainers.image.created=${BUILD_DATE} \
org.opencontainers.image.description="Python container for local Python web development" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.revision=${VCS_REF} \
org.opencontainers.image.source="https://github.com/groovytron/python-container" \
org.opencontainers.image.title="Python Container" \
org.opencontainers.image.url="https://github.com/groovytron/python-container" \
org.opencontainers.image.vendor="Julien M'Poy <[email protected]>" \
org.opencontainers.image.version="3.8"