-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile
63 lines (52 loc) · 1.85 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
FROM ubuntu:22.04
# Add user that will be used in the container
RUN groupadd zednews && \
useradd --create-home --shell /bin/bash -g zednews zednews
RUN mkdir -p /home/zednews/app && chown zednews:zednews /home/zednews/app
# set work directory
WORKDIR /home/zednews/app
# set environment variables
# - Force Python stdout and stderr streams to be unbuffered.
ENV PYTHONUNBUFFERED=1 \
PYTHONHASHSEED=random \
PYTHONPATH=/home/zednews/app
# Install system dependencies required by the project
ARG DEBIAN_FRONTEND=noninteractive
ENV TZ Africa/Lusaka
RUN apt-get update --yes --quiet && apt-get install --yes --quiet --no-install-recommends \
build-essential \
libssl-dev libffi-dev python3-dev python3-venv tzdata locales \
curl \
git \
ffmpeg \
libpq-dev \
postgresql-client \
&& rm -rf /var/lib/apt/lists/*
# Set timezone to Africa/Lusaka
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen \
&& locale-gen \
&& ln -fs /usr/share/zoneinfo/${TZ} /etc/localtime \
&& dpkg-reconfigure tzdata
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
# Use user "zednews" to run the build commands below
USER zednews
# set up virtual environment & install python dependencies
ARG POETRY_VERSION=1.8.3
ARG DEVELOPMENT
ENV VIRTUAL_ENV=/home/zednews/venv \
DEVELOPMENT=${DEVELOPMENT}
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
RUN pip install --upgrade pip
RUN python -m pip install poetry==$POETRY_VERSION
COPY --chown=zednews ./pyproject.toml .
COPY --chown=zednews ./poetry.lock .
RUN poetry install ${DEVELOPMENT:+--with dev} --no-root
# Copy the source code of the project into the container
COPY --chown=zednews:zednews . .
RUN poetry install --only-root
# Runtime command that executes when "docker run" is called
# basically, do nothing ... we'll run commands ourselves
CMD tail -f /dev/null