Debian Codegraph @

Dockerfile

raw
1 ARG PYTHON_VER=3.10
2 ARG IMG_OPTION=alpine
3
4 ### BUILDER
5
6 FROM python:${PYTHON_VER}-${IMG_OPTION} AS BUILDER
7
8 RUN pip install --upgrade pip
9
10 WORKDIR /local
11 COPY . /local
12
13 RUN python -m venv /opt/venv
14
15
16 ENV PATH="/opt/venv/bin:$PATH"
17
18 RUN apk add --no-cache build-base # Add build-base package
19 RUN pip --no-cache-dir install "." &&\
20 pip --no-cache-dir install ".[cli]"
21
22 # ----------------------------------- #
23
24 ### BASE
25
26 FROM python:${PYTHON_VER}-${IMG_OPTION} AS BASE
27
28 # Add a system user
29 RUN adduser --system anta
30
31 # Opencontainer labels
32 # Labels version and revision will be updating
33 # during the CI with accurate information
34 # To configure version and revision, you can use:
35 # docker build --label org.opencontainers.image.version=<your version> -t ...
36 # Doc: https://docs.docker.com/engine/reference/commandline/run/#label
37 LABEL "org.opencontainers.image.title"="anta" \
38 "org.opencontainers.artifact.description"="network-test-automation in a Python package and Python scripts to test Arista devices." \
39 "org.opencontainers.image.description"="network-test-automation in a Python package and Python scripts to test Arista devices." \
40 "org.opencontainers.image.source"="https://github.com/aristanetworks/anta" \
41 "org.opencontainers.image.url"="https://anta.arista.com" \
42 "org.opencontainers.image.documentation"="https://anta.arista.com" \
43 "org.opencontainers.image.licenses"="Apache-2.0" \
44 "org.opencontainers.image.vendor"="Arista Networks" \
45 "org.opencontainers.image.authors"="Khelil Sator, Angélique Phillipps, Colin MacGiollaEáin, Matthieu Tache, Onur Gashi, Paul Lavelle, Guillaume Mulocher, Thomas Grimonet" \
46 "org.opencontainers.image.base.name"="python" \
47 "org.opencontainers.image.revision"="dev" \
48 "org.opencontainers.image.version"="dev"
49
50 # Copy artifacts from builder
51 COPY --from=BUILDER /opt/venv /opt/venv
52
53 # Define PATH and default user
54 ENV PATH="/opt/venv/bin:$PATH"
55
56 USER anta
57
58 ENTRYPOINT [ "/opt/venv/bin/anta" ]