2.6 KiB
Executable File
Development environment set up
Note
Replace
/developmentwith the path where your code files will be stored. The default container name isnetalertxso there might be a conflict with your running containers.
1. Download the code:
mkdir /developmentcd /development && git clone https://github.com/jokob-sk/NetAlertX.git
2. Create a DEV .env_dev file
touch /development/.env_dev && sudo nano /development/.env_dev
The file content should be following, with your custom values.
#--------------------------------
#NETALERTX
#--------------------------------
TZ=Europe/Berlin
PORT=22222 # make sure this port is unique on your whole network
DEV_LOCATION=/development/NetAlertX
APP_DATA_LOCATION=/volume/docker_appdata
# ALWAYS_FRESH_INSTALL=true # uncommenting this will always delete the content of /config and /db dirs on boot to simulate a fresh install
3. Create /db and /config dirs
Create a folder netalertx in the APP_DATA_LOCATION (in this example in /volume/docker_appdata) with 2 subfolders db and config.
mkdir /volume/docker_appdata/netalertxmkdir /volume/docker_appdata/netalertx/dbmkdir /volume/docker_appdata/netalertx/config
4. Run the container
cd /development/NetAlertX && sudo docker-compose --env-file ../.env_dev
You can then modify the python script without restarting/rebuilding the container every time. Additionally, you can trigger a plugin run via the UI:
💡 Tips
A quick cheat sheet of useful commands.
Removing the container and image
A command to stop, remove the container and the image (replace netalertx and netalertx-netalertx with the appropriate values)
sudo docker container stop netalertx ; sudo docker container rm netalertx ; sudo docker image rm netalertx-netalertx
Restart the server backend
Most code changes can be tetsed without rebuilding the container. When working on the python server backend, you only need to restart the server.
- You can usually restart the backend via Maintenance > Logs > Restart server
- If above doesn't work, SSH into the container and kill & restart the main script loop
sudo docker exec -it netalertx /bin/bashpkill -f "python /app/server" && python /app/server &
- If none of the above work, restart the docker image. This is usually the last resort as sometimes the Docker engine becomes unresponsive and the whole engine needs to be restarted.
