From 2e13daa2cb2190e1031413c288a0f8ca5162d804 Mon Sep 17 00:00:00 2001 From: jdenquin Date: Tue, 5 Nov 2024 15:16:05 +0100 Subject: [PATCH 1/3] misc(docker): Uses migrate service instead of api --- api | 2 +- docker-compose.dev.yml | 2 ++ docker-compose.yml | 57 ++++++++++++++++++++++++++---------------- front | 2 +- 4 files changed, 40 insertions(+), 23 deletions(-) diff --git a/api b/api index 85136d0..d7bf864 160000 --- a/api +++ b/api @@ -1 +1 @@ -Subproject commit 85136d0e642b6a087e60716564974281bd1d1f9c +Subproject commit d7bf86400acbfcb3dc5f4504997807f77f6923ad diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index fbd8cfa..3a14327 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -1,3 +1,5 @@ +name: lago_dev + volumes: front_node_modules_dev: front_dist_dev: diff --git a/docker-compose.yml b/docker-compose.yml index d0ea9b7..0738f0b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,3 +1,5 @@ +name: Lago + volumes: lago_postgres_data: lago_redis_data: @@ -8,6 +10,15 @@ services: image: postgres:14-alpine container_name: lago-db restart: unless-stopped + healthcheck: + test: + [ + "CMD-SHELL", + "pg_isready -U ${POSTGRES_USER:-lago} -d ${POSTGRES_DB:-lago} -h localhost -p ${POSTGRES_PORT:-5432}", + ] + interval: 10s + timeout: 5s + retries: 5 environment: POSTGRES_DB: ${POSTGRES_DB:-lago} POSTGRES_USER: ${POSTGRES_USER:-lago} @@ -25,19 +36,41 @@ services: container_name: lago-redis restart: unless-stopped command: --port ${REDIS_PORT:-6379} + healthcheck: + test: ["CMD", "redis-cli", "ping"] + interval: 10s + timeout: 5s + retries: 5 volumes: - lago_redis_data:/data ports: - ${REDIS_PORT:-6379}:${REDIS_PORT:-6379} + migrate: + container_name: lago-migrate + image: getlago/api:v1.15.2 + depends_on: + db: + condition: service_healthy + restart: true + command: ["./scripts/migrate.sh"] + environment: + - RAILS_ENV=production + - SECRET_KEY_BASE=${SECRET_KEY_BASE:-your-secret-key-base-hex-64} + - RSA_PRIVATE_KEY=${LAGO_RSA_PRIVATE_KEY} # Should be base64 encoded + - LAGO_RSA_PRIVATE_KEY=${LAGO_RSA_PRIVATE_KEY} # Should be base64 encoded + - DATABASE_URL=postgresql://${POSTGRES_USER:-lago}:${POSTGRES_PASSWORD:-changeme}@${POSTGRES_HOST:-db}:${POSTGRES_PORT:-5432}/${POSTGRES_DB:-lago}?search_path=${POSTGRES_SCHEMA:-public} + api: container_name: lago-api image: getlago/api:v1.15.2 restart: unless-stopped depends_on: - - db - - redis - command: ["./scripts/start.sh"] + migrate: + condition: service_completed_successfully + redis: + condition: service_healthy + command: ["./scripts/start.api.sh"] healthcheck: test: curl -f http://localhost:3000/health || exit 1 interval: 10s @@ -289,21 +322,3 @@ services: pdf: image: getlago/lago-gotenberg:7.8.2 - - migrate: - container_name: lago-migrate - image: getlago/api:v1.13.1 - depends_on: - - db - - redis - command: ["./scripts/start.migrate.sh"] - volumes: - - lago_storage_data:/app/storage - environment: - - RAILS_ENV=production - - SECRET_KEY_BASE=${SECRET_KEY_BASE:-your-secret-key-base-hex-64} - - RSA_PRIVATE_KEY=${LAGO_RSA_PRIVATE_KEY} # Should be base64 encoded - - LAGO_RSA_PRIVATE_KEY=${LAGO_RSA_PRIVATE_KEY} # Should be base64 encoded - - DATABASE_URL=postgresql://${POSTGRES_USER:-lago}:${POSTGRES_PASSWORD:-changeme}@${POSTGRES_HOST:-db}:${POSTGRES_PORT:-5432}/${POSTGRES_DB:-lago}?search_path=${POSTGRES_SCHEMA:-public} - - REDIS_URL=redis://${REDIS_HOST:-redis}:${REDIS_PORT:-6379} - - REDIS_PASSWORD=${REDIS_PASSWORD} diff --git a/front b/front index c8506af..3195462 160000 --- a/front +++ b/front @@ -1 +1 @@ -Subproject commit c8506af8b6ee7b89445bfafcccdb850cc0332907 +Subproject commit 31954626fdf65baf801619034e483fd29a7ee5a7 From 8b33eb924fa27ef759a5a92d566d7ff88623d0e7 Mon Sep 17 00:00:00 2001 From: jdenquin Date: Tue, 5 Nov 2024 15:21:10 +0100 Subject: [PATCH 2/3] update dependencies --- docker-compose.yml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 0738f0b..1e947be 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -68,8 +68,12 @@ services: depends_on: migrate: condition: service_completed_successfully + db: + condition: service_healthy + restart: true redis: condition: service_healthy + restart: true command: ["./scripts/start.api.sh"] healthcheck: test: curl -f http://localhost:3000/health || exit 1 @@ -131,6 +135,7 @@ services: depends_on: api: condition: service_healthy + restart: true environment: - API_URL=${LAGO_API_URL:-http://localhost:3000} - APP_ENV=${APP_ENV:-production} @@ -166,8 +171,12 @@ services: image: getlago/api:v1.15.2 restart: unless-stopped depends_on: - api: + db: condition: service_healthy + restart: true + redis: + condition: service_healthy + restart: true command: ["./scripts/start.worker.sh"] healthcheck: test: ["CMD-SHELL", "bundle exec sidekiqmon | grep $(hostname) || exit 1"] @@ -298,8 +307,12 @@ services: image: getlago/api:v1.15.2 restart: unless-stopped depends_on: - api: + db: condition: service_healthy + restart: true + redis: + condition: service_healthy + restart: true command: ["./scripts/start.clock.sh"] environment: - LAGO_API_URL=${LAGO_API_URL:-http://localhost:3000} From 1637571486515f9bde553d8e04fb7bd76041ef57 Mon Sep 17 00:00:00 2001 From: Jeremy Denquin Date: Wed, 6 Nov 2024 16:53:05 +0100 Subject: [PATCH 3/3] some small fixes --- api | 2 +- docker-compose.yml | 12 ++++++------ front | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/api b/api index d7bf864..2a0f21a 160000 --- a/api +++ b/api @@ -1 +1 @@ -Subproject commit d7bf86400acbfcb3dc5f4504997807f77f6923ad +Subproject commit 2a0f21a248cdab791048e5fca639853a78de291f diff --git a/docker-compose.yml b/docker-compose.yml index 1e947be..80043b6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,3 @@ -name: Lago - volumes: lago_postgres_data: lago_redis_data: @@ -48,7 +46,7 @@ services: migrate: container_name: lago-migrate - image: getlago/api:v1.15.2 + image: getlago/api:jeremy depends_on: db: condition: service_healthy @@ -60,10 +58,12 @@ services: - RSA_PRIVATE_KEY=${LAGO_RSA_PRIVATE_KEY} # Should be base64 encoded - LAGO_RSA_PRIVATE_KEY=${LAGO_RSA_PRIVATE_KEY} # Should be base64 encoded - DATABASE_URL=postgresql://${POSTGRES_USER:-lago}:${POSTGRES_PASSWORD:-changeme}@${POSTGRES_HOST:-db}:${POSTGRES_PORT:-5432}/${POSTGRES_DB:-lago}?search_path=${POSTGRES_SCHEMA:-public} + - REDIS_URL=redis://${REDIS_HOST:-redis}:${REDIS_PORT:-6379} + - REDIS_PASSWORD=${REDIS_PASSWORD} api: container_name: lago-api - image: getlago/api:v1.15.2 + image: getlago/api:jeremy restart: unless-stopped depends_on: migrate: @@ -168,7 +168,7 @@ services: api-worker: container_name: lago-worker - image: getlago/api:v1.15.2 + image: getlago/api:jeremy restart: unless-stopped depends_on: db: @@ -304,7 +304,7 @@ services: api-clock: container_name: lago-clock - image: getlago/api:v1.15.2 + image: getlago/api:jeremy restart: unless-stopped depends_on: db: diff --git a/front b/front index 3195462..98c1166 160000 --- a/front +++ b/front @@ -1 +1 @@ -Subproject commit 31954626fdf65baf801619034e483fd29a7ee5a7 +Subproject commit 98c1166fac8ab1a7ead050332f8870dd02705db4