File size: 9,812 Bytes
7a4e1c5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
# =============================================
# STREAMCORE DOCKER COMPOSE
# =============================================
#
# DEPLOYMENT OPTIONS:
#
# β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
# β”‚  OPTION 1: Development / Local Testing (NO SSL, NO NGINX)          β”‚
# β”‚                                                                     β”‚
# β”‚    docker compose up -d --build                                     β”‚
# β”‚                                                                     β”‚
# β”‚    Access:                                                          β”‚
# β”‚    - Frontend: http://localhost:5000                                β”‚
# β”‚    - Backend:  http://localhost:3000                                β”‚
# β”‚    - Database: localhost:5433 (mapped to container 5432)            β”‚
# β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
#
# β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
# β”‚  OPTION 2: Production with SSL (NGINX + Let's Encrypt)             β”‚
# β”‚                                                                     β”‚
# β”‚    1. Set your domains:                                             β”‚
# β”‚       export FRONTEND_DOMAIN=yourdomain.com                         β”‚
# β”‚       export BACKEND_DOMAIN=api.yourdomain.com                      β”‚
# β”‚       export LETSENCRYPT_EMAIL=admin@yourdomain.com                 β”‚
# β”‚                                                                     β”‚
# β”‚    2. Update PUBLIC_BASE_URL and NEXT_PUBLIC_API_URL below          β”‚
# β”‚                                                                     β”‚
# β”‚    3. Run with proxy profile:                                       β”‚
# β”‚       docker compose --profile proxy up -d --build                  β”‚
# β”‚                                                                     β”‚
# β”‚    Access:                                                          β”‚
# β”‚    - Frontend: https://yourdomain.com                               β”‚
# β”‚    - Backend:  https://api.yourdomain.com                           β”‚
# β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
#
# β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
# β”‚  OPTION 3: Your Own Reverse Proxy (Nginx, Traefik, Caddy, etc.)    β”‚
# β”‚                                                                     β”‚
# β”‚    docker compose up -d --build                                     β”‚
# β”‚                                                                     β”‚
# β”‚    Then configure your own proxy to forward:                        β”‚
# β”‚    - yourdomain.com       -> localhost:5000                         β”‚
# β”‚    - api.yourdomain.com   -> localhost:3000                         β”‚
# β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
#
# NOTE: The nginx-proxy services are ONLY started when you use --profile proxy.
#       You don't need to delete or comment anything for Options 1 or 3.
#
# CONFIGURATION: Edit the values marked with βš™οΈ EDIT below
#
# =============================================

