From 64162c69f7d5f7ba6eb8554d7abde4da37067ae2 Mon Sep 17 00:00:00 2001 From: Josh VanDeraa Date: Mon, 31 Jul 2023 21:59:12 -0500 Subject: [PATCH 1/4] Updates Developer Env for Docker Compose --- development/docker-compose.base.yml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/development/docker-compose.base.yml b/development/docker-compose.base.yml index c875afa4..7ad26732 100644 --- a/development/docker-compose.base.yml +++ b/development/docker-compose.base.yml @@ -26,14 +26,12 @@ services: timeout: "10s" start_period: "120s" retries: 3 - <<: - - *nautobot-build - - *nautobot-base + <<: [*nautobot-build, *nautobot-base] worker: entrypoint: - "sh" - - "-c" # this is to evaluate the $NAUTOBOT_LOG_LEVEL from the env - - "nautobot-server celery worker -l $$NAUTOBOT_LOG_LEVEL --events" ## $$ because of docker-compose + - "-c" # this is to evaluate the $NAUTOBOT_LOG_LEVEL from the env + - "nautobot-server celery worker -l $$NAUTOBOT_LOG_LEVEL --events" ## $$ because of docker-compose depends_on: - "nautobot" healthcheck: @@ -41,5 +39,10 @@ services: timeout: "10s" start_period: "30s" retries: 3 - test: ["CMD", "bash", "-c", "nautobot-server celery inspect ping --destination celery@$$HOSTNAME"] ## $$ because of docker-compose + test: [ + "CMD", + "bash", + "-c", + "nautobot-server celery inspect ping --destination celery@$$HOSTNAME", + ] ## $$ because of docker-compose <<: *nautobot-base From a3d1961f2216ca49a4436fb217458c318ac607d3 Mon Sep 17 00:00:00 2001 From: Josh VanDeraa Date: Mon, 31 Jul 2023 21:59:57 -0500 Subject: [PATCH 2/4] Converts Docker Compose to plugin --- tasks.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tasks.py b/tasks.py index 9e8cb71f..c1f7a98d 100644 --- a/tasks.py +++ b/tasks.py @@ -77,26 +77,26 @@ 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 = { - # Note: 'docker-compose logs' will stop following after 60 seconds by default, + # Note: 'docker compose logs' will stop following after 60 seconds by default, # so we are overriding that by setting this environment variable. "COMPOSE_HTTP_TIMEOUT": context.design_builder.compose_http_timeout, "NAUTOBOT_VER": context.design_builder.nautobot_ver, "PYTHON_VER": context.design_builder.python_ver, } - compose_command = f'docker-compose --project-name {context.design_builder.project_name} --project-directory "{context.design_builder.compose_dir}"' + compose_command = f'docker compose --project-name {context.design_builder.project_name} --project-directory "{context.design_builder.compose_dir}"' for compose_file in context.design_builder.compose_files: compose_file_path = os.path.join(context.design_builder.compose_dir, compose_file) compose_command += f' -f "{compose_file_path}"' compose_command += f" {command}" - print(f'Running docker-compose command "{command}"') + print(f'Running docker compose command "{command}"') return context.run(compose_command, env=build_env, **kwargs) @@ -193,13 +193,13 @@ def vscode(context): @task( help={ - "service": "Docker-compose service name to view (default: nautobot)", + "service": "docker compose service name to view (default: nautobot)", "follow": "Follow logs", "tail": "Tail N number of lines or 'all'", } ) def logs(context, service="nautobot", follow=False, tail=None): - """View the logs of a docker-compose service.""" + """View the logs of a docker compose service.""" command = "logs " if follow: From 59c7d40fa38f4455bc491eaf5bafe9a28be02d02 Mon Sep 17 00:00:00 2001 From: Josh VanDeraa Date: Tue, 1 Aug 2023 07:06:44 -0500 Subject: [PATCH 3/4] Updates formatting --- development/docker-compose.base.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/development/docker-compose.base.yml b/development/docker-compose.base.yml index 7ad26732..973f8276 100644 --- a/development/docker-compose.base.yml +++ b/development/docker-compose.base.yml @@ -30,8 +30,8 @@ services: worker: entrypoint: - "sh" - - "-c" # this is to evaluate the $NAUTOBOT_LOG_LEVEL from the env - - "nautobot-server celery worker -l $$NAUTOBOT_LOG_LEVEL --events" ## $$ because of docker-compose + - "-c" # this is to evaluate the $NAUTOBOT_LOG_LEVEL from the env + - "nautobot-server celery worker -l $$NAUTOBOT_LOG_LEVEL --events" ## $$ because of docker-compose depends_on: - "nautobot" healthcheck: @@ -40,9 +40,9 @@ services: start_period: "30s" retries: 3 test: [ - "CMD", - "bash", - "-c", - "nautobot-server celery inspect ping --destination celery@$$HOSTNAME", - ] ## $$ because of docker-compose + "CMD", + "bash", + "-c", + "nautobot-server celery inspect ping --destination celery@$$HOSTNAME", + ] ## $$ because of docker-compose <<: *nautobot-base From fb57c4ea1b81bf3373db20d769387b6247eec9e8 Mon Sep 17 00:00:00 2001 From: Josh VanDeraa Date: Tue, 1 Aug 2023 07:09:09 -0500 Subject: [PATCH 4/4] Updates to pass CI --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 99e27170..cc2ebe12 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -149,6 +149,7 @@ jobs: tag: "${{ github.ref }}" overwrite: true file_glob: true +# yamllint disable-line rule:comments-indentation # publish_pypi: # needs: # - "unittest"