From 949b55c543786982407a93047c3329c024af5a29 Mon Sep 17 00:00:00 2001 From: Rachid F <109089247+rflihxyz@users.noreply.github.com> Date: Thu, 14 Dec 2023 23:00:48 +0000 Subject: [PATCH] :hammer: Update healthcheck in docker-compose Update healthcheck in docker-compose --- docker-compose.yml | 18 ++++++++---------- packages/api/scripts/pull-database.sh | 2 ++ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index ba261e8c7..195e2c941 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,6 +14,11 @@ services: POSTGRES_DB: ${POSTGRES_DB} ports: - "5432:5432" + healthcheck: + test: ["CMD-SHELL", "pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}"] + interval: 10s + timeout: 5s + retries: 5 volumes: - ./pg_data:/var/lib/postgresql/data - ./packages/api/scripts/init.sql:/docker-entrypoint-initdb.d/init.sql @@ -33,8 +38,10 @@ services: unless-stopped ports: - 3000:3000 + command: sh -c "/app/packages/api/scripts/pull-database.sh && pnpm run build && node dist/src/main.js" depends_on: - - postgres + postgres: + condition: service_healthy networks: - backend @@ -45,15 +52,6 @@ services: - "6379:6379" volumes: - ./redis-data:/data - - docs: - build: - context: ./ - dockerfile: ./docs/Dockerfile - restart: - always - ports: - - 5000:3000 webapp: build: diff --git a/packages/api/scripts/pull-database.sh b/packages/api/scripts/pull-database.sh index df83ca753..545b6e28c 100755 --- a/packages/api/scripts/pull-database.sh +++ b/packages/api/scripts/pull-database.sh @@ -1,3 +1,5 @@ +#!/bin/sh + # SCRIPT TO USE IF YOU WANT TO UPDATE YOUR PRISMA MODEL BASED ON YOUR DB # it pulls changes from your database to your Prisma schema # DB => PRISMA MODEL