-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathContainerfile
More file actions
50 lines (38 loc) · 1.04 KB
/
Copy pathContainerfile
File metadata and controls
50 lines (38 loc) · 1.04 KB
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
FROM mcr.microsoft.com/mirror/docker/library/ubuntu:24.04
RUN <<HEREDOC
# install package dependencies and create nonroot user
set -eux
useradd -u 1001 -m nonroot
apt-get update
apt-get install -yqq --no-install-recommends \
python3-minimal \
python3-venv \
python3-pip
apt-get clean
rm -rf /var/lib/apt/lists/*
rm -rf /tmp/*
rm -rf /root/.cache
HEREDOC
# copy the minimal number of files to install the devtools
# this way we can cache as many container layers as possible
COPY pyproject.toml /opt/snraware/pyproject.toml
COPY README.md /opt/snraware/README.md
# create the skeleton of the packages so they install successfully
RUN <<HEREDOC
# create skeleton of python modules
set -eux
mkdir -p /opt/snraware/src/snraware
touch /opt/snraware/src/snraware/__init__.py
HEREDOC
WORKDIR /opt/snraware
RUN <<HEREDOC
# install python package
set -eux
python3 -m venv .venv
.venv/bin/pip install .
rm -rf /root/.cache
HEREDOC
COPY . /opt/snraware
ENV PATH="$PATH:/opt/snraware/.venv/bin"
# nothing should be installed after this step
USER nonroot