Add production install script and migrate service
- install.sh: Interactive setup script for Linux VPS/LXC deployment - Checks prerequisites (Docker, Docker Compose, OpenSSL) - Auto-generates all secrets (Postgres, MinIO, NextAuth, encryption) - Creates .env.production with proper Docker service hostnames - Builds and starts all services via docker-compose.prod.yml - Health check loop with status reporting - Idempotent (safe to re-run) - docker-compose.prod.yml: Add migrate service - One-shot container that runs prisma db push before app starts - App depends on migrate completing successfully - Override DATABASE_URL and MINIO_ENDPOINT for Docker networking Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -45,6 +45,23 @@ services:
|
||||
exit 0;
|
||||
"
|
||||
|
||||
migrate:
|
||||
image: node:20-alpine
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
working_dir: /app
|
||||
volumes:
|
||||
- ./prisma:/app/prisma
|
||||
- ./package.json:/app/package.json
|
||||
- ./package-lock.json:/app/package-lock.json
|
||||
env_file:
|
||||
- .env.production
|
||||
environment:
|
||||
DATABASE_URL: "postgresql://${POSTGRES_USER:-drinktracker}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB:-drinktracker}"
|
||||
command: sh -c "npm install prisma @prisma/client --silent && npx prisma db push --skip-generate --accept-data-loss"
|
||||
restart: "no"
|
||||
|
||||
app:
|
||||
build:
|
||||
context: .
|
||||
@@ -57,8 +74,13 @@ services:
|
||||
condition: service_healthy
|
||||
minio:
|
||||
condition: service_healthy
|
||||
migrate:
|
||||
condition: service_completed_successfully
|
||||
env_file:
|
||||
- .env.production
|
||||
environment:
|
||||
DATABASE_URL: "postgresql://${POSTGRES_USER:-drinktracker}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB:-drinktracker}"
|
||||
MINIO_ENDPOINT: "minio"
|
||||
|
||||
volumes:
|
||||
pgdata:
|
||||
|
||||
Reference in New Issue
Block a user