|
| 1 | +# ───────────────────────────────────────────────────────────────────────────── |
| 2 | +# OpenBlog — production compose |
| 3 | +# ───────────────────────────────────────────────────────────────────────────── |
| 4 | +# Pulls published images from ghcr.io and runs the full stack. This file |
| 5 | +# is the artifact end users deploy — it is NOT pulled from this git repo; |
| 6 | +# users download it via wget (or have it generated locally by the installer). |
| 7 | +# |
| 8 | +# Direct deployment: |
| 9 | +# 1. wget https://raw.githubusercontent.com/IamCoder18/OpenBlog/main/docker-compose.prod.yaml |
| 10 | +# 2. Replace each `REPLACE_ME_…` placeholder below with a freshly generated |
| 11 | +# secret: |
| 12 | +# POSTGRES_PASSWORD → openssl rand -hex 32 |
| 13 | +# AUTH_SECRET → openssl rand -base64 32 |
| 14 | +# Or just run `./scripts/install.sh` to do the substitution automatically. |
| 15 | +# 3. Edit `BASE_URL` to your real deployment URL. |
| 16 | +# 4. docker compose up -d |
| 17 | +# |
| 18 | +# Image source: |
| 19 | +# postgres → ghcr.io/iamcoder18/openblog:postgres |
| 20 | +# app → ghcr.io/iamcoder18/openblog:latest |
| 21 | +# Pin to a version (e.g. :v0.1.0) for production by editing the `image:` lines. |
| 22 | +# |
| 23 | +# To build from source instead of pulling, use docker-compose.local.yaml. |
| 24 | +# ───────────────────────────────────────────────────────────────────────────── |
| 25 | +# |
| 26 | +# ⚠️ DATABASE NAME IS LOCKED TO `openblog` — DO NOT CHANGE ⚠️ |
| 27 | +# |
| 28 | +# The Postgres service, the OpenBlog application, and the pg_cron extension |
| 29 | +# all hard-code the database name `openblog`. Changing any of the lines |
| 30 | +# below that reference it (POSTGRES_DB, cron.database_name, the /openblog |
| 31 | +# path in DATABASE_URL) will cause one or more of the following failures: |
| 32 | +# |
| 33 | +# • `CREATE EXTENSION pg_cron` refuses with |
| 34 | +# "can only create extension in database postgres" |
| 35 | +# when connected to a differently-named database. |
| 36 | +# • Scheduled-publish migrations (`cron.schedule` calls) target the |
| 37 | +# wrong catalog and silently no-op. |
| 38 | +# • First-time Prisma migrations target a DB that doesn't exist. |
| 39 | +# |
| 40 | +# If you genuinely need a different database name, fork the repo, edit |
| 41 | +# Dockerfile.postgres (POSTGRES_DB + cron.database_name CMD flag), edit |
| 42 | +# the same three lines in BOTH compose files, and rebuild — there is no |
| 43 | +# runtime override. This is intentional: it removes a class of subtle |
| 44 | +# bugs at the cost of flexibility. |
| 45 | +# ───────────────────────────────────────────────────────────────────────────── |
| 46 | + |
| 47 | +services: |
| 48 | + postgres: |
| 49 | + image: ghcr.io/iamcoder18/openblog:postgres |
| 50 | + container_name: openblog-db |
| 51 | + restart: unless-stopped |
| 52 | + environment: |
| 53 | + POSTGRES_USER: postgres |
| 54 | + POSTGRES_PASSWORD: "REPLACE_ME_run_openssl_rand_hex_32" |
| 55 | + POSTGRES_DB: openblog |
| 56 | + command: |
| 57 | + - postgres |
| 58 | + - -c |
| 59 | + - shared_preload_libraries=pg_cron |
| 60 | + - -c |
| 61 | + - cron.database_name=openblog |
| 62 | + - -c |
| 63 | + - cron.use_background_workers=on |
| 64 | + volumes: |
| 65 | + - postgres_data:/var/lib/postgresql/data |
| 66 | + ports: |
| 67 | + - "127.0.0.1:5432:5432" |
| 68 | + healthcheck: |
| 69 | + test: ["CMD-SHELL", "pg_isready -U postgres"] |
| 70 | + interval: 10s |
| 71 | + timeout: 5s |
| 72 | + retries: 5 |
| 73 | + |
| 74 | + app: |
| 75 | + image: ghcr.io/iamcoder18/openblog:latest |
| 76 | + container_name: openblog-app |
| 77 | + restart: unless-stopped |
| 78 | + init: true |
| 79 | + depends_on: |
| 80 | + postgres: |
| 81 | + condition: service_healthy |
| 82 | + ports: |
| 83 | + - "3000:3000" |
| 84 | + environment: |
| 85 | + DATABASE_URL: "postgresql://postgres:REPLACE_ME_run_openssl_rand_hex_32@postgres:5432/openblog?schema=public" |
| 86 | + BASE_URL: "http://localhost:3000" |
| 87 | + BLOG_NAME: "OpenBlog" |
| 88 | + BLOG_DESCRIPTION: "" |
| 89 | + SITE_LOGO_URL: "" |
| 90 | + SITE_CONTACT_EMAIL: "" |
| 91 | + SITE_SOCIAL_URL: "" |
| 92 | + NODE_ENV: production |
| 93 | + PORT: 3000 |
| 94 | + AUTH_SECRET: "REPLACE_ME_run_openssl_rand_base64_32" |
| 95 | + SIGN_UP_ENABLED: "false" |
| 96 | + SMTP_HOST: "" |
| 97 | + SMTP_PORT: "" |
| 98 | + SMTP_SECURE: "" |
| 99 | + SMTP_USER: "" |
| 100 | + SMTP_PASSWORD: "" |
| 101 | + SMTP_FROM: "" |
| 102 | + healthcheck: |
| 103 | + test: |
| 104 | + [ |
| 105 | + "CMD-SHELL", |
| 106 | + "wget -qO- http://127.0.0.1:3000/api/health >/dev/null || exit 1", |
| 107 | + ] |
| 108 | + interval: 30s |
| 109 | + timeout: 5s |
| 110 | + retries: 3 |
| 111 | + start_period: 20s |
| 112 | + |
| 113 | +volumes: |
| 114 | + postgres_data: |
0 commit comments