-
Notifications
You must be signed in to change notification settings - Fork 77
/
Copy pathDockerfile
38 lines (27 loc) · 1.07 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
FROM python:3.11-slim-bookworm AS builder
COPY requirements.txt .
ARG VENV=/opt/netbox-sync/venv
# Install dependencies
RUN apt-get update && apt-get install -y --no-install-recommends git && \
rm -rf /var/lib/apt/lists/* && \
python3 -m venv $VENV && \
$VENV/bin/python3 -m pip install --upgrade pip && \
$VENV/bin/pip install -r requirements.txt && \
$VENV/bin/pip install --upgrade git+https://github.com/vmware/vsphere-automation-sdk-python.git && \
find $VENV -type d -name "__pycache__" -print0 | xargs -0 -n1 rm -rf
FROM python:3.11-slim-bookworm AS netbox-sync
ARG VENV=/opt/netbox-sync/venv
# Copy installed packages
COPY --from=builder $VENV $VENV
# Add netbox-sync user
RUN groupadd --gid 1000 netbox-sync && \
useradd --uid 1000 --gid netbox-sync --shell /bin/sh \
--no-create-home --system netbox-sync
USER netbox-sync
# Prepare the application
WORKDIR /app
COPY --chown=netbox-sync:netbox-sync . .
# Use virtual env packages and allow timezone setup
ENV PATH=$VENV/bin:$PATH
ENV TZ=Europe/Berlin
ENTRYPOINT ["python3", "netbox-sync.py"]