From 8ac119c1fe8cd13523f24c923edf3b3ec6e952f1 Mon Sep 17 00:00:00 2001 From: wanghao Date: Tue, 16 Sep 2025 20:33:50 +0800 Subject: [PATCH] chore(docker): add prisma directory to Dockerfile and create docker-compose.yml Add /app/prisma copy in Dockerfile for database schema. Introduce docker-compose.yml with full service stack including postgres, redis, minio, and migration service. --- Dockerfile | 1 + docker-compose.yml | 98 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile index 2e620e84..ce150a19 100644 --- a/Dockerfile +++ b/Dockerfile @@ -37,6 +37,7 @@ COPY --from=builder /app/tsconfig.json ./tsconfig.json COPY --from=builder /app/package.json ./package.json COPY --from=builder /app/node_modules ./node_modules COPY --from=builder /app/sources ./sources +COPY --from=builder /app/prisma ./prisma # Expose the port the app will run on EXPOSE 3000 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..9aac1acc --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,98 @@ +version: '3.8' +services: + happy-server: + image: happy-server:latest + ports: + - "3005:3005" + restart: unless-stopped + environment: + - NODE_ENV=production + - DATABASE_URL=postgresql://postgres:postgres@postgres:5432/happy-server + - REDIS_URL=redis://redis:6379 + - SEED=911c5a9950504bd8452ac2e7c8b99af15771f01fdfc93722e32f149cadb6571b + - HANDY_MASTER_SECRET=6a3a767d05bff2865d9a1857c68ae09d54659a3f3a200b2c9e165b1d5b72a91c + - PORT=3005 + - S3_HOST=minio + - S3_PORT=9000 + - S3_USE_SSL=false + - S3_ACCESS_KEY=minioadmin + - S3_SECRET_KEY=minioadmin + - S3_BUCKET=happy-server + - S3_PUBLIC_URL=http://localhost:9000/happy-server + depends_on: + postgres: + condition: service_healthy + redis: + condition: service_started + minio: + condition: service_healthy + migrate: + condition: service_completed_successfully + + migrate: + image: happy-server:latest + environment: + - DATABASE_URL=postgresql://postgres:postgres@postgres:5432/happy-server + depends_on: + postgres: + condition: service_healthy + command: yarn prisma migrate deploy + restart: "no" + + minio: + image: minio/minio:latest + ports: + - "9000:9000" + - "9001:9001" + environment: + - MINIO_ROOT_USER=minioadmin + - MINIO_ROOT_PASSWORD=minioadmin + volumes: + - minio_data:/data + command: server /data --console-address ":9001" + healthcheck: + test: ["CMD", "mc", "ready", "local"] + interval: 30s + timeout: 20s + retries: 3 + + minio-init: + image: minio/mc:latest + depends_on: + minio: + condition: service_healthy + entrypoint: > + /bin/sh -c " + mc alias set myminio http://minio:9000 minioadmin minioadmin; + mc mb -p myminio/happy-server; + mc anonymous set public myminio/happy-server; + exit 0; + " + + postgres: + image: postgres:15 + environment: + - POSTGRES_DB=happy-server + - POSTGRES_USER=postgres + - POSTGRES_PASSWORD=postgres + volumes: + - postgres_data:/var/lib/postgresql/data + ports: + - "5432:5432" + healthcheck: + test: ["CMD-SHELL", "pg_isready -U postgres"] + interval: 5s + timeout: 5s + retries: 5 + + redis: + image: redis:7-alpine + ports: + - "6379:6379" + volumes: + - redis_data:/data + +volumes: + postgres_data: + redis_data: + minio_data: \ No newline at end of file