移至檔案
Andreas Zweili c92d38bf62
Merge pull request #156 from Nebucatnetzer/dev
Update master
2023-08-28 20:45:59 +02:00
.github Remove poetry from github actions 2023-08-28 20:18:17 +02:00
.vscode use python3 explicitly 2022-03-01 09:33:27 +01:00
docs extend RM diagramm 2022-04-01 18:43:46 +02:00
nginx add a nginx container as a reverse proxy 2020-02-15 17:58:16 +01:00
src Allow IP 0.0.0.0 2023-07-22 16:40:59 +02:00
.coveragerc Make test runs work from any directory 2023-07-13 23:02:56 +02:00
.dir-locals.el Update emacs dir variables 2022-11-22 14:14:36 +01:00
.editorconfig Remove poetry2nix 2023-08-28 17:01:22 +02:00
.env-example use the production settings in the example 2022-03-29 21:11:37 +02:00
.envrc Readd poetry2nix 2023-08-28 20:12:20 +02:00
.gitignore Revert "Pdm" 2023-08-27 19:06:06 +02:00
.gitlab-ci.yml try a hack 2020-07-17 17:12:29 +02:00
LICENSE Initial commit 2017-12-21 23:11:33 +01:00
Procfile Randomize the ports 2023-07-22 15:58:26 +02:00
README.md Reformat 2023-07-18 20:22:32 +02:00
dev.sh Only update the lock file when updating poetry depencies 2023-08-28 20:15:34 +02:00
docker-compose.yml Get the postgres password from the env variable 2022-12-12 10:07:58 +01:00
flake.lock Readd poetry2nix 2023-08-28 20:12:20 +02:00
flake.nix Readd poetry2nix 2023-08-28 20:12:20 +02:00
poetry.lock Update dependencies 2023-08-28 17:12:14 +02:00
poetry.toml Revert "Pdm" 2023-08-27 19:06:06 +02:00
pyproject.toml Disable pylint messages for functions and classes 2023-08-28 17:33:14 +02:00
pytest.ini ignore warnings for the moment 2022-04-04 16:39:48 +02:00

README.md

network_inventory

.github/workflows/publish.yml

I started this project in order to have solution for keeping an inventory over my various servers and other network equipment.

Production Setup

  1. Clone the repository
  2. Copy the .env-example file to .env and change the POSTGRES_PASSWORD and DJANGO_SECRET_KEY variables to something secure.
  3. Run docker-compose up and connect to http://localhost

Development Setup

There is currently only one supported way to work with this repository. You will need a Linux system (WSL might work) onto wich you install the Nix package manager with Flakes enabled1 and direnv2. Afterwards you can enter the development environment with direnv allow.

After you've entered the development environment with either method you can start the development server with dev run. This will start a PostgreSQL database running and start the Django development server.

It will prompt you for your sudo password because it opens port 8000 in your firewall. This is because I sometimes develope from my iPad on my notebook and with this tweak I can access the dev server running on my notebook.

You can then access the project in the browser under the FQDN of your computer. E.g. http://mypc.domain.local:8000.

In case you want a fresh start or remove the project you can just remove the .direnv directory at the root of the project. All the data of the PostgreSQL database is stored there together with the symlinks to the Nix store.

In case you want to tweak something these are the applications use do build the development environment:

  • Nix package manager
  • direnv
  • overmind3

The dev command is a simple BASH script called dev.sh at the root of the project.

Run the dev command without an argument to see all options.

Why aren't you using Docker/containers for development.

I think containers have their uses but developing with them is in my opinion a pain in the ass. You just can't easily interact with the tools inside the container and you have to hack around to get your editor working with it. In addition they aren't fully reproducable. Nix solves all of these problems. Overmind then comes into play to orchestrate the few tasks that are required to get a development environment up an running.

Manual way

The manual way you have to install poetry4 and then run poetry shell to enter the virtual environment. You will then need a local PostgreSQL server or modify the settings so that you can use your prefered database.

Please note that I will only use and test the first method.

Environment Variables

To customise the application in the Docker container you can use environment variables in the docker-compose.yml file. Currently the following variables are supported.

  • DJANGO_SECRET_KEY the secret key is mandatory, otherwise the application doesn't run. Make sure that it is some long random string.
  • DJANGO_DEBUG settings this variable to any value enables the Django debug mode. Make sure that you don't set it on a production server.
  • DJANGO_SETTINGS_MODULE the path to the settings file to use in the container. This requires a dotet syntax. The default is network_inventory.settings.docker.

Documentation

Currently there isn't a lot of documentation present. I try to document my thoughts and other related information in the Notes file.