From d37f51867e60794871618ccbbb2b004246806f04 Mon Sep 17 00:00:00 2001 From: Josh VanDeraa Date: Mon, 10 Apr 2023 18:23:33 +0000 Subject: [PATCH 1/2] Updates for docker compose plugin. --- changes/191.fixed | 1 + docs/dev/dev_environment.md | 28 +++++++++++++++------------- pyproject.toml | 2 +- tasks.py | 8 ++++---- 4 files changed, 21 insertions(+), 18 deletions(-) create mode 100644 changes/191.fixed diff --git a/changes/191.fixed b/changes/191.fixed new file mode 100644 index 00000000..07f68fc6 --- /dev/null +++ b/changes/191.fixed @@ -0,0 +1 @@ +Updated docker-compose to docker compose within the tasks.py file. \ No newline at end of file diff --git a/docs/dev/dev_environment.md b/docs/dev/dev_environment.md index 5fce28d0..dd8cc370 100644 --- a/docs/dev/dev_environment.md +++ b/docs/dev/dev_environment.md @@ -25,7 +25,10 @@ Using **Invoke** these configuration options can be overridden using [several me ### Docker Development Environment !!! tip - This is the recommended option for development. +As of 1.11.1 the Docker Compose environment has moved from the standalone docker-compose to the plugin execution of `docker compose`. Be sure that your version of Docker has the plugin installed. If the docker compose plugin is installed, no other changes to the invoke methodology is required. + +!!! tip +This is the recommended option for development. This project is managed by [Python Poetry](https://python-poetry.org/) and has a few requirements to setup your development environment: @@ -73,7 +76,7 @@ nautobot-server migrate ``` !!! note - If you want to develop on the latest develop branch of Nautobot, run the following command: `poetry add --optional git+https://github.com/nautobot/nautobot@develop`. After the `@` symbol must match either a branch or a tag. +If you want to develop on the latest develop branch of Nautobot, run the following command: `poetry add --optional git+https://github.com/nautobot/nautobot@develop`. After the `@` symbol must match either a branch or a tag. You can now run `nautobot-server` commands as you would from the [Nautobot documentation](https://nautobot.readthedocs.io/en/latest/) for example to start the development server: @@ -102,7 +105,7 @@ The project features a CLI helper based on [Invoke](https://www.pyinvoke.org/) t Each command can be executed with `invoke `. All commands support the arguments `--nautobot-ver` and `--python-ver` if you want to manually define the version of Python and Nautobot to use. Each command also has its own help `invoke --help` !!! note - To run the mysql (mariadb) development environment, set the environment variable as such `export NAUTOBOT_USE_MYSQL=1`. +To run the mysql (mariadb) development environment, set the environment variable as such `export NAUTOBOT_USE_MYSQL=1`. #### Local Development Environment @@ -136,15 +139,14 @@ Each command can be executed with `invoke `. All commands support the a unittest Run Django unit tests for the plugin. ``` - ## Project Overview -This project provides the ability to develop and manage the Nautobot server locally (with supporting services being *Dockerized*) or by using only Docker containers to manage Nautobot. The main difference between the two environments is the ability to debug and use **pdb** when developing locally. Debugging with **pdb** within the Docker container is more complicated, but can still be accomplished by either entering into the container (via `docker exec`) or attaching your IDE to the container and running the Nautobot service manually within the container. +This project provides the ability to develop and manage the Nautobot server locally (with supporting services being _Dockerized_) or by using only Docker containers to manage Nautobot. The main difference between the two environments is the ability to debug and use **pdb** when developing locally. Debugging with **pdb** within the Docker container is more complicated, but can still be accomplished by either entering into the container (via `docker exec`) or attaching your IDE to the container and running the Nautobot service manually within the container. The upside to having the Nautobot service handled by Docker rather than locally is that you do not have to manage the Nautobot server. The [Docker logs](#docker-logs) provide the majority of the information you will need to help troubleshoot, while getting started quickly and not requiring you to perform several manual steps and remembering to have the Nautobot server running in a separate terminal while you develop. !!! note - The local environment still uses Docker containers for the supporting services (Postgres, Redis, and RQ Worker), but the Nautobot server is handled locally by you, the developer. +The local environment still uses Docker containers for the supporting services (Postgres, Redis, and RQ Worker), but the Nautobot server is handled locally by you, the developer. Follow the directions below for the specific development environment that you choose. @@ -229,7 +231,7 @@ Once the containers are fully up, you should be able to open up a web browser, a - A live version of the documentation at [http://localhost:8001](http://localhost:8001) !!! note - Sometimes the containers take a minute to fully spin up. If the page doesn't load right away, wait a minute and try again. +Sometimes the containers take a minute to fully spin up. If the page doesn't load right away, wait a minute and try again. ### Invoke - Creating a Superuser @@ -240,7 +242,7 @@ The Nautobot development image will automatically provision a super user when sp - `NAUTOBOT_SUPERUSER_PASSWORD=admin` !!! note - The default username is **admin**, but can be overridden by specifying **NAUTOBOT_SUPERUSER_USERNAME**. +The default username is **admin**, but can be overridden by specifying **NAUTOBOT_SUPERUSER_USERNAME**. If you need to create additional superusers, run the follow commands. @@ -290,7 +292,7 @@ Removing network nautobot_chatops_default This will safely shut down all of your running Docker containers for this project. When you are ready to spin containers back up, it is as simple as running `invoke start` again [as seen previously](#invoke-starting-the-development-environment). !!! warning - If you're wanting to reset the database and configuration settings, you can use the `invoke destroy` command, but **you will lose any data stored in those containers**, so make sure that is what you want to do. +If you're wanting to reset the database and configuration settings, you can use the `invoke destroy` command, but **you will lose any data stored in those containers**, so make sure that is what you want to do. ### Real-Time Updates? How Cool! @@ -301,12 +303,12 @@ Now you can start developing your plugin in the project folder! The magic here is the root directory is mounted inside your Docker containers when built and ran, so **any** changes made to the files in here are directly updated to the Nautobot plugin code running in Docker. This means that as you modify the code in your plugin folder, the changes will be instantly updated in Nautobot. !!! warning - There are a few exceptions to this, as outlined in the section [To Rebuild or Not To Rebuild](#to-rebuild-or-not-to-rebuild). +There are a few exceptions to this, as outlined in the section [To Rebuild or Not To Rebuild](#to-rebuild-or-not-to-rebuild). The back-end Django process is setup to automatically reload itself (it only takes a couple of seconds) every time a file is updated (saved). So for example, if you were to update one of the files like `tables.py`, then save it, the changes will be visible right away in the web browser! !!! note - You may get connection refused while Django reloads, but it should be refreshed fairly quickly. +You may get connection refused while Django reloads, but it should be refreshed fairly quickly. ### Docker Logs @@ -317,7 +319,7 @@ When trying to debug an issue, one helpful thing you can look at are the logs wi ``` !!! note - The `-f` tag will keep the logs open, and output them in realtime as they are generated. +The `-f` tag will keep the logs open, and output them in realtime as they are generated. So for example, our plugin is named `nautobot-chatops`, the command would most likely be `docker logs nautobot_chatops_nautobot_1 -f`. You can find the name of all running containers via `docker ps`. @@ -382,7 +384,7 @@ Before you continue, you'll need to update the file `development/nautobot_config Once the containers are up and running, you should now see the new plugin installed in your Nautobot instance. !!! note - You can even launch an `ngrok` service locally on your laptop, pointing to port 8080 (such as for chatops development), and it will point traffic directly to your Docker images. +You can even launch an `ngrok` service locally on your laptop, pointing to port 8080 (such as for chatops development), and it will point traffic directly to your Docker images. ### Updating Python Version diff --git a/pyproject.toml b/pyproject.toml index 81bc010a..3a95c4a9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "nautobot-chatops" -version = "1.11.0" +version = "1.11.1" description = "A plugin providing chatbot capabilities for Nautobot" authors = ["Network to Code, LLC "] readme = "README.md" diff --git a/tasks.py b/tasks.py index dc2581e2..61eb91d3 100644 --- a/tasks.py +++ b/tasks.py @@ -76,18 +76,18 @@ def task_wrapper(function=None): def docker_compose(context, command, **kwargs): - """Helper function for running a specific docker-compose command with all appropriate parameters and environment. + """Helper function for running a specific docker compose command with all appropriate parameters and environment. Args: context (obj): Used to run specific commands - command (str): Command string to append to the "docker-compose ..." command, such as "build", "up", etc. + command (str): Command string to append to the "docker compose ..." command, such as "build", "up", etc. **kwargs: Passed through to the context.run() call. """ build_env = { "NAUTOBOT_VER": context.nautobot_chatops.nautobot_ver, "PYTHON_VER": context.nautobot_chatops.python_ver, } - compose_command = f'docker-compose --project-name {context.nautobot_chatops.project_name} --project-directory "{context.nautobot_chatops.compose_dir}"' + compose_command = f'docker compose --project-name {context.nautobot_chatops.project_name} --project-directory "{context.nautobot_chatops.compose_dir}"' for compose_file in context.nautobot_chatops.compose_files: compose_file_path = os.path.join(context.nautobot_chatops.compose_dir, compose_file) compose_command += f' -f "{compose_file_path}"' @@ -98,7 +98,7 @@ def docker_compose(context, command, **kwargs): if service is not None: compose_command += f" {service}" - print(f'Running docker-compose command "{command}"') + print(f'Running docker compose command "{command}"') return context.run(compose_command, env=build_env, **kwargs) From 4ff2c9c4a0214913c8c89caf3303ce9e6873314c Mon Sep 17 00:00:00 2001 From: Josh VanDeraa Date: Mon, 5 Jun 2023 16:07:01 -0500 Subject: [PATCH 2/2] Fix mkdocs issues. --- docs/dev/dev_environment.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/dev/dev_environment.md b/docs/dev/dev_environment.md index dd8cc370..1d61eb4c 100644 --- a/docs/dev/dev_environment.md +++ b/docs/dev/dev_environment.md @@ -25,10 +25,10 @@ Using **Invoke** these configuration options can be overridden using [several me ### Docker Development Environment !!! tip -As of 1.11.1 the Docker Compose environment has moved from the standalone docker-compose to the plugin execution of `docker compose`. Be sure that your version of Docker has the plugin installed. If the docker compose plugin is installed, no other changes to the invoke methodology is required. + As of 1.11.1 the Docker Compose environment has moved from the standalone docker-compose to the plugin execution of `docker compose`. Be sure that your version of Docker has the plugin installed. If the docker compose plugin is installed, no other changes to the invoke methodology is required. !!! tip -This is the recommended option for development. + This is the recommended option for development. This project is managed by [Python Poetry](https://python-poetry.org/) and has a few requirements to setup your development environment: @@ -76,7 +76,7 @@ nautobot-server migrate ``` !!! note -If you want to develop on the latest develop branch of Nautobot, run the following command: `poetry add --optional git+https://github.com/nautobot/nautobot@develop`. After the `@` symbol must match either a branch or a tag. + If you want to develop on the latest develop branch of Nautobot, run the following command: `poetry add --optional git+https://github.com/nautobot/nautobot@develop`. After the `@` symbol must match either a branch or a tag. You can now run `nautobot-server` commands as you would from the [Nautobot documentation](https://nautobot.readthedocs.io/en/latest/) for example to start the development server: @@ -105,7 +105,7 @@ The project features a CLI helper based on [Invoke](https://www.pyinvoke.org/) t Each command can be executed with `invoke `. All commands support the arguments `--nautobot-ver` and `--python-ver` if you want to manually define the version of Python and Nautobot to use. Each command also has its own help `invoke --help` !!! note -To run the mysql (mariadb) development environment, set the environment variable as such `export NAUTOBOT_USE_MYSQL=1`. + To run the mysql (mariadb) development environment, set the environment variable as such `export NAUTOBOT_USE_MYSQL=1`. #### Local Development Environment @@ -146,7 +146,7 @@ This project provides the ability to develop and manage the Nautobot server loca The upside to having the Nautobot service handled by Docker rather than locally is that you do not have to manage the Nautobot server. The [Docker logs](#docker-logs) provide the majority of the information you will need to help troubleshoot, while getting started quickly and not requiring you to perform several manual steps and remembering to have the Nautobot server running in a separate terminal while you develop. !!! note -The local environment still uses Docker containers for the supporting services (Postgres, Redis, and RQ Worker), but the Nautobot server is handled locally by you, the developer. + The local environment still uses Docker containers for the supporting services (Postgres, Redis, and RQ Worker), but the Nautobot server is handled locally by you, the developer. Follow the directions below for the specific development environment that you choose. @@ -231,7 +231,7 @@ Once the containers are fully up, you should be able to open up a web browser, a - A live version of the documentation at [http://localhost:8001](http://localhost:8001) !!! note -Sometimes the containers take a minute to fully spin up. If the page doesn't load right away, wait a minute and try again. + Sometimes the containers take a minute to fully spin up. If the page doesn't load right away, wait a minute and try again. ### Invoke - Creating a Superuser @@ -242,7 +242,7 @@ The Nautobot development image will automatically provision a super user when sp - `NAUTOBOT_SUPERUSER_PASSWORD=admin` !!! note -The default username is **admin**, but can be overridden by specifying **NAUTOBOT_SUPERUSER_USERNAME**. + The default username is **admin**, but can be overridden by specifying **NAUTOBOT_SUPERUSER_USERNAME**. If you need to create additional superusers, run the follow commands. @@ -292,7 +292,7 @@ Removing network nautobot_chatops_default This will safely shut down all of your running Docker containers for this project. When you are ready to spin containers back up, it is as simple as running `invoke start` again [as seen previously](#invoke-starting-the-development-environment). !!! warning -If you're wanting to reset the database and configuration settings, you can use the `invoke destroy` command, but **you will lose any data stored in those containers**, so make sure that is what you want to do. + If you're wanting to reset the database and configuration settings, you can use the `invoke destroy` command, but **you will lose any data stored in those containers**, so make sure that is what you want to do. ### Real-Time Updates? How Cool! @@ -303,12 +303,12 @@ Now you can start developing your plugin in the project folder! The magic here is the root directory is mounted inside your Docker containers when built and ran, so **any** changes made to the files in here are directly updated to the Nautobot plugin code running in Docker. This means that as you modify the code in your plugin folder, the changes will be instantly updated in Nautobot. !!! warning -There are a few exceptions to this, as outlined in the section [To Rebuild or Not To Rebuild](#to-rebuild-or-not-to-rebuild). + There are a few exceptions to this, as outlined in the section [To Rebuild or Not To Rebuild](#to-rebuild-or-not-to-rebuild). The back-end Django process is setup to automatically reload itself (it only takes a couple of seconds) every time a file is updated (saved). So for example, if you were to update one of the files like `tables.py`, then save it, the changes will be visible right away in the web browser! !!! note -You may get connection refused while Django reloads, but it should be refreshed fairly quickly. + You may get connection refused while Django reloads, but it should be refreshed fairly quickly. ### Docker Logs @@ -319,7 +319,7 @@ When trying to debug an issue, one helpful thing you can look at are the logs wi ``` !!! note -The `-f` tag will keep the logs open, and output them in realtime as they are generated. + The `-f` tag will keep the logs open, and output them in realtime as they are generated. So for example, our plugin is named `nautobot-chatops`, the command would most likely be `docker logs nautobot_chatops_nautobot_1 -f`. You can find the name of all running containers via `docker ps`. @@ -384,7 +384,7 @@ Before you continue, you'll need to update the file `development/nautobot_config Once the containers are up and running, you should now see the new plugin installed in your Nautobot instance. !!! note -You can even launch an `ngrok` service locally on your laptop, pointing to port 8080 (such as for chatops development), and it will point traffic directly to your Docker images. + You can even launch an `ngrok` service locally on your laptop, pointing to port 8080 (such as for chatops development), and it will point traffic directly to your Docker images. ### Updating Python Version