From 27811fbca0c524901005fdf33e7bcf3ef9e03939 Mon Sep 17 00:00:00 2001 From: Nick Phura Date: Tue, 13 Aug 2024 16:13:44 -0700 Subject: [PATCH] TechDebt: Update Docker Compose Command (#1339) --- Makefile | 44 ++++++++++++++-------------- README.md | 2 +- api/.docker/api/Dockerfile | 2 +- app/.docker/app/Dockerfile | 2 +- app/server/index.js | 2 +- app/src/contexts/configContext.tsx | 2 +- docker-compose.yml => compose.yml | 2 -- database/.docker/db/Dockerfile | 2 +- database/.docker/db/Dockerfile.setup | 2 +- env_config/env.docker | 4 +-- 10 files changed, 31 insertions(+), 33 deletions(-) rename docker-compose.yml => compose.yml (99%) diff --git a/Makefile b/Makefile index 31f78ed505..8c18d71028 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ -include .env -# Apply the contents of the .env to the terminal, so that the docker-compose file can use them in its builds +# Apply the contents of the .env to the terminal, so that the compose file can use them in its builds export $(shell sed 's/=.*//' .env) ## ------------------------------------------------------------------------------ @@ -46,13 +46,13 @@ close: ## Closes all project containers @echo "===============================================" @echo "Make: close - closing Docker containers" @echo "===============================================" - @docker-compose -f docker-compose.yml down + @docker compose down clean: ## Closes and cleans (removes) all project containers @echo "===============================================" @echo "Make: clean - closing and cleaning Docker containers" @echo "===============================================" - @docker-compose -f docker-compose.yml down -v --rmi all --remove-orphans + @docker compose down -v --rmi all --remove-orphans prune: ## Deletes ALL docker artifacts (even those not associated to this project) @echo -n "Delete ALL docker artifacts? [y/n] " && read ans && [ $${ans:-n} = y ] @@ -77,13 +77,13 @@ build-postgres: ## Builds the postgres db containers @echo "===============================================" @echo "Make: build-postgres - building postgres db images" @echo "===============================================" - @docker-compose -f docker-compose.yml build db db_setup + @docker compose build db db_setup run-postgres: ## Runs the postgres db containers @echo "===============================================" @echo "Make: run-postgres - running postgres db images" @echo "===============================================" - @docker-compose -f docker-compose.yml up -d db db_setup + @docker compose up -d db db_setup ## ------------------------------------------------------------------------------ ## Build/Run Backend Commands @@ -94,13 +94,13 @@ build-backend: ## Builds all backend containers @echo "===============================================" @echo "Make: build-backend - building backend images" @echo "===============================================" - @docker-compose -f docker-compose.yml build db db_setup api + @docker compose build db db_setup api run-backend: ## Runs all backend containers @echo "===============================================" @echo "Make: run-backend - running backend images" @echo "===============================================" - @docker-compose -f docker-compose.yml up -d db db_setup api + @docker compose up -d db db_setup api ## ------------------------------------------------------------------------------ ## Build/Run Backend+Web Commands (backend + web frontend) @@ -111,13 +111,13 @@ build-web: ## Builds all backend+web containers @echo "===============================================" @echo "Make: build-web - building web images" @echo "===============================================" - @docker-compose -f docker-compose.yml build db db_setup api app + @docker compose build db db_setup api app run-web: ## Runs all backend+web containers @echo "===============================================" @echo "Make: run-web - running web images" @echo "===============================================" - @docker-compose -f docker-compose.yml up -d db db_setup api app + @docker compose up -d db db_setup api app ## ------------------------------------------------------------------------------ ## Commands to shell into the target container @@ -128,19 +128,19 @@ db-container: ## Executes into database container. @echo "Make: Shelling into database container" @echo "===============================================" @export PGPASSWORD=$(DB_ADMIN_PASS) - @docker-compose exec db psql -U $(DB_ADMIN) -d $(DB_DATABASE) + @docker compose exec db psql -U $(DB_ADMIN) -d $(DB_DATABASE) app-container: ## Executes into the app container. @echo "===============================================" @echo "Shelling into app container" @echo "===============================================" - @docker-compose exec app bash + @docker compose exec app bash api-container: ## Executes into the api container. @echo "===============================================" @echo "Shelling into api container" @echo "===============================================" - @docker-compose exec api bash + @docker compose exec api bash ## ------------------------------------------------------------------------------ ## Database migration commands @@ -150,37 +150,37 @@ build-db-setup: ## Build the db knex setup (migrations + seeding) image @echo "===============================================" @echo "Make: build-db-setup - building db knex setup image" @echo "===============================================" - @docker-compose -f docker-compose.yml build db_setup + @docker compose build db_setup run-db-setup: ## Run the database migrations and seeding @echo "===============================================" @echo "Make: run-db-setup - running database migrations and seeding" @echo "===============================================" - @docker-compose -f docker-compose.yml up db_setup + @docker compose up db_setup build-db-migrate: ## Build the db knex migrations image @echo "===============================================" @echo "Make: build-db-migrate - building db knex migrate image" @echo "===============================================" - @docker-compose -f docker-compose.yml build db_migrate + @docker compose build db_migrate run-db-migrate: ## Run the database migrations @echo "===============================================" @echo "Make: run-db-migrate - running database migrations" @echo "===============================================" - @docker-compose -f docker-compose.yml up db_migrate + @docker compose up db_migrate build-db-rollback: ## Build the db knex rollback image @echo "===============================================" @echo "Make: build-db-rollback - building db knex rollback image" @echo "===============================================" - @docker-compose -f docker-compose.yml build db_rollback + @docker compose build db_rollback run-db-rollback: ## Rollback the latest database migrations @echo "===============================================" @echo "Make: run-db-rollback - rolling back the latest database migrations" @echo "===============================================" - @docker-compose -f docker-compose.yml up db_rollback + @docker compose up db_rollback ## ------------------------------------------------------------------------------ ## clamav commands @@ -190,13 +190,13 @@ build-clamav: ## Build the clamav image @echo "===============================================" @echo "Make: build-clamav - building clamav image" @echo "===============================================" - @docker-compose -f docker-compose.yml build clamav + @docker compose build clamav run-clamav: ## Run clamav @echo "===============================================" @echo "Make: run-clamav - running clamav" @echo "===============================================" - @docker-compose -f docker-compose.yml up -d clamav + @docker compose up -d clamav ## ------------------------------------------------------------------------------ ## Run `npm` commands for all projects @@ -314,11 +314,11 @@ pipeline-install: ## Runs `npm install` for all projects args ?= --tail 2000 ## Default args if none are provided -log: ## Runs `docker-compose logs -f` for all containers +log: ## Runs `docker compose logs -f` for all containers @echo "===============================================" @echo "Running docker logs for the app container" @echo "===============================================" - @docker-compose logs -f $(args) + @docker compose logs -f $(args) log-app: ## Runs `docker logs -f` for the app container @echo "===============================================" diff --git a/README.md b/README.md index 020a947546..b23d85a04e 100644 --- a/README.md +++ b/README.md @@ -125,7 +125,7 @@ Below are all of the relevant files that need to be updated when modifying envir #### Local Development - `env.docker` -- `docker-compose.yml` +- `compose.yml` - `app/src/contexts/configContext.tsx` #### Deployed to OpenShift diff --git a/api/.docker/api/Dockerfile b/api/.docker/api/Dockerfile index 1501d7cfdc..2c658d84b8 100644 --- a/api/.docker/api/Dockerfile +++ b/api/.docker/api/Dockerfile @@ -1,5 +1,5 @@ # ######################################################################################################## -# This DockerFile is used for local development (via docker-compose) only. +# This DockerFile is used for local development (via compose.yml) only. # ######################################################################################################## FROM node:20 diff --git a/app/.docker/app/Dockerfile b/app/.docker/app/Dockerfile index e77e9cf6f9..2b4f6e4c55 100644 --- a/app/.docker/app/Dockerfile +++ b/app/.docker/app/Dockerfile @@ -1,5 +1,5 @@ # ######################################################################################################## -# This DockerFile is used for local development (via docker-compose) only. +# This DockerFile is used for local development (via compose.yml) only. # ######################################################################################################## FROM node:20 diff --git a/app/server/index.js b/app/server/index.js index 020eeb4532..bb903d2809 100644 --- a/app/server/index.js +++ b/app/server/index.js @@ -28,7 +28,7 @@ const request = require('request'); * This includes a health check endpoint that OpenShift uses to determine if the app is healthy. * * This file is only used when serving the app in OpenShift. - * When running the app locally, the app is served by docker-compose, and doesn't use this file at all. + * When running the app locally, the app is served by compose.yml, and doesn't use this file at all. * * Note: All changes to env vars here must also be reflected in the `app/src/contexts/configContext.tsx` file, so that * the app has access to the same env vars when running in both OpenShift and local development. diff --git a/app/src/contexts/configContext.tsx b/app/src/contexts/configContext.tsx index 842423d28e..a6c5469492 100644 --- a/app/src/contexts/configContext.tsx +++ b/app/src/contexts/configContext.tsx @@ -51,7 +51,7 @@ const parseFeatureFlagsString = (featureFlagsString: string): string[] => { * This is used when running the app locally in docker. * * Note: All changes to env vars here must also be reflected in the `app/server/index.js` file, so that the app has - * access to the same env vars when running in both local development (via docker-compose) and in OpenShift. + * access to the same env vars when running in both local development (via compose.yml) and in OpenShift. * * @return {*} {IConfig} */ diff --git a/docker-compose.yml b/compose.yml similarity index 99% rename from docker-compose.yml rename to compose.yml index 0bd03d55cd..9f6c8670cf 100644 --- a/docker-compose.yml +++ b/compose.yml @@ -1,5 +1,3 @@ -version: "3.5" - services: ## Build postgres docker image db: diff --git a/database/.docker/db/Dockerfile b/database/.docker/db/Dockerfile index b0808f9bfa..effd413ed7 100644 --- a/database/.docker/db/Dockerfile +++ b/database/.docker/db/Dockerfile @@ -1,5 +1,5 @@ # ######################################################################################################## -# This DockerFile is used for local development (via docker-compose) only. +# This DockerFile is used for local development (via compose.yml) only. # ######################################################################################################## ARG POSTGRES_VERSION=12.5 diff --git a/database/.docker/db/Dockerfile.setup b/database/.docker/db/Dockerfile.setup index 6bb7575574..40c77c4659 100644 --- a/database/.docker/db/Dockerfile.setup +++ b/database/.docker/db/Dockerfile.setup @@ -1,5 +1,5 @@ # ######################################################################################################## -# This DockerFile is used for both Openshift deployments and local development (via docker-compose). +# This DockerFile is used for both Openshift deployments and local development (via compose.yml). # ######################################################################################################## FROM node:20 diff --git a/env_config/env.docker b/env_config/env.docker index face12d12c..2209fcefc9 100644 --- a/env_config/env.docker +++ b/env_config/env.docker @@ -5,11 +5,11 @@ # # These env vars are automatically read by the makefile (when running make commands). # -# Newly added environment variables need to be added to the docker-compose file, +# Newly added environment variables need to be added to the compose.yml file, # under whichever service needs them (api, app, etc) # # Exposed Ports/URLs -# - Certain ports/urls are exposed in docker-compose and may conflict with other +# - Certain ports/urls are exposed in compose.yml and may conflict with other # docker-containers if they are exposing the same ports/urls. # # - If conflicts arise, modify the conflicting values in your `.env` and re-build.