-
Notifications
You must be signed in to change notification settings - Fork 65
/
Dockerfile
33 lines (24 loc) · 1.04 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
FROM python:3.11-slim-bookworm AS builder
COPY requirements.txt .
# Install dependencies
RUN apt-get update && apt-get install -y --no-install-recommends git && \
rm -rf /var/lib/apt/lists/* && \
python3 -m venv /opt/netbox-sync/venv && \
/opt/netbox-sync/venv/bin/python3 -m pip install --upgrade pip && \
/opt/netbox-sync/venv/bin/pip install -r requirements.txt && \
/opt/netbox-sync/venv/bin/pip install --upgrade git+https://github.com/vmware/vsphere-automation-sdk-python.git
FROM python:3.11-slim-bookworm AS netbox-sync
# Copy installed packages
COPY --from=builder /opt/netbox-sync/venv /opt/netbox-sync/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=/opt/netbox-sync/venv/bin:$PATH
ENV TZ=Europe/Berlin
ENTRYPOINT ["python3", "netbox-sync.py"]