From 1d00438440664485f1bf9a128dcf137083bb7539 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 18 Mar 2025 10:07:48 +0100 Subject: [PATCH] refactor(docker): directus use postgress, redis and fix cors (#26) * directus use postgress, redis and fix cors In order to use gis features you can install some plugins to sqlite or use postgres which supports those features natively. Use a redis cache as this was part of the advanced setup example. Furthermore fix cors and allow http://localhost:8080 by default. * lint fixes --- docker-compose.yml | 60 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 55 insertions(+), 5 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 85f932b5..829739ed 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,5 @@ services: - server: + frontend: image: cupcakearmy/static restart: unless-stopped ports: @@ -7,14 +7,64 @@ services: volumes: - ./dist:/srv:ro + database: + image: postgis/postgis:13-master + # Required when running on platform other than amd64, like Apple M1/M2: + # platform: linux/amd64 + volumes: + - ./data/database:/var/lib/postgresql/data + environment: + POSTGRES_USER: 'directus' + POSTGRES_PASSWORD: 'directus' + POSTGRES_DB: 'directus' + healthcheck: + test: ['CMD', 'pg_isready', '--host=localhost', '--username=directus'] + interval: 10s + timeout: 5s + retries: 5 + start_interval: 5s + start_period: 30s + + cache: + image: redis:6 + healthcheck: + test: ['CMD-SHELL', "[ $$(redis-cli ping) = 'PONG' ]"] + interval: 10s + timeout: 5s + retries: 5 + start_interval: 5s + start_period: 30s + backend: container_name: backend build: context: ./backend + depends_on: + database: + condition: service_healthy + cache: + condition: service_healthy ports: - 8055:8055 environment: - - SECRET=SECRET - - PUBLIC_URL=http://localhost - - ADMIN_EMAIL=admin@it4c.dev - - ADMIN_PASSWORD=admin123 + PUBLIC_URL: 'http://localhost' + + SECRET: 'SECRET' + + CORS_ENABLED: 'true' + CORS_ORIGIN: 'http://localhost:8080' + + DB_CLIENT: 'pg' + DB_HOST: 'database' + DB_PORT: '5432' + DB_DATABASE: 'directus' + DB_USER: 'directus' + DB_PASSWORD: 'directus' + + CACHE_ENABLED: 'true' + CACHE_AUTO_PURGE: 'true' + CACHE_STORE: 'redis' + REDIS: 'redis://cache:6379' + + ADMIN_EMAIL: 'admin@it4c.dev' + ADMIN_PASSWORD: 'admin123'