chore(database): add postgres and valkey services
These are used by `strapi` and `directus` to store data.
This commit is contained in:
parent
1ad7e94ea1
commit
7fab4e4072
48
services/database/compose.yml
Normal file
48
services/database/compose.yml
Normal file
@ -0,0 +1,48 @@
|
||||
---
|
||||
services:
|
||||
postgres:
|
||||
image: 'postgres:17.4-bookworm'
|
||||
hostname: ${CMS_POSTGRES_HOST:-postgres}
|
||||
init: true
|
||||
restart: unless-stopped
|
||||
healthcheck:
|
||||
test:
|
||||
- CMD-SHELL
|
||||
- pg_isready
|
||||
- --hostname
|
||||
- localhost
|
||||
- --username
|
||||
- ${CMD_POSTGRES_USER:-postgres}
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
start_interval: 5s
|
||||
start_period: 30s
|
||||
environment:
|
||||
POSTGRES_USER: ${CMS_POSTGRES_USER:-postgres}
|
||||
POSTGRES_PASSWORD: ${CMS_POSTGRES_PASSWORD:-postgres}
|
||||
volumes:
|
||||
- 'postgres_data:/var/lib/postgresql/data'
|
||||
- './scripts/postgres:/docker-entrypoint-initdb.d'
|
||||
|
||||
# NOTE: (jpd) this is an open-source alternative to redis
|
||||
valkey:
|
||||
image: 'valkey/valkey:8.0.2-bookworm'
|
||||
hostname: ${CMS_VALKEY_HOST:-valkey}
|
||||
init: true
|
||||
restart: unless-stopped
|
||||
healthcheck:
|
||||
test:
|
||||
- CMD-SHELL
|
||||
- '[ $$(redis-cli ping) = "PONG" ]'
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
start_interval: 5s
|
||||
start_period: 30s
|
||||
volumes:
|
||||
- 'valkey_data:/data'
|
||||
|
||||
volumes:
|
||||
postgres_data: {}
|
||||
valkey_data: {}
|
7
services/database/scripts/postgres/00-create-strapi-database.sh
Executable file
7
services/database/scripts/postgres/00-create-strapi-database.sh
Executable file
@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
set -ex
|
||||
|
||||
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
|
||||
CREATE DATABASE strapi;
|
||||
GRANT ALL PRIVILEGES ON DATABASE strapi TO ${POSTGRES_USER};
|
||||
EOSQL
|
7
services/database/scripts/postgres/01-create-directus-database.sh
Executable file
7
services/database/scripts/postgres/01-create-directus-database.sh
Executable file
@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
|
||||
CREATE DATABASE directus;
|
||||
GRANT ALL PRIVILEGES ON DATABASE strapi TO ${POSTGRES_USER};
|
||||
EOSQL
|
Loading…
x
Reference in New Issue
Block a user