Skip to content

Commit

Permalink
Proto update, blocking migration
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanculver committed Dec 9, 2022
1 parent 797445c commit ecb3bf6
Show file tree
Hide file tree
Showing 7 changed files with 1,173 additions and 1,467 deletions.
77 changes: 65 additions & 12 deletions development/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,73 @@
# -------------------------------------------------------------------------------------
# Nautobot Plugin Development Dockerfile Template
# Version: 1.0.0
#
# Plugins that need to add additional steps or packages can do in the section below.
# -------------------------------------------------------------------------------------
# !!! USE CAUTION WHEN MODIFYING LINES BELOW

ARG PYTHON_VER
ARG NAUTOBOT_VER
# Accepts a desired Nautobot version as build argument, default to 1.5.0
ARG NAUTOBOT_VER="1.5.0"

# Accepts a desired Python version as build argument, default to 3.7
ARG PYTHON_VER="3.7"

# Retrieve published development image of Nautobot base which should include most CI dependencies
FROM ghcr.io/nautobot/nautobot-dev:${NAUTOBOT_VER}-py${PYTHON_VER}

WORKDIR /source
# Runtime argument and environment setup
ARG NAUTOBOT_ROOT=/opt/nautobot

ENV prometheus_multiproc_dir=/prom_cache
ENV NAUTOBOT_ROOT ${NAUTOBOT_ROOT}

# Don't need virtual environments in container, parallelized installer has inconsistent behavior
RUN poetry config virtualenvs.create false \
&& poetry config installer.parallel false

# !!! USE CAUTION WHEN MODIFYING LINES ABOVE
# -------------------------------------------------------------------------------------
# Plugin-specific system build/test dependencies.
#
# Example: LDAP requires `libldap2-dev` to be apt-installed before the Python package.
# -------------------------------------------------------------------------------------
# --> Start safe to modify section

RUN pip install --upgrade pip
# Uncomment the line below if you are apt-installing any package.
# RUN apt update
# RUN apt install libldap2-dev

# Copy in only pyproject.toml/poetry.lock to help with caching this layer if no updates to dependencies
COPY poetry.lock pyproject.toml /source/
# --no-root declares not to install the project package since we're wanting to take advantage of caching dependency installation
# and the project is copied in and installed after this step
RUN poetry install --no-interaction --no-ansi --no-root
# --> Stop safe to modify section
# -------------------------------------------------------------------------------------
# Install Nautobot Plugin
# -------------------------------------------------------------------------------------
# !!! USE CAUTION WHEN MODIFYING LINES BELOW

# Copy in the rest of the source code and install local Nautobot plugin
# Copy in the source code
WORKDIR /source
COPY . /source
RUN poetry install --no-interaction --no-ansi

COPY development/nautobot_config.py /opt/nautobot/nautobot_config.py
# Get container's installed Nautobot version as a forced constraint
# NAUTOBOT_VER may be a branch name and not a published release therefor we need to get the installed version
# so pip can use it to recognize local constraints.
RUN pip show nautobot | grep "^Version: " | sed -e 's/Version: /nautobot==/' > constraints.txt

# Use Poetry to grab dev dependencies from the lock file
# Can be improved in Poetry 1.2 which allows `poetry install --only dev`
#
# We can't use the entire freeze as it takes forever to resolve with rigidly fixed non-direct dependencies,
# especially those that are only direct to Nautobot but the container included versions slightly mismatch
RUN poetry export -f requirements.txt --without-hashes --output poetry_freeze_base.txt
RUN poetry export -f requirements.txt --dev --without-hashes --output poetry_freeze_all.txt
RUN sort poetry_freeze_base.txt poetry_freeze_all.txt | uniq -u > poetry_freeze_dev.txt

# Install all local project as editable, constrained on Nautobot version, to get any additional
# direct dependencies of the plugin
RUN pip install -c constraints.txt -e .

# Install any dev dependencies frozen from Poetry
# Can be improved in Poetry 1.2 which allows `poetry install --only dev`
RUN pip install -c constraints.txt -r poetry_freeze_dev.txt

COPY development/nautobot_config.py ${NAUTOBOT_ROOT}/nautobot_config.py
# !!! USE CAUTION WHEN MODIFYING LINES ABOVE
7 changes: 4 additions & 3 deletions development/Dockerfile-dolt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:20.04
FROM ubuntu:22.04

RUN apt update && apt install -y curl mariadb-client && \
apt-get autoremove -y && \
Expand All @@ -7,7 +7,7 @@ RUN apt update && apt install -y curl mariadb-client && \

RUN mkdir -p /var/lib/nautobot

ARG DOLT_RELEASE="v0.35.5"
ARG DOLT_RELEASE="v0.51.9"
RUN curl -L https://github.com/dolthub/dolt/releases/download/${DOLT_RELEASE}/install.sh | bash

RUN dolt config --global --add user.name nautobot
Expand All @@ -24,4 +24,5 @@ ENV DOLT_ENABLE_DB_REVISIONS=true

RUN dolt init

CMD dolt sql-server --config /dolt-config.yaml
ARG DOLT_TRACE=""
CMD dolt sql-server --config /dolt-config.yaml ${DOLT_TRACE}
1 change: 1 addition & 0 deletions development/docker-compose.requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
version: "3.4"
services:
dolt:
platform: "linux/amd64"
build:
context: "../"
dockerfile: "development/Dockerfile-dolt"
Expand Down
6 changes: 6 additions & 0 deletions nautobot_version_control/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ class Meta:
"latest_commit_date",
"latest_commit_message",
)
exclude = [
"id"
]

def search(self, queryset, name, value): # pylint: disable=unused-argument,no-self-use
"""
Expand Down Expand Up @@ -64,6 +67,9 @@ class Meta:
"date",
"message",
)
exclude = [
"id"
]

def search(self, queryset, name, value): # pylint: disable=unused-argument,no-self-use
"""
Expand Down
Loading

0 comments on commit ecb3bf6

Please sign in to comment.