Skip to content

Commit

Permalink
refactor: replace build image with upstream netbox image
Browse files Browse the repository at this point in the history
Has been a raw python image with a fill blown Netbox build.
  • Loading branch information
Felix Peters committed May 7, 2024
1 parent 16efe9b commit 56b4585
Show file tree
Hide file tree
Showing 5 changed files with 301 additions and 131 deletions.
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,12 @@ repos:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/python-poetry/poetry
rev: "1.8"
hooks:
- id: poetry-check
- id: poetry-lock
- id: poetry-export
args: ["-f", "requirements.txt"]
verbose: true
35 changes: 7 additions & 28 deletions develop/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,35 +1,14 @@
ARG netbox_ver=latest

FROM python:3.11
FROM netboxcommunity/netbox:${netbox_ver}

ENV PYTHONUNBUFFERED 1

RUN mkdir -p /opt

RUN pip install --upgrade pip\
&& pip install poetry

# -------------------------------------------------------------------------------------
# Install NetBox
# -------------------------------------------------------------------------------------
ARG netbox_ver=master

RUN git clone --single-branch --branch ${netbox_ver} https://github.com/netbox-community/netbox.git /opt/netbox/ && \
cd /opt/netbox/ && \
pip install -r /opt/netbox/requirements.txt

# Make the django-debug-toolbar always visible when DEBUG is enabled,
# except when we're running Django unit-tests.
RUN echo "import sys" >> /opt/netbox/netbox/netbox/settings.py && \
echo "TESTING = len(sys.argv) > 1 and sys.argv[1] == 'test'" >> /opt/netbox/netbox/netbox/settings.py && \
echo "DEBUG_TOOLBAR_CONFIG = {'SHOW_TOOLBAR_CALLBACK': lambda _: DEBUG and not TESTING }" >> /opt/netbox/netbox/netbox/settings.py

# -------------------------------------------------------------------------------------
# Install Netbox Plugin
# -------------------------------------------------------------------------------------
RUN mkdir -p /source
WORKDIR /source
COPY . /source
RUN poetry config virtualenvs.create false \
&& poetry install --no-interaction --no-ansi
COPY .. /source

# Install the plugin in netbox
RUN /opt/netbox/venv/bin/pip install -r /source/requirements.txt
RUN /opt/netbox/venv/bin/pip install --editable /source

WORKDIR /opt/netbox/netbox/
Loading

0 comments on commit 56b4585

Please sign in to comment.