From 4173972d01ed3fc15e87a58b1a85efd2c0dcba8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=ABl?= <57440945+jofmi@users.noreply.github.com> Date: Mon, 8 Apr 2024 11:57:33 +0200 Subject: [PATCH] feat: consistent env vars --- .env.example | 41 ++++++++++----------- collectivo/collectivo/nuxt.config.ts | 18 ++++----- docker-compose.yml | 55 ++++++++++++++-------------- 3 files changed, 57 insertions(+), 57 deletions(-) diff --git a/.env.example b/.env.example index c01ce955..d4d8ba94 100644 --- a/.env.example +++ b/.env.example @@ -1,8 +1,10 @@ DIRECTUS_URL = "http://localhost:8055" -DIRECTUS_HOSTNAME = 'localhost' -DIRECTUS_KEY = 'changeme' -DIRECTUS_SECRET = 'changeme' -DIRECTUS_DB_PASSWORD = 'changeme' +DIRECTUS_DOMAIN = "localhost" +DIRECTUS_KEY = "changeme" +DIRECTUS_SECRET = "changeme" +DIRECTUS_DB_PASSWORD = "changeme" +DIRECTUS_ADMIN_EMAIL = "api@example.com" +DIRECTUS_ADMIN_PASSWORD = "d1r3ctu5" DIRECTUS_EMAIL_FROM = "" DIRECTUS_EMAIL_TRANSPORT = "smtp" @@ -12,21 +14,18 @@ DIRECTUS_EMAIL_SMTP_USER = "" DIRECTUS_EMAIL_SMTP_PASSWORD = "" KEYCLOAK_URL = "http://keycloak:8080" -KEYCLOAK_HOSTNAME = 'keycloak' -KEYCLOAK_ADMIN = 'admin@example.com' -KEYCLOAK_ADMIN_PASSWORD = 'admin' -KEYCLOAK_DB_PASSWORD = 'changeme' - -NUXT_API_TOKEN = "badToken" -NUXT_PUBLIC_DEBUG = "false" -NUXT_PUBLIC_COLLECTIVO_URL = "http://localhost:3000" - -NUXT_KEYCLOAK_ADMIN_CLIENT = "admin-cli" -NUXT_KEYCLOAK_ADMIN_SECRET = "**********" -NUXT_PUBLIC_KEYCLOAK_URL = "http://keycloak:8080" -NUXT_PUBLIC_KEYCLOAK_REALM = "collectivo" - -NUXT_DIRECTUS_ADMIN_EMAIL = "api@example.com" -NUXT_DIRECTUS_ADMIN_PASSWORD = "d1r3ctu5" -NUXT_PUBLIC_DIRECTUS_URL = "http://localhost:8055" +KEYCLOAK_DOMAIN = "keycloak" +KEYCLOAK_ADMIN = "admin@example.com" +KEYCLOAK_ADMIN_PASSWORD = "admin" +KEYCLOAK_DB_PASSWORD = "changeme" +KEYCLOAK_REALM = "collectivo" +KEYCLOAK_ADMIN_CLIENT = "admin-cli" +KEYCLOAK_ADMIN_SECRET = "**********" +KEYCLOAK_DIRECTUS_CLIENT = "directus" +KEYCLOAK_DIRECTUS_SECRET = "**********" +COLLECTIVO_URL = "http://localhost:3000" +COLLECTIVO_DOMAIN = "localhost" +COLLECTIVO_DEBUG = "false" +COLLECTIVO_API_URL = "http://host.docker.internal:3000" +COLLECTIVO_API_TOKEN = "badToken" diff --git a/collectivo/collectivo/nuxt.config.ts b/collectivo/collectivo/nuxt.config.ts index d69ce880..fd9e9f87 100644 --- a/collectivo/collectivo/nuxt.config.ts +++ b/collectivo/collectivo/nuxt.config.ts @@ -10,18 +10,18 @@ export default defineNuxtConfig({ ssr: false, runtimeConfig: { collectivoVersion: pkg.version, - apiToken: "badToken", - directusAdminEmail: "api@example.com", - directusAdminPassword: "d1r3ctu5", - keycloakAdminClient: "admin-cli", - keycloakAdminSecret: "**********", + apiToken: process.env.COLLECTIVO_API_TOKEN || "badToken", + directusAdminEmail: process.env.DIRECTUS_ADMIN_EMAIL || "api@example.com", + directusAdminPassword: process.env.DIRECTUS_ADMIN_PASSWORD || "d1r3ctu5", + keycloakAdminClient: process.env.KEYCLOAK_ADMIN_CLIENT || "admin-cli", + keycloakAdminSecret: process.env.KEYCLOAK_ADMIN_SECRET || "**********", public: { debug: false, - collectivoUrl: "http://localhost:3000", + collectivoUrl: process.env.COLLECTIVO_URL || "http://localhost:3000", authService: "keycloak", - keycloakUrl: "http://keycloak:8080", - keycloakRealm: "collectivo", - directusUrl: "http://localhost:8055", + keycloakUrl: process.env.KEYCLOAK_URL || "http://keycloak:8080", + keycloakRealm: process.env.KEYCLOAK_REALM || "collectivo", + directusUrl: process.env.DIRECTUS_URL || "http://localhost:8055", }, }, colorMode: { diff --git a/docker-compose.yml b/docker-compose.yml index 01824ea9..076d7e94 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,11 +17,12 @@ services: directus-db: condition: service_healthy environment: - KEY: "0fda9121-269d-44bd-91f2-4ff05be14b4b" - SECRET: "86cb4a76-a4c6-4ce7-8181-b0445d95675c" + PUBLIC_URL: ${DIRECTUS_URL} + KEY: ${DIRECTUS_KEY} + SECRET: ${DIRECTUS_SECRET} - ADMIN_EMAIL: ${NUXT_DIRECTUS_ADMIN_EMAIL} - ADMIN_PASSWORD: ${NUXT_DIRECTUS_ADMIN_PASSWORD} + ADMIN_EMAIL: ${DIRECTUS_ADMIN_EMAIL} + ADMIN_PASSWORD: ${DIRECTUS_ADMIN_PASSWORD} CORS_ENABLED: "true" CORS_ORIGIN: "true" @@ -38,16 +39,13 @@ services: CACHE_STORE: "redis" REDIS: "redis://directus-cache:6379" - PUBLIC_URL: "http://localhost:8055" - AUTH_PROVIDERS: "keycloak" AUTH_KEYCLOAK_DRIVER: "openid" - AUTH_KEYCLOAK_CLIENT_ID: "directus" - AUTH_KEYCLOAK_CLIENT_SECRET: "**********" - AUTH_KEYCLOAK_ISSUER_URL: "http://keycloak:8080/realms/collectivo/.well-known/openid-configuration" + AUTH_KEYCLOAK_CLIENT_ID: ${KEYCLOAK_DIRECTUS_CLIENT} + AUTH_KEYCLOAK_CLIENT_SECRET: ${KEYCLOAK_DIRECTUS_SECRET} + AUTH_KEYCLOAK_ISSUER_URL: "${KEYCLOAK_URL}/realms/collectivo/.well-known/openid-configuration" AUTH_KEYCLOAK_IDENTIFIER_KEY: "email" AUTH_KEYCLOAK_ALLOW_PUBLIC_REGISTRATION: "true" - # AUTH_KEYCLOAK_DEFAULT_ROLE_ID: SESSION_COOKIE_SECURE: "false" SESSION_COOKIE_SAME_SITE: "lax" @@ -57,10 +55,13 @@ services: EMAIL_FROM: ${DIRECTUS_EMAIL_FROM} EMAIL_TRANSPORT: ${DIRECTUS_EMAIL_TRANSPORT} EMAIL_SMTP_HOST: ${DIRECTUS_EMAIL_SMTP_HOST} - EMAIL_SMTP_PORT: ${DIRECTUS_EMAIL_SMTP_PORT} EMAIL_SMTP_USER: ${DIRECTUS_EMAIL_SMTP_USER} EMAIL_SMTP_PASSWORD: ${DIRECTUS_EMAIL_SMTP_PASSWORD} + COLLECTIVO_API_URL: ${COLLECTIVO_API_URL} + COLLECTIVO_API_KEY: ${COLLECTIVO_API_TOKEN} + FLOWS_ENV_ALLOW_LIST: "COLLECTIVO_API_URL, COLLECTIVO_API_TOKEN" + directus-db: image: postgis/postgis:15-3.4-alpine volumes: @@ -80,20 +81,6 @@ services: directus-cache: image: redis:6 - keycloak-db: - image: postgres:15.4-alpine - volumes: - - keycloak-db-data:/var/lib/postgresql/data - environment: - POSTGRES_DB: keycloak - POSTGRES_USER: keycloak - POSTGRES_PASSWORD: ${KEYCLOAK_DB_PASSWORD} - healthcheck: - test: ["CMD-SHELL", "pg_isready"] - interval: 10s - timeout: 5s - retries: 5 - keycloak: build: context: ./keycloak @@ -109,13 +96,13 @@ services: KC_DB_URL_DATABASE: "keycloak" KC_DB_URL_HOST: "keycloak-db" KC_DB_URL_PORT: 5432 - KC_HOSTNAME: ${KEYCLOAK_HOSTNAME} + KC_HOSTNAME: ${KEYCLOAK_DOMAIN} volumes: - ./keycloak/import:/opt/keycloak/data/import:ro - ./keycloak/export:/tmp/export command: start-dev --import-realm --health-enabled true healthcheck: - test: ["CMD", "curl", "-f", "http://localhost:8080/health/ready"] + test: ["CMD", "curl", "-f", "${KEYCLOAK_URL}/health/ready"] interval: 5s timeout: 5s retries: 20 @@ -124,6 +111,20 @@ services: ports: - "8080:8080" + keycloak-db: + image: postgres:15.4-alpine + volumes: + - keycloak-db-data:/var/lib/postgresql/data + environment: + POSTGRES_DB: keycloak + POSTGRES_USER: keycloak + POSTGRES_PASSWORD: ${KEYCLOAK_DB_PASSWORD} + healthcheck: + test: ["CMD-SHELL", "pg_isready"] + interval: 10s + timeout: 5s + retries: 5 + volumes: directus-db-data: keycloak-db-data: