From 8ee9dc9a94aa804feafb90db2accfe0120e7ef8d Mon Sep 17 00:00:00 2001 From: ryanmerolle Date: Fri, 29 Jul 2022 12:18:59 +0000 Subject: [PATCH] correct nginx dev setup --- .devcontainer/Dockerfile-plugin_dev | 8 ++--- .devcontainer/devcontainer.json | 18 +++++++---- Makefile | 48 ++++++++++++++--------------- 3 files changed, 40 insertions(+), 34 deletions(-) diff --git a/.devcontainer/Dockerfile-plugin_dev b/.devcontainer/Dockerfile-plugin_dev index 442c6e7..31b046d 100644 --- a/.devcontainer/Dockerfile-plugin_dev +++ b/.devcontainer/Dockerfile-plugin_dev @@ -22,7 +22,7 @@ RUN useradd -md /home/vscode -s /usr/bin/zsh -u $USER_UID $USERNAME \ && usermod -aG sudo $USERNAME \ && echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers \ && mkdir /opt/netbox/netbox/netbox-access-lists \ - && chown $USERNAME:$USERNAME /opt/netbox /etc/netbox -R + && chown $USERNAME:$USERNAME /opt/netbox /etc/netbox /opt/unit -R USER $USERNAME @@ -36,7 +36,7 @@ WORKDIR /opt/netbox/netbox/netbox-access-lists USER root -COPY entrypoint-dev.sh /bin/entrypoint.sh -RUN chmod +x /bin/entrypoint.sh +COPY entrypoint-dev.sh /bin/entrypoint-dev.sh +RUN chmod +x /bin/entrypoint-dev.sh -CMD ["/bin/entrypoint.sh"] +CMD ["/bin/entrypoint-dev.sh"] diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 4e24ad0..94e0f1e 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -30,14 +30,14 @@ "python.sortImports.path": "/opt/netbox/venv/bin/isort", "python.analysis.typeCheckingMode": "strict", "python.analysis.extraPaths": [ - "/opt/netbox/", + // "/opt/netbox/", "/opt/netbox/netbox" ], "python.autoComplete.extraPaths": [ - "/opt/netbox/netbox/", - "/opt/netbox/netbox/**", - "/opt/netbox/netbox/**/**" - + // "/opt/netbox/netbox/", + // "/opt/netbox/netbox/**", + // "/opt/netbox/netbox/**/**", + "/opt/netbox/netbox" ], "python.defaultInterpreterPath": "/opt/netbox/venv/bin/python3", "python.formatting.autopep8Path": "/opt/netbox/venv/bin/autopep8", @@ -62,7 +62,13 @@ "python.linting.pylintPath": "/opt/netbox/venv/bin/pylint", "python.pythonPath": "/opt/netbox/venv/bin/python3", "python.terminal.activateEnvironment": true, - "python.venvPath": "/opt/netbox/" + "python.venvPath": "/opt/netbox/", + "files.exclude": { + "**/node_modules": true, + "build": true, + "dist": true, + "*egg*": true + } }, // Add the IDs of extensions you want installed when the container is created. diff --git a/Makefile b/Makefile index 86ce924..d3fc3e4 100644 --- a/Makefile +++ b/Makefile @@ -4,19 +4,19 @@ VENV_PY_PATH=/opt/netbox/venv/bin/python3 NETBOX_MANAGE_PATH=/opt/netbox/netbox/manage.py VERFILE=./version.py -.PHONY: help -help: ## Display help message +.PHONY: help ## Display help message +help: @grep -E '^[0-9a-zA-Z_-]+\.*[0-9a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' -################# -# DOCKER # -################# - -# Outside of Devcontainer - -.PHONY: cleanup -cleanup: ## Clean associated docker resources. - -docker-compose -p netbox-access-lists_devcontainer rm -fv +################## +## DOCKER # +################## +# +## Outside of Devcontainer +# +#.PHONY: cleanup ## Clean associated docker resources. +#cleanup: +# -docker-compose -p netbox-access-lists_devcontainer rm -fv ################## # PLUGIN DEV # @@ -24,22 +24,22 @@ cleanup: ## Clean associated docker resources. # in VS Code Devcontianer -.PHONY: nbshell -nbshell: ## Run nbshell +.PHONY: nbshell ## Run nbshell +nbshell: ${VENV_PY_PATH} ${NETBOX_MANAGE_PATH} nbshell from netbox_access_lists.models import * -.PHONY: setup -setup: ## Copy plugin settings. Setup NetBox plugin. +.PHONY: setup ## Copy plugin settings. Setup NetBox plugin. +setup: -${VENV_PY_PATH} -m pip install --disable-pip-version-check --no-cache-dir -e ${REPO_PATH} #-python3 setup.py develop -.PHONY: makemigrations -makemigrations: ## Run makemigrations +.PHONY: makemigrations ## Run makemigrations +makemigrations: -${VENV_PY_PATH} ${NETBOX_MANAGE_PATH} makemigrations --name ${PLUGIN_NAME} -.PHONY: migrate -migrate: ## Run migrate +.PHONY: migrate ## Run migrate +migrate: -${VENV_PY_PATH} ${NETBOX_MANAGE_PATH} migrate .PHONY: startup_scripts @@ -50,12 +50,12 @@ startup_scripts: collectstatic: -${VENV_PY_PATH} ${NETBOX_MANAGE_PATH} collectstatic --no-input -.PHONY: start -start: ## Start NetBox - -${VENV_PY_PATH} ${NETBOX_MANAGE_PATH} runserver +.PHONY: start ## Start NetBox +start: + - cd /opt/netbox/netbox/ && /opt/netbox/docker-entrypoint.sh && /opt/netbox/launch-netbox.sh -.PHONY: all -all: setup makemigrations migrate collectstatic startup_scripts start ## Run all PLUGIN DEV targets +.PHONY: all ## Run all PLUGIN DEV targets +all: setup makemigrations migrate collectstatic startup_scripts start #.PHONY: test #test: