From 9077c41bc8b9c699ef1ce1a1c4c8168b511e5981 Mon Sep 17 00:00:00 2001 From: sbriat Date: Mon, 20 Mar 2023 10:23:59 +0100 Subject: [PATCH] remove db from service --check --- .env.dist | 6 +-- .env.test | 5 +- ci/.env.ci | 9 +--- ci/wait-up.sh | 2 +- docker-compose.ci.tools.yml | 26 ++++------ docker-compose.yml | 48 +------------------ .../20230206113946_init/migration.sql | 4 ++ 7 files changed, 20 insertions(+), 80 deletions(-) diff --git a/.env.dist b/.env.dist index 9df7acc..850a500 100644 --- a/.env.dist +++ b/.env.dist @@ -4,7 +4,7 @@ SERVICE_PORT=5004 SERVICE_CONFIGURATION_DOMAIN=TERRITORY # PRISMA -DATABASE_URL="postgresql://territory:territory@v3-territory-db:5432/territory?schema=public" +DATABASE_URL="postgresql://mobicoop:mobicoop@v3-db:5432/mobicoop?schema=territory" # RABBIT MQ RMQ_URI=amqp://v3-broker:5672 @@ -14,8 +14,8 @@ RMQ_EXCHANGE=mobicoop POSTGRES_IMAGE=postgis/postgis:15-3.3 # REDIS -REDIS_IMAGE=redis:7.0-alpine -REDIS_HOST=v3-territory-redis +REDIS_HOST=v3-redis +REDIS_PASSWORD=redis REDIS_PORT=6379 # CACHE diff --git a/.env.test b/.env.test index 907a6d4..1264154 100644 --- a/.env.test +++ b/.env.test @@ -4,7 +4,4 @@ SERVICE_PORT=5004 SERVICE_CONFIGURATION_DOMAIN=TERRITORY # PRISMA -DATABASE_URL="postgresql://territory:territory@localhost:5604/territory?schema=public" - -# POSTGRES -POSTGRES_IMAGE=postgis/postgis:15-3.3 +DATABASE_URL="postgresql://mobicoop:mobicoop@localhost:5432/mobicoop-test?schema=territory" diff --git a/ci/.env.ci b/ci/.env.ci index 39a0ede..8f9361a 100644 --- a/ci/.env.ci +++ b/ci/.env.ci @@ -3,18 +3,13 @@ SERVICE_URL=0.0.0.0 SERVICE_PORT=5004 # PRISMA -DATABASE_URL="postgresql://territory:territory@v3-territory-db-test:5432/territory?schema=public" +DATABASE_URL="postgresql://mobicoop:mobicoop@v3-db:5432/mobicoop?schema=public" # RABBIT MQ -RMQ_URI=amqp://v3-territory-broker:5672 +RMQ_URI=amqp://v3-broker:5672 # MESSAGE BROKER BROKER_IMAGE=rabbitmq:3-alpine # POSTGRES POSTGRES_IMAGE=postgis/postgis:15-3.3 - -# REDIS -REDIS_IMAGE=redis:7.0-alpine -REDIS_HOST=v3-territory-redis -REDIS_PORT=6379 diff --git a/ci/wait-up.sh b/ci/wait-up.sh index 4308dfa..f29be44 100644 --- a/ci/wait-up.sh +++ b/ci/wait-up.sh @@ -1,6 +1,6 @@ #!/bin/bash testlog() { - docker logs v3-territory-db-test | grep -q "database system is ready to accept connections" + docker logs v3-db | grep -q "database system is ready to accept connections" } testlog 2> /dev/null diff --git a/docker-compose.ci.tools.yml b/docker-compose.ci.tools.yml index 2a83306..a72f134 100644 --- a/docker-compose.ci.tools.yml +++ b/docker-compose.ci.tools.yml @@ -1,30 +1,20 @@ version: '3.8' services: - v3-territory-redis: - container_name: v3-territory-redis - image: ${REDIS_IMAGE} - ports: - - 6504:6379 - env_file: - - ci/.env.ci - networks: - - v3-network - - v3-territory-db-test: - container_name: v3-territory-db-test + db: + container_name: v3-db image: ${POSTGRES_IMAGE} environment: - POSTGRES_DB: territory - POSTGRES_USER: territory - POSTGRES_PASSWORD: territory + POSTGRES_DB: mobicoop + POSTGRES_USER: mobicoop + POSTGRES_PASSWORD: mobicoop ports: - - 5604:5432 + - 5432:5432 networks: - v3-network - v3-territory-broker: - container_name: v3-territory-broker + broker: + container_name: v3-broker image: ${BROKER_IMAGE} ports: - 5672:5672 diff --git a/docker-compose.yml b/docker-compose.yml index c2f70a6..537af33 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,7 +2,7 @@ version: '3.8' services: v3-territory-api: - container_name: v3-territory + container_name: v3-territory-api build: dockerfile: Dockerfile context: . @@ -14,57 +14,11 @@ services: command: npm run start:dev ports: - ${SERVICE_PORT:-5004}:${SERVICE_PORT:-5004} - depends_on: - - v3-territory-db networks: v3-network: aliases: - v3-territory-api - v3-territory-redis: - container_name: v3-territory-redis - image: ${REDIS_IMAGE} - ports: - - 6504:6379 - volumes: - - .redis_data:/data - env_file: - - .env - networks: - v3-network: - aliases: - - v3-territory-redis - - v3-territory-db: - container_name: v3-territory-db - image: ${POSTGRES_IMAGE} - environment: - POSTGRES_DB: territory - POSTGRES_USER: territory - POSTGRES_PASSWORD: territory - ports: - - 5504:5432 - volumes: - - .postgresql:/var/lib/postgresql/data:rw - networks: - v3-network: - aliases: - - v3-territory-db - - v3-territory-db-test: - container_name: v3-territory-db-test - image: ${POSTGRES_IMAGE} - environment: - POSTGRES_DB: territory - POSTGRES_USER: territory - POSTGRES_PASSWORD: territory - ports: - - 5604:5432 - networks: - v3-network: - aliases: - - v3-territory-db-test - networks: v3-network: name: v3-network diff --git a/prisma/migrations/20230206113946_init/migration.sql b/prisma/migrations/20230206113946_init/migration.sql index 3fdbaac..983ca5a 100644 --- a/prisma/migrations/20230206113946_init/migration.sql +++ b/prisma/migrations/20230206113946_init/migration.sql @@ -1,6 +1,10 @@ -- CreateExtension CREATE EXTENSION IF NOT EXISTS "postgis"; +-- Required to use postgis extension : +-- set the search_path to both public (where is postgis) AND the current schema +SET search_path TO territory, public; + -- CreateTable CREATE TABLE "territory" ( "uuid" UUID NOT NULL,