Skip to content

Commit a6fff45

Browse files
authored
Merge pull request #321 from rizlas/development
Updates Dockerfile to lates Debian 12 and removes unused clutter
2 parents 2e8d0f0 + 048edc4 commit a6fff45

3 files changed

Lines changed: 31 additions & 29 deletions

File tree

.dockerignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
11
settings.ini
2+
.dockerignore
3+
Dockerfile
4+
.git*
5+
.github
6+
docs
7+
scripts
8+
*.yaml
9+
requirements_3.6.txt

Dockerfile

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,33 @@
1-
FROM python:3.9-slim-bullseye AS PREBUILD
1+
FROM python:3.9-slim-bookworm AS builder
22

3-
# Install dependencies
4-
RUN apt-get update && apt-get -y upgrade && apt-get install -y git-core
5-
6-
COPY requirements.txt /tmp/requirements.txt
7-
8-
RUN pip3 install --upgrade pip && \
9-
pip3 install wheel && \
10-
pip3 install -r /tmp/requirements.txt && \
11-
pip3 install --upgrade git+https://github.com/vmware/vsphere-automation-sdk-python.git
12-
13-
14-
FROM python:3.9-slim-bullseye
3+
COPY requirements.txt .
154

165
# Install dependencies
17-
RUN apt-get update && apt-get -y upgrade
6+
RUN apt-get update && apt-get install -y --no-install-recommends git && \
7+
rm -rf /var/lib/apt/lists/* && \
8+
python3 -m venv /opt/netbox-sync/venv && \
9+
/opt/netbox-sync/venv/bin/python3 -m pip install --upgrade pip && \
10+
/opt/netbox-sync/venv/bin/pip install -r requirements.txt && \
11+
/opt/netbox-sync/venv/bin/pip install --upgrade git+https://github.com/vmware/vsphere-automation-sdk-python.git
1812

19-
# Run the application
20-
WORKDIR /app
13+
FROM python:3.9-slim-bookworm AS netbox-sync
2114

22-
RUN set -eux; \
23-
addgroup --gid 1000 netbox-sync; \
24-
adduser --uid 1000 --ingroup netbox-sync --shell /bin/sh --home /home/netbox-sync --disabled-password \
25-
--gecos "netbox-sync,0815,2342,9001" netbox-sync
15+
# Copy installed packages
16+
COPY --from=builder /opt/netbox-sync/venv /opt/netbox-sync/venv
2617

27-
# Prepare the application
28-
COPY Dockerfile LICENSE.txt netbox-sync.py README.md requirements.txt settings-example.ini /app/
29-
COPY module /app/module
18+
# Add netbox-sync user
19+
RUN groupadd --gid 1000 netbox-sync && \
20+
useradd --uid 1000 --gid netbox-sync --shell /bin/sh \
21+
--no-create-home --system netbox-sync
3022

31-
RUN chown -R netbox-sync:netbox-sync /app
23+
USER netbox-sync
3224

33-
# disable upgrading setup tools due to bug in setuptools and automation sdk
34-
# once this is fixed, switch back to: pip3 install --upgrade pip setuptools
35-
COPY --from=PREBUILD /usr/local /usr/local
25+
# Prepare the application
26+
WORKDIR /app
27+
COPY --chown=netbox-sync:netbox-sync . .
3628

37-
USER netbox-sync
29+
# Use virtual env packages and allow timezone setup
30+
ENV PATH=/opt/netbox-sync/venv/bin:$PATH
31+
ENV TZ=Europe/Berlin
3832

3933
ENTRYPOINT ["python3", "netbox-sync.py"]

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
packaging
2-
urllib3==1.26.12
2+
urllib3==1.26.16
33
wheel
44
requests==2.31.0
55
pyvmomi==7.0.3

0 commit comments

Comments
 (0)