-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile
58 lines (44 loc) · 1.87 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
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 \
&& apt-get update \
&& apt-get install --no-install-recommends -y \
build-essential python3.10 python3.10-distutils python3.10-dev python3.10-venv python3-pip python3-wheel \
&& 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
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install --no-install-recommends -y \
software-properties-common \
&& add-apt-repository ppa:deadsnakes/ppa \
&& apt-get update \
&& apt-get install --no-install-recommends -y python3.10 python3.10-venv \
&& apt-get clean && rm -rf /var/lib/apt/lists/* \
&& useradd --create-home appuser \
&& mkdir -p /home/appuser/app \
&& chown appuser:appuser /home/appuser/app
USER appuser
COPY --from=builder-image --chown=appuser:appuser /opt/venv /opt/venv
# activate virtual environment
# Keeps Python from generating .pyc files in the container
# Turns off buffering for easier container logging
ENV VIRTUAL_ENV="/opt/venv" \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
# Copy user code into application code
COPY --chown=appuser:appuser solutions /home/appuser/app
WORKDIR /home/appuser/app
# ENV EC2_KEY='not defined' K8S_KEY='not defined'
# Default arguments (originally /bin/bash)
ENTRYPOINT [ "/bin/bash" ]
# ENTRYPOINT [ "/opt/venv/bin/python", "main.py" ]