-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
34 lines (24 loc) · 1.21 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
FROM ubuntu:20.04 AS builder-image
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install --no-install-recommends -y python3.9 python3.9-dev python3.9-venv python3-pip python3-wheel build-essential && apt-get clean && rm -rf /var/lib/apt/lists/*
# create and activate virtual environment using final folder name to avoid path issues with packages
RUN python3.9 -m venv /home/textfocususer/venv
ENV PATH="/home/textfocususer/venv/bin:$PATH"
# install requirements
COPY src/requirements.txt .
RUN pip3 install --no-cache-dir wheel
RUN pip3 install --no-cache-dir -r requirements.txt
FROM ubuntu:20.04 AS runner-image
RUN apt-get update && apt-get install --no-install-recommends -y python3.9 python3-venv && apt-get clean && rm -rf /var/lib/apt/lists/*
RUN useradd --create-home textfocususer
COPY --from=builder-image /home/textfocususer/venv /home/textfocususer/venv
USER textfocususer
RUN mkdir -p /home/textfocususer/ && chown textfocususer /home/textfocususer/
WORKDIR /home/textfocususer/
COPY src .
# make sure all messages always reach console
ENV PYTHONUNBUFFERED=1
# activate virtual environment
ENV VIRTUAL_ENV=/home/textfocususer/venv
ENV PATH="/home/textfocususer/venv/bin:$PATH"
CMD ["python", "main.py"]