Skip to content

Commit

Permalink
misc(docker): Uses migrate service instead of api (#428)
Browse files Browse the repository at this point in the history
* misc(docker): Uses migrate service instead of api

* update dependencies

* some small fixes

* uses now all services for a better scalability

* just use migrate service

* will update dep later

* add migrate dep

* update migrate version
  • Loading branch information
jdenquin authored Jan 21, 2025
1 parent 27cf480 commit 456bec7
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 23 deletions.
2 changes: 2 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
name: lago_dev

volumes:
front_node_modules_dev:
front_dist_dev:
Expand Down
78 changes: 55 additions & 23 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,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}
Expand All @@ -25,19 +34,47 @@ 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.19.0
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}
- REDIS_URL=redis://${REDIS_HOST:-redis}:${REDIS_PORT:-6379}
- REDIS_PASSWORD=${REDIS_PASSWORD}

api:
container_name: lago-api
image: getlago/api:v1.19.0
restart: unless-stopped
depends_on:
- db
- redis
command: ["./scripts/start.sh"]
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
interval: 10s
Expand Down Expand Up @@ -102,6 +139,7 @@ services:
depends_on:
api:
condition: service_healthy
restart: true
environment:
- API_URL=${LAGO_API_URL:-http://localhost:3000}
- APP_ENV=${APP_ENV:-production}
Expand Down Expand Up @@ -137,8 +175,14 @@ services:
image: getlago/api:v1.19.0
restart: unless-stopped
depends_on:
api:
migrate:
condition: service_completed_successfully
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"]
Expand Down Expand Up @@ -412,8 +456,14 @@ services:
image: getlago/api:v1.19.0
restart: unless-stopped
depends_on:
api:
migrate:
condition: service_completed_successfully
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}
Expand All @@ -437,21 +487,3 @@ services:

pdf:
image: getlago/lago-gotenberg:7.8.2

migrate:
container_name: lago-migrate
image: getlago/api:v1.19.0
depends_on:
- db
- redis
command: ["./scripts/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}

0 comments on commit 456bec7

Please sign in to comment.