services:
  # =============================================
  # POSTGRESQL DATABASE
  # =============================================
  postgres:
    image: postgres:16
    container_name: streamcore-postgres
    restart: unless-stopped
    environment:
      # βš™οΈ EDIT: Database credentials
      POSTGRES_USER: streamcore
      POSTGRES_PASSWORD: StreamCore_DB_2024_Production!
      POSTGRES_DB: streamcore
    volumes:
      - postgres-data:/var/lib/postgresql/data
    ports:
      - "5433:5432"
    networks:
      - streamcore-network
    healthcheck:
      test: [ "CMD-SHELL", "pg_isready -U streamcore -d streamcore" ]
      interval: 5s
      timeout: 5s
      retries: 10
      start_period: 10s

  # =============================================
  # BACKEND API (Rust/Axum)
  # =============================================
  backend:
    build:
      context: ./backend
    container_name: streamcore-backend
    restart: unless-stopped
    environment:
      # Server
      SERVER_ADDRESS: "0.0.0.0:3000"

      # βš™οΈ EDIT: Must match postgres credentials above
      DATABASE_URL: "postgres://streamcore:StreamCore_DB_2024_Production!@postgres:5432/streamcore"

      # βš™οΈ EDIT: URLs (change to your domains for production)
      PUBLIC_BASE_URL: "https://apistreamcore.syruum.com"
      CORS_ALLOWED_ORIGINS: "https://streamcore.syruum.com,https://apistreamcore.syruum.com,http://localhost:5000,http://localhost:3000"

      # βš™οΈ EDIT: Security - CHANGE THESE IN PRODUCTION!
      JWT_SECRET: "${JWT_SECRET:-ae85a308c80be3b2006da9126620c5fbc2ceadeadbe9c8e9040e9ad0c5d362c8}"
      ADMIN_DEFAULT_PASSWORD: "${ADMIN_DEFAULT_PASSWORD:-22333265}"

      # βš™οΈ EDIT: Stripe (optional - for reseller payments)
      STRIPE_SECRET_KEY: "sk_test_placeholder"
      STRIPE_WEBHOOK_SECRET: "whsec_placeholder"
      STRIPE_CURRENCY: "usd"
      STRIPE_SUCCESS_URL: "https://streamcore.syruum.com/credits/success"
      STRIPE_CANCEL_URL: "https://streamcore.syruum.com/credits/cancel"

      # Backup Configuration
      BACKUP_ENABLED: "true"
      BACKUP_DIR: "/data/backups"
      BACKUP_RETENTION_DAYS: "30"
      BACKUP_INTERVAL_HOURS: "24"

      # App Config
      CONTENT_OVERVIEW_MULTIPLIER: "x1"
      SKIP_MIGRATIONS: "false"
      RUST_LOG: "iptv_backend=info,tower_http=warn,sqlx=warn"
      DEBUG_MODE: "false"

      # Nginx Proxy config (used when profile=proxy)
      # βš™οΈ EDIT: Change to your backend domain
      VIRTUAL_HOST: "apistreamcore.syruum.com"
      VIRTUAL_PORT: "3000"
      LETSENCRYPT_HOST: "apistreamcore.syruum.com"
      LETSENCRYPT_EMAIL: "admin@syruum.com"
    volumes:
      - backend-data:/data
      - /media:/media
    ports:
      - "3000:3000"
    networks:
      - streamcore-network
    depends_on:
      postgres:
        condition: service_healthy

  # =============================================
  # FRONTEND WEB APP (Next.js)
  # =============================================
  frontend:
    build:
      context: ./frontend
      args:
        # βš™οΈ EDIT: Your app name
        APP_NAME: "StreamCore"
        # βš™οΈ EDIT: CRITICAL - Must be set at build time for client-side code
        NEXT_PUBLIC_API_URL: "https://apistreamcore.syruum.com"
    container_name: streamcore-frontend
    restart: unless-stopped
    environment:
      # API URLs
      INTERNAL_API_URL: "http://backend:3000"
      # βš™οΈ EDIT: Change to your backend domain for production
      NEXT_PUBLIC_API_URL: "https://apistreamcore.syruum.com"
      NEXT_PUBLIC_APP_NAME: "StreamCore"

      # Proxy settings
      STREAMCORE_PROXY_ALLOWED_HOSTS: "*"
      STREAMCORE_PROXY_REQUIRE_AUTH: "false"
      STREAMCORE_PROXY_ALLOW_PRIVATE: "true"

      # Nginx Proxy config (used when profile=proxy)
      # βš™οΈ EDIT: Change to your frontend domain
      VIRTUAL_HOST: "streamcore.syruum.com"
      VIRTUAL_PORT: "5000"
      LETSENCRYPT_HOST: "streamcore.syruum.com"
      LETSENCRYPT_EMAIL: "admin@syruum.com"
    depends_on:
      - backend
    ports:
      - "5000:5000"
    networks:
      - streamcore-network

  # =============================================
  # NGINX REVERSE PROXY (Production with SSL)
  # =============================================
  # Automatically generates SSL certificates via Let's Encrypt
  # Enable with: docker compose --profile proxy up -d --build
  #
  # Required environment variables (set in .env or export):
  #   FRONTEND_DOMAIN=yourdomain.com
  #   BACKEND_DOMAIN=api.yourdomain.com
  #   LETSENCRYPT_EMAIL=admin@yourdomain.com
  #
  nginx-proxy:
    image: nginxproxy/nginx-proxy:1.4
    container_name: nginx-proxy
    restart: always
    profiles:
      - proxy
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - /var/run/docker.sock:/tmp/docker.sock:ro
      - nginx-certs:/etc/nginx/certs:ro
      - nginx-vhost:/etc/nginx/vhost.d
      - nginx-html:/usr/share/nginx/html
      - ./nginx/custom.conf:/etc/nginx/conf.d/custom.conf:ro
    networks:
      - streamcore-network

  acme-companion:
    image: nginxproxy/acme-companion:2.2
    container_name: acme-companion
    restart: always
    profiles:
      - proxy
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - nginx-certs:/etc/nginx/certs:rw
      - nginx-vhost:/etc/nginx/vhost.d
      - nginx-html:/usr/share/nginx/html
      - acme-state:/etc/acme.sh
    environment:
      # βš™οΈ EDIT: Your email for Let's Encrypt notifications
      DEFAULT_EMAIL: "admin@syruum.com"
      NGINX_PROXY_CONTAINER: nginx-proxy
    depends_on:
      - nginx-proxy
    networks:
      - streamcore-network

networks:
  streamcore-network:
    driver: bridge

volumes:
  backend-data:
  postgres-data:
  nginx-certs:
  nginx-vhost:
  nginx-html:
  acme-state: