-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathDockerfile
73 lines (59 loc) · 1.91 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
# using ubuntu LTS version
FROM ubuntu:20.04 AS builder-image
# avoid stuck build due to user prompt
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install \
--no-install-recommends -y \
software-properties-common \
&& add-apt-repository ppa:deadsnakes/ppa -y \
&& apt-get update \
&& apt-get install \
--no-install-recommends -y \
python3.10 \
python3.10-dev \
python3.10-venv \
python3.10-distutils \
build-essential \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# create and activate virtual environment
RUN python3.10 -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
# Install pip requirements
COPY requirements.txt .
RUN pip3 install --no-cache-dir wheel && 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 \
software-properties-common \
&& add-apt-repository ppa:deadsnakes/ppa -y \
&& apt-get update \
&& apt-get install \
--no-install-recommends -y \
python3.10 \
python3.10-venv \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN useradd --create-home appuser
COPY --from=builder-image --chown=appuser:appuser /opt/venv /opt/venv
RUN mkdir -p /home/appuser/app
COPY --chown=appuser:appuser . /home/appuser/app
WORKDIR /home/appuser/app
# In addition to chown above, sets user after files have been copied
USER appuser
# Keeps Python from generating .pyc files in the container
ENV PYTHONDONTWRITEBYTECODE=1
# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED=1
# activate virtual environment
ENV VIRTUAL_ENV="/opt/venv"
RUN python3.10 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
# call script
ENTRYPOINT ["python", "scriptorium"]
# pass help flag by default `docker run scriptorium`
# can be overrridden via `docker run scriptorium down`
CMD ["-h"]
# CMD [ "bash" ]