From 1906e2f37edf224b08a4f4c675b09492036e0f90 Mon Sep 17 00:00:00 2001 From: Rafael Romero <rafael@parabol.co> Date: Wed, 21 Feb 2024 12:43:11 +0000 Subject: [PATCH 1/5] Docker compose stack improved --- docker/parabol-ubi/docker-host-st/README.md | 7 + .../docker-host-st/docker-compose.yaml | 162 +++++++++++++++--- .../{ => postgres}/postgres.conf | 0 3 files changed, 147 insertions(+), 22 deletions(-) rename docker/parabol-ubi/docker-host-st/{ => postgres}/postgres.conf (100%) diff --git a/docker/parabol-ubi/docker-host-st/README.md b/docker/parabol-ubi/docker-host-st/README.md index c743187aa1d..9b37ae291ee 100644 --- a/docker/parabol-ubi/docker-host-st/README.md +++ b/docker/parabol-ubi/docker-host-st/README.md @@ -13,3 +13,10 @@ To run the Parabol UBI in single tenant mode (e.g. simple docker-compose on a do 💧💧💧 Server ID: 0. Ready for GraphQL Execution 💧💧💧 💧💧💧 Server ID: 01. Ready for GraphQL Execution 💧💧💧 ``` + +## Upgrade Parabol version + +1. Edit the `docker-compose.yaml` and change the `#image:tag` changing the tag. Ex: from `v7.15.0` to `v7.15.2`. +2. (optional) Run `docker compose logs -f` to follow the upgrade. +3. Run `docker compose up -d`. It will start the `pre-deploy` and, once it is done successfully, then it will stop and recreate the `web-server` and `gql-executor` with the new version of the image. **This step implies a downtime**. +4. Verify the application is still up and running. diff --git a/docker/parabol-ubi/docker-host-st/docker-compose.yaml b/docker/parabol-ubi/docker-host-st/docker-compose.yaml index c7ff752a95b..c1b2314498e 100644 --- a/docker/parabol-ubi/docker-host-st/docker-compose.yaml +++ b/docker/parabol-ubi/docker-host-st/docker-compose.yaml @@ -1,51 +1,169 @@ -version: '3.7' +version: '3.9' services: - db: - image: rethinkdb:latest + postgres: + container_name: postgres + image: postgres:15.4 restart: always + env_file: .env + environment: + - PGUSER=$POSTGRES_USER ports: - - '8080:8080' - - '29015:29015' - - '28015:28015' + - '5432:5432' volumes: - - ./rethink-data:/data + #- './postgres/postgres.conf:/usr/local/etc/postgres/postgres.conf' + - './data/postgres/pgdata:/var/lib/postgresql/data' + #command: 'postgres -c config_file=/usr/local/etc/postgres/postgres.conf' + healthcheck: + test: ["CMD-SHELL", "pg_isready", "-d", "$POSTGRES_DB", "-U", "$POSTGRES_USER"] + interval: 10s + timeout: 5s + retries: 5 networks: - parabol-network - postgres: - image: postgres:15.4 - restart: always + pgadmin: + container_name: pgadmin + image: dpage/pgadmin4:8.3 + depends_on: + postgres: + condition: service_healthy env_file: .env ports: - - '5432:5432' + - "5050:80" + networks: + - parabol-network + rethinkdb: + container_name: rethinkdb + image: rethinkdb:2.4.2 + restart: always + ports: + - '8080:8080' + - '29015:29015' + - '28015:28015' volumes: - - './postgres.conf:/usr/local/etc/postgres/postgres.conf' - - './postgres-data/pgdata:/var/lib/postgresql/data' - command: 'postgres -c config_file=/usr/local/etc/postgres/postgres.conf' + - ./data/rethink:/data networks: - parabol-network redis: - image: redis + container_name: redis + image: redis:7.0-alpine + healthcheck: + test: "[ $$(redis-cli ping) = 'PONG' ]" + interval: 10s + timeout: 5s + retries: 5 restart: always ports: - '6379:6379' volumes: - - ./redis-data:/data + - ./data/redis:/data + networks: + - parabol-network + # test-task: + # image: busybox + # command: sh -c "sleep 30" + # depends_on: + # rethinkdb: + # condition: service_started + # postgres: + # condition: service_started + # redis: + # condition: service_healthy + # networks: + # - parabol-network + # test-process: + # image: nginx + # depends_on: + # test-task: + # condition: service_completed_successfully + # rethinkdb: + # condition: service_started + # postgres: + # condition: service_started + # redis: + # condition: service_healthy + # networks: + # - parabol-network + pre-deploy: + container_name: pre-deploy + image: us-central1-docker.pkg.dev/prbl-tooling/parabol-production/parabol:v7.15.2 + command: bash -c "node dist/preDeploy.js" + env_file: .env + environment: + - SERVER_ID=0 + volumes: + - './.env:/parabol/.env' + depends_on: + rethinkdb: + condition: service_started + postgres: + condition: service_healthy + redis: + condition: service_healthy networks: - parabol-network - app: - image: #image:tag + # chronos: + # image: us-central1-docker.pkg.dev/prbl-tooling/parabol-production/parabol:v7.15.2 + # restart: always + # command: bash -c "node dist/chronos.js" + # env_file: .env + # environment: + # - SERVER_ID=1 + # volumes: + # - './.env:/parabol/.env' + # depends_on: + # pre-deploy: + # condition: service_completed_successfully + # rethinkdb: + # condition: service_started + # postgres: + # condition: service_healthy + # redis: + # condition: service_healthy + # networks: + # - parabol-network + web-server: + container_name: web-server + image: us-central1-docker.pkg.dev/prbl-tooling/parabol-production/parabol:v7.15.2 restart: always + command: bash -c "node dist/web.js" env_file: .env - command: bash -c "yarn predeploy && NODE_ENV=production && yarn start" + environment: + - SERVER_ID=5 ports: - '3000:3000' volumes: - './.env:/parabol/.env' depends_on: - - db - - redis - - postgres + pre-deploy: + condition: service_completed_successfully + rethinkdb: + condition: service_started + postgres: + condition: service_healthy + redis: + condition: service_healthy + networks: + - parabol-network + gql-executor: + container_name: gql-executor + image: us-central1-docker.pkg.dev/prbl-tooling/parabol-production/parabol:v7.15.2 + restart: always + command: bash -c "node dist/gqlExecutor.js" + env_file: .env + environment: + - SERVER_ID=10 + volumes: + - './.env:/parabol/.env' + depends_on: + pre-deploy: + condition: service_completed_successfully + rethinkdb: + condition: service_started + postgres: + condition: service_healthy + redis: + condition: service_healthy networks: - parabol-network networks: diff --git a/docker/parabol-ubi/docker-host-st/postgres.conf b/docker/parabol-ubi/docker-host-st/postgres/postgres.conf similarity index 100% rename from docker/parabol-ubi/docker-host-st/postgres.conf rename to docker/parabol-ubi/docker-host-st/postgres/postgres.conf From 8a4f5192c046b225c9ef2229846692a32cbd2f68 Mon Sep 17 00:00:00 2001 From: Rafael Romero <rafael@parabol.co> Date: Wed, 21 Feb 2024 17:33:36 +0000 Subject: [PATCH 2/5] Remove unused containers from docker-compse and add useful comment on .env.example about PGSSLMODE --- .../parabol-ubi/docker-host-st/.env.example | 1 + .../docker-host-st/docker-compose.yaml | 25 ------------------- 2 files changed, 1 insertion(+), 25 deletions(-) diff --git a/docker/parabol-ubi/docker-host-st/.env.example b/docker/parabol-ubi/docker-host-st/.env.example index 82c7b2b7e29..9eadf7108e5 100644 --- a/docker/parabol-ubi/docker-host-st/.env.example +++ b/docker/parabol-ubi/docker-host-st/.env.example @@ -1 +1,2 @@ # See https://github.com/ParabolInc/parabol/blob/master/.env.example +# DO NOT SET PGSSLMODE to an empty value. Postgres will not be able to start. diff --git a/docker/parabol-ubi/docker-host-st/docker-compose.yaml b/docker/parabol-ubi/docker-host-st/docker-compose.yaml index c1b2314498e..c4dbd17b13c 100644 --- a/docker/parabol-ubi/docker-host-st/docker-compose.yaml +++ b/docker/parabol-ubi/docker-host-st/docker-compose.yaml @@ -59,31 +59,6 @@ services: - ./data/redis:/data networks: - parabol-network - # test-task: - # image: busybox - # command: sh -c "sleep 30" - # depends_on: - # rethinkdb: - # condition: service_started - # postgres: - # condition: service_started - # redis: - # condition: service_healthy - # networks: - # - parabol-network - # test-process: - # image: nginx - # depends_on: - # test-task: - # condition: service_completed_successfully - # rethinkdb: - # condition: service_started - # postgres: - # condition: service_started - # redis: - # condition: service_healthy - # networks: - # - parabol-network pre-deploy: container_name: pre-deploy image: us-central1-docker.pkg.dev/prbl-tooling/parabol-production/parabol:v7.15.2 From 7aeb4735a6bf48df55b4a1964c974849be8696dd Mon Sep 17 00:00:00 2001 From: Rafael Romero <rafael@parabol.co> Date: Thu, 22 Feb 2024 09:54:13 +0000 Subject: [PATCH 3/5] Docker compose profiles added. Documentation extended on how to use the profiles to manage the stack. --- docker/parabol-ubi/docker-host-st/README.md | 30 +++++++-- .../docker-host-st/docker-compose.yaml | 65 ++++++++++++------- .../docker-host-st/postgres/postgres.conf | 1 - 3 files changed, 68 insertions(+), 28 deletions(-) delete mode 100644 docker/parabol-ubi/docker-host-st/postgres/postgres.conf diff --git a/docker/parabol-ubi/docker-host-st/README.md b/docker/parabol-ubi/docker-host-st/README.md index 9b37ae291ee..532c70a358a 100644 --- a/docker/parabol-ubi/docker-host-st/README.md +++ b/docker/parabol-ubi/docker-host-st/README.md @@ -1,12 +1,12 @@ # Docker Host Single Tenant (ST) -To run the Parabol UBI in single tenant mode (e.g. simple docker-compose on a docker host). +To run Parabol in single tenant mode (e.g. simple docker-compose on a docker host). 1. Build your Parabol UBI using instructions in `docker/ubi/docker-build/README.md` 2. Create a working `.env` from `.env.example` 3. Update docker-compose.yaml `image: #image:tag` with your built image tag from `step (1.)` -4. Run `docker-compose up -d` to deploy the local stack. You can run `docker-compose down` to terminate the local stack -5. Check logs via command `docker logs <name>-app-1` and wait for the following output to appear +4. Run `docker-compose up --profile databases --profile parabol -d` to deploy the local stack. You can run `docker-compose down --profile databases --profile parabol` to terminate the local stack +5. Check logs via command `docker logs <name> -f` and wait for the following output to appear ```shell 🔥🔥🔥 Server ID: 0. Ready for Sockets: Port 3000 🔥🔥🔥 @@ -17,6 +17,26 @@ To run the Parabol UBI in single tenant mode (e.g. simple docker-compose on a do ## Upgrade Parabol version 1. Edit the `docker-compose.yaml` and change the `#image:tag` changing the tag. Ex: from `v7.15.0` to `v7.15.2`. -2. (optional) Run `docker compose logs -f` to follow the upgrade. -3. Run `docker compose up -d`. It will start the `pre-deploy` and, once it is done successfully, then it will stop and recreate the `web-server` and `gql-executor` with the new version of the image. **This step implies a downtime**. +2. (optional) In a different terminal, run `docker compose logs -f` to follow the upgrade. +3. Run `docker compose up --profile databases --profile parabol -d`. It will start the `pre-deploy` and, once it is done successfully, then it will stop and recreate the `web-server` and `gql-executor` with the new version of the image. **This step implies a downtime**. 4. Verify the application is still up and running. + +## Running Chronos + +Chronos isn't started by default. If it needs to run, it must be managed using `docker compose up --profile databases --profile parabol --profile chronos`. + +This will run `pre-deploy` and thus it will recreate the `web-server` and the `gql-executor`. + +## Database debug + +Some tools are available to debug the databases is needed: + +- pgadmin +- redis-commander + +To operate them use `docker compose up --profile databases --profile database-debug`. + +## Running the whole stack + +- Start the whole stack: `docker compose up --profile databases --profile parabol --profile database-debug --profile chronos -d`. +- Stop the stack: `docker compose down --profile databases --profile parabol --profile database-debug --profile chronos` diff --git a/docker/parabol-ubi/docker-host-st/docker-compose.yaml b/docker/parabol-ubi/docker-host-st/docker-compose.yaml index c4dbd17b13c..52bb8c76a7d 100644 --- a/docker/parabol-ubi/docker-host-st/docker-compose.yaml +++ b/docker/parabol-ubi/docker-host-st/docker-compose.yaml @@ -3,6 +3,7 @@ version: '3.9' services: postgres: container_name: postgres + profiles: ["databases"] image: postgres:15.4 restart: always env_file: .env @@ -11,9 +12,7 @@ services: ports: - '5432:5432' volumes: - #- './postgres/postgres.conf:/usr/local/etc/postgres/postgres.conf' - './data/postgres/pgdata:/var/lib/postgresql/data' - #command: 'postgres -c config_file=/usr/local/etc/postgres/postgres.conf' healthcheck: test: ["CMD-SHELL", "pg_isready", "-d", "$POSTGRES_DB", "-U", "$POSTGRES_USER"] interval: 10s @@ -22,6 +21,7 @@ services: networks: - parabol-network pgadmin: + profiles: ["database-debug"] container_name: pgadmin image: dpage/pgadmin4:8.3 depends_on: @@ -34,6 +34,7 @@ services: - parabol-network rethinkdb: container_name: rethinkdb + profiles: ["databases"] image: rethinkdb:2.4.2 restart: always ports: @@ -46,6 +47,7 @@ services: - parabol-network redis: container_name: redis + profiles: ["databases"] image: redis:7.0-alpine healthcheck: test: "[ $$(redis-cli ping) = 'PONG' ]" @@ -59,8 +61,23 @@ services: - ./data/redis:/data networks: - parabol-network + redis-commander: + profiles: ["database-debug"] + container_name: redis-commander + image: ghcr.io/joeferner/redis-commander:0.8.1 + depends_on: + redis: + condition: service_healthy + restart: always + environment: + - REDIS_HOSTS=local:redis:6379 + ports: + - "8081:8081" + networks: + - parabol-network pre-deploy: container_name: pre-deploy + profiles: ["parabol"] image: us-central1-docker.pkg.dev/prbl-tooling/parabol-production/parabol:v7.15.2 command: bash -c "node dist/preDeploy.js" env_file: .env @@ -77,28 +94,31 @@ services: condition: service_healthy networks: - parabol-network - # chronos: - # image: us-central1-docker.pkg.dev/prbl-tooling/parabol-production/parabol:v7.15.2 - # restart: always - # command: bash -c "node dist/chronos.js" - # env_file: .env - # environment: - # - SERVER_ID=1 - # volumes: - # - './.env:/parabol/.env' - # depends_on: - # pre-deploy: - # condition: service_completed_successfully - # rethinkdb: - # condition: service_started - # postgres: - # condition: service_healthy - # redis: - # condition: service_healthy - # networks: - # - parabol-network + chronos: + container_name: chronos + profiles: ["chronos"] + image: us-central1-docker.pkg.dev/prbl-tooling/parabol-production/parabol:v7.15.2 + restart: always + command: bash -c "node dist/chronos.js" + env_file: .env + environment: + - SERVER_ID=1 + volumes: + - './.env:/parabol/.env' + depends_on: + pre-deploy: + condition: service_completed_successfully + rethinkdb: + condition: service_started + postgres: + condition: service_healthy + redis: + condition: service_healthy + networks: + - parabol-network web-server: container_name: web-server + profiles: ["parabol"] image: us-central1-docker.pkg.dev/prbl-tooling/parabol-production/parabol:v7.15.2 restart: always command: bash -c "node dist/web.js" @@ -122,6 +142,7 @@ services: - parabol-network gql-executor: container_name: gql-executor + profiles: ["parabol"] image: us-central1-docker.pkg.dev/prbl-tooling/parabol-production/parabol:v7.15.2 restart: always command: bash -c "node dist/gqlExecutor.js" diff --git a/docker/parabol-ubi/docker-host-st/postgres/postgres.conf b/docker/parabol-ubi/docker-host-st/postgres/postgres.conf deleted file mode 100644 index 3357fd28574..00000000000 --- a/docker/parabol-ubi/docker-host-st/postgres/postgres.conf +++ /dev/null @@ -1 +0,0 @@ -listen_addresses='*' \ No newline at end of file From 1f8fe068ab1cc599a159900fb47cd432673a7c0f Mon Sep 17 00:00:00 2001 From: Rafael Romero <rafael@parabol.co> Date: Thu, 22 Feb 2024 10:43:13 +0000 Subject: [PATCH 4/5] README fixed as docker compose up and down commands were not working --- docker/parabol-ubi/docker-host-st/README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docker/parabol-ubi/docker-host-st/README.md b/docker/parabol-ubi/docker-host-st/README.md index 532c70a358a..215c11ee442 100644 --- a/docker/parabol-ubi/docker-host-st/README.md +++ b/docker/parabol-ubi/docker-host-st/README.md @@ -5,7 +5,7 @@ To run Parabol in single tenant mode (e.g. simple docker-compose on a docker hos 1. Build your Parabol UBI using instructions in `docker/ubi/docker-build/README.md` 2. Create a working `.env` from `.env.example` 3. Update docker-compose.yaml `image: #image:tag` with your built image tag from `step (1.)` -4. Run `docker-compose up --profile databases --profile parabol -d` to deploy the local stack. You can run `docker-compose down --profile databases --profile parabol` to terminate the local stack +4. Run `docker-compose --profile databases --profile parabol up -d` to deploy the local stack. You can run `docker-compos --profile databases --profile parabol down` to terminate the local stack 5. Check logs via command `docker logs <name> -f` and wait for the following output to appear ```shell @@ -18,12 +18,12 @@ To run Parabol in single tenant mode (e.g. simple docker-compose on a docker hos 1. Edit the `docker-compose.yaml` and change the `#image:tag` changing the tag. Ex: from `v7.15.0` to `v7.15.2`. 2. (optional) In a different terminal, run `docker compose logs -f` to follow the upgrade. -3. Run `docker compose up --profile databases --profile parabol -d`. It will start the `pre-deploy` and, once it is done successfully, then it will stop and recreate the `web-server` and `gql-executor` with the new version of the image. **This step implies a downtime**. +3. Run `docker compose --profile databases --profile parabol up -d`. It will start the `pre-deploy` and, once it is done successfully, then it will stop and recreate the `web-server` and `gql-executor` with the new version of the image. **This step implies a downtime**. 4. Verify the application is still up and running. ## Running Chronos -Chronos isn't started by default. If it needs to run, it must be managed using `docker compose up --profile databases --profile parabol --profile chronos`. +Chronos isn't started by default. If it needs to run, it must be managed using `docker compose --profile databases --profile parabol --profile chronos up`. This will run `pre-deploy` and thus it will recreate the `web-server` and the `gql-executor`. @@ -38,5 +38,5 @@ To operate them use `docker compose up --profile databases --profile database-de ## Running the whole stack -- Start the whole stack: `docker compose up --profile databases --profile parabol --profile database-debug --profile chronos -d`. -- Stop the stack: `docker compose down --profile databases --profile parabol --profile database-debug --profile chronos` +- Start the whole stack: `docker compose --profile databases --profile parabol --profile database-debug --profile chronos up -d`. +- Stop the stack: `docker compose --profile databases --profile parabol --profile database-debug --profile chronos down` From 0fcd382cb89501c76203f3357cdf870b9dd916b2 Mon Sep 17 00:00:00 2001 From: Rafael Romero <rafael@parabol.co> Date: Thu, 22 Feb 2024 22:46:38 +0000 Subject: [PATCH 5/5] Typo fixed and docker-compose command replaced by docker compose --- docker/parabol-ubi/docker-host-st/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/parabol-ubi/docker-host-st/README.md b/docker/parabol-ubi/docker-host-st/README.md index 215c11ee442..af3a0b244ec 100644 --- a/docker/parabol-ubi/docker-host-st/README.md +++ b/docker/parabol-ubi/docker-host-st/README.md @@ -5,7 +5,7 @@ To run Parabol in single tenant mode (e.g. simple docker-compose on a docker hos 1. Build your Parabol UBI using instructions in `docker/ubi/docker-build/README.md` 2. Create a working `.env` from `.env.example` 3. Update docker-compose.yaml `image: #image:tag` with your built image tag from `step (1.)` -4. Run `docker-compose --profile databases --profile parabol up -d` to deploy the local stack. You can run `docker-compos --profile databases --profile parabol down` to terminate the local stack +4. Run `docker compose --profile databases --profile parabol up -d` to deploy the local stack. You can run `docker compose --profile databases --profile parabol down` to terminate the local stack 5. Check logs via command `docker logs <name> -f` and wait for the following output to appear ```shell