docker-compose.yml 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. services:
  2. payload:
  3. build:
  4. context: .
  5. dockerfile: Dockerfile
  6. image: hanoman-website-be:latest
  7. restart: unless-stopped
  8. ports:
  9. - "${PAYLOAD_BIND_IP:-127.0.0.1}:${PAYLOAD_PUBLISHED_PORT:-3000}:3000"
  10. # Seed (and local uploads) write files to ./media on the host. The app image has no project
  11. # checkout — without this mount, DB rows point to paths like /app/media/*.png that do not exist.
  12. volumes:
  13. - ./media:/app/media
  14. depends_on:
  15. postgres:
  16. condition: service_healthy
  17. env_file:
  18. - .env
  19. environment:
  20. NODE_ENV: production
  21. DATABASE_URL: ${DATABASE_URL}
  22. # Ensure DATABASE_URL points to this service when running in Docker:
  23. # postgresql://postgres:postgres@postgres:5432/hanoman
  24. postgres:
  25. restart: unless-stopped
  26. image: postgres:16
  27. environment:
  28. POSTGRES_DB: ${POSTGRES_DB}
  29. POSTGRES_USER: ${POSTGRES_USER}
  30. POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
  31. volumes:
  32. - pgdata:/var/lib/postgresql/data
  33. ports:
  34. - "${POSTGRES_BIND_IP:-127.0.0.1}:${POSTGRES_PUBLISHED_PORT:-5432}:5432"
  35. healthcheck:
  36. test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
  37. interval: 10s
  38. timeout: 5s
  39. retries: 5
  40. # One-off DB seeding on the same Docker network as Postgres (hostname "postgres" in DATABASE_URL works).
  41. # Usage: docker compose --profile seed run --rm seed
  42. seed:
  43. profiles:
  44. - seed
  45. image: node:22.17.0-alpine
  46. working_dir: /app
  47. volumes:
  48. - .:/app
  49. env_file:
  50. - .env
  51. environment:
  52. NODE_ENV: development
  53. CI: "true"
  54. depends_on:
  55. postgres:
  56. condition: service_healthy
  57. command:
  58. - sh
  59. - -c
  60. - corepack enable && corepack prepare pnpm@10.33.0 --activate && pnpm install --frozen-lockfile && pnpm seed
  61. volumes:
  62. pgdata: