Skip to content

Commit

Permalink
feat(standalone-deployment): Standalone host deployment improved and …
Browse files Browse the repository at this point in the history
…documented (#9445)

* Docker compose stack improved

* Remove unused containers from docker-compse and add useful comment on .env.example about PGSSLMODE

* Docker compose profiles added. Documentation extended on how to use the profiles to manage the stack.

* README fixed as docker compose up and down commands were not working

* Typo fixed and docker-compose command replaced by docker compose
  • Loading branch information
rafaelromcar-parabol authored Feb 22, 2024
1 parent e4a831a commit 61ba015
Show file tree
Hide file tree
Showing 4 changed files with 166 additions and 25 deletions.
1 change: 1 addition & 0 deletions docker/parabol-ubi/docker-host-st/.env.example
Original file line number Diff line number Diff line change
@@ -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.
33 changes: 30 additions & 3 deletions docker/parabol-ubi/docker-host-st/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,42 @@
# 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 --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
🔥🔥🔥 Server ID: 0. Ready for Sockets: Port 3000 🔥🔥🔥
💧💧💧 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) In a different terminal, run `docker compose logs -f` to follow the upgrade.
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 --profile databases --profile parabol --profile chronos up`.

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 --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`
156 changes: 135 additions & 21 deletions docker/parabol-ubi/docker-host-st/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,51 +1,165 @@
version: '3.7'
version: '3.9'

services:
db:
image: rethinkdb:latest
postgres:
container_name: postgres
profiles: ["databases"]
image: postgres:15.4
restart: always
env_file: .env
environment:
- PGUSER=$POSTGRES_USER
ports:
- '5432:5432'
volumes:
- './data/postgres/pgdata:/var/lib/postgresql/data'
healthcheck:
test: ["CMD-SHELL", "pg_isready", "-d", "$POSTGRES_DB", "-U", "$POSTGRES_USER"]
interval: 10s
timeout: 5s
retries: 5
networks:
- parabol-network
pgadmin:
profiles: ["database-debug"]
container_name: pgadmin
image: dpage/pgadmin4:8.3
depends_on:
postgres:
condition: service_healthy
env_file: .env
ports:
- "5050:80"
networks:
- parabol-network
rethinkdb:
container_name: rethinkdb
profiles: ["databases"]
image: rethinkdb:2.4.2
restart: always
ports:
- '8080:8080'
- '29015:29015'
- '28015:28015'
volumes:
- ./rethink-data:/data
- ./data/rethink:/data
networks:
- parabol-network
postgres:
image: postgres:15.4
redis:
container_name: redis
profiles: ["databases"]
image: redis:7.0-alpine
healthcheck:
test: "[ $$(redis-cli ping) = 'PONG' ]"
interval: 10s
timeout: 5s
retries: 5
restart: always
env_file: .env
ports:
- '5432:5432'
- '6379:6379'
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/redis:/data
networks:
- parabol-network
redis:
image: redis
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:
- '6379:6379'
- "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
environment:
- SERVER_ID=0
volumes:
- ./redis-data:/data
- './.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:
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
command: bash -c "yarn predeploy && NODE_ENV=production && yarn start"
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"
env_file: .env
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
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"
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:
Expand Down
1 change: 0 additions & 1 deletion docker/parabol-ubi/docker-host-st/postgres.conf

This file was deleted.

0 comments on commit 61ba015

Please sign in to comment.