Skip to content

Commit 49123e5

Browse files
committed
Rework for non-root user execution
1 parent e775336 commit 49123e5

File tree

2 files changed

+48
-43
lines changed

2 files changed

+48
-43
lines changed

Dockerfile

+11-43
Original file line numberDiff line numberDiff line change
@@ -3,58 +3,26 @@ FROM python:${PYTHON}-slim-bullseye
33

44
ENV PATH="/root/.local/bin:$PATH" \
55
PYTHONDONTWRITEBYTECODE=1 \
6-
PYTHONUNBUFFERED=1
6+
PYTHONUNBUFFERED=1
77

88
RUN apt-get update \
99
&& apt-get install -yq curl git pandoc make vim wget \
1010
&& apt-get -y upgrade \
1111
&& curl -sSL https://install.python-poetry.org | python \
1212
&& poetry config virtualenvs.create false
1313

14+
RUN useradd -u 111 -m netdevops
1415

15-
RUN pip3 install --no-cache-dir \
16-
nornir \
17-
nornir_netmiko \
18-
nornir_napalm \
19-
nornir_paramiko \
20-
nornir_scrapli \
21-
nornir_netbox \
22-
nornir_ansible \
23-
netmiko \
24-
napalm \
25-
paramiko \
26-
scrapli \
27-
pexpect \
28-
pynetbox \
29-
textfsm \
30-
ntc-templates \
31-
ttp \
32-
numpy \
33-
pandas \
34-
flask \
35-
fastapi \
36-
"uvicorn[standard]" \
37-
gunicorn \
38-
python-zeep \
39-
psycopg2-binary \
40-
sqlalchemy \
41-
kafka-python \
42-
pika \
43-
redis \
44-
pytest \
45-
pylint \
46-
flake8 \
47-
yamllint \
48-
tabulate \
49-
rich \
50-
gitpython \
51-
openpyxl \
52-
scapy
53-
54-
55-
RUN useradd -u 111 netdevops
16+
WORKDIR /home/netdevops
17+
18+
COPY --chown=netdevops:netdevops requirements.txt requirements.txt
19+
20+
USER netdevops:netdevops
21+
22+
RUN pip3 install --user --no-cache-dir -r requirements.txt
23+
24+
ENV PATH="/home/netdevops/.local/bin:${PATH}"
5625

5726
WORKDIR /opt/netdevops
5827

5928
CMD ["/bin/bash"]
60-

requirements.txt

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
nornir
2+
nornir_netmiko
3+
nornir_napalm
4+
nornir_paramiko
5+
nornir_scrapli
6+
nornir_netbox
7+
nornir_ansible
8+
netmiko
9+
napalm
10+
paramiko
11+
scrapli
12+
pexpect
13+
pynetbox
14+
textfsm
15+
ntc-templates
16+
ttp
17+
numpy
18+
pandas
19+
flask
20+
fastapi
21+
uvicorn[standard]
22+
gunicorn
23+
python-zeep
24+
psycopg2-binary
25+
sqlalchemy
26+
kafka-python
27+
pika
28+
redis
29+
pytest
30+
pylint
31+
flake8
32+
yamllint
33+
tabulate
34+
rich
35+
gitpython
36+
openpyxl
37+
scapy

0 commit comments

Comments
 (0)