Refactor Docker configuration in compose-plesk.yaml to streamline service setup by adding network mode and service links for frontend, backend, database, and cache services.
This commit is contained in:
parent
2dd049fcd4
commit
853a5473b3
@ -1,25 +1,11 @@
|
|||||||
# 🚀 Customer Portal - Plesk Docker Stack
|
# 🚀 Customer Portal - Plesk Docker Stack
|
||||||
# Deploy via: Plesk → Docker → Stacks → Add Stack
|
|
||||||
# Project name: customer-portal
|
|
||||||
#
|
|
||||||
# Instructions for Plesk Deployment:
|
|
||||||
# 1. Build images locally:
|
|
||||||
# docker build -t portal-frontend:latest -f apps/portal/Dockerfile .
|
|
||||||
# docker build -t portal-backend:latest -f apps/bff/Dockerfile .
|
|
||||||
# 2. Upload images through Plesk → Docker → Images → Upload
|
|
||||||
# 3. Create env files in Plesk private dir:
|
|
||||||
# /var/www/vhosts/asolutions.jp/private/env/portal-frontend.env
|
|
||||||
# /var/www/vhosts/asolutions.jp/private/env/portal-backend.env
|
|
||||||
# 4. Copy this file content to Plesk → Docker → Stacks → Add Stack
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
frontend:
|
frontend:
|
||||||
image: portal-frontend:latest
|
image: portal-frontend:latest
|
||||||
container_name: portal-frontend
|
container_name: portal-frontend
|
||||||
# Bind to loopback; Plesk nginx will proxy via Proxy Rules
|
|
||||||
ports:
|
ports:
|
||||||
- "127.0.0.1:3000:3000"
|
- "127.0.0.1:3000:3000"
|
||||||
# Only public, client-safe vars
|
|
||||||
env_file:
|
env_file:
|
||||||
- /var/www/vhosts/asolutions.jp/private/env/portal-frontend.env
|
- /var/www/vhosts/asolutions.jp/private/env/portal-frontend.env
|
||||||
environment:
|
environment:
|
||||||
@ -28,6 +14,11 @@ services:
|
|||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
depends_on:
|
depends_on:
|
||||||
- backend
|
- backend
|
||||||
|
# use built-in bridge; don't let compose create a network
|
||||||
|
network_mode: bridge
|
||||||
|
# allow service-name DNS via legacy links
|
||||||
|
links:
|
||||||
|
- backend
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3000/api/health"]
|
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3000/api/health"]
|
||||||
interval: 30s
|
interval: 30s
|
||||||
@ -38,22 +29,22 @@ services:
|
|||||||
backend:
|
backend:
|
||||||
image: portal-backend:latest
|
image: portal-backend:latest
|
||||||
container_name: portal-backend
|
container_name: portal-backend
|
||||||
# Bind to loopback; Plesk nginx will proxy via Proxy Rules
|
|
||||||
ports:
|
ports:
|
||||||
- "127.0.0.1:4000:4000"
|
- "127.0.0.1:4000:4000"
|
||||||
# Secrets and server-side config only
|
|
||||||
env_file:
|
env_file:
|
||||||
- /var/www/vhosts/asolutions.jp/private/env/portal-backend.env
|
- /var/www/vhosts/asolutions.jp/private/env/portal-backend.env
|
||||||
environment:
|
environment:
|
||||||
- PORT=4000
|
- PORT=4000
|
||||||
volumes:
|
volumes:
|
||||||
# Mount secrets from Plesk private directory
|
|
||||||
- /var/www/vhosts/asolutions.jp/private/secrets:/app/secrets:ro
|
- /var/www/vhosts/asolutions.jp/private/secrets:/app/secrets:ro
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
depends_on:
|
depends_on:
|
||||||
- database
|
- database
|
||||||
- cache
|
- cache
|
||||||
# Wait for DB, run migrations, then start
|
network_mode: bridge
|
||||||
|
links:
|
||||||
|
- database
|
||||||
|
- cache
|
||||||
command: >
|
command: >
|
||||||
sh -c "
|
sh -c "
|
||||||
until nc -z database 5432; do echo 'waiting for db'; sleep 2; done;
|
until nc -z database 5432; do echo 'waiting for db'; sleep 2; done;
|
||||||
@ -69,7 +60,6 @@ services:
|
|||||||
database:
|
database:
|
||||||
image: postgres:17-alpine
|
image: postgres:17-alpine
|
||||||
container_name: portal-database
|
container_name: portal-database
|
||||||
# No public port exposure; internal only
|
|
||||||
env_file:
|
env_file:
|
||||||
- /var/www/vhosts/asolutions.jp/private/env/portal-backend.env
|
- /var/www/vhosts/asolutions.jp/private/env/portal-backend.env
|
||||||
environment:
|
environment:
|
||||||
@ -77,6 +67,7 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- postgres_data:/var/lib/postgresql/data
|
- postgres_data:/var/lib/postgresql/data
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
network_mode: bridge
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD-SHELL", "pg_isready -U portal -d portal_prod"]
|
test: ["CMD-SHELL", "pg_isready -U portal -d portal_prod"]
|
||||||
interval: 10s
|
interval: 10s
|
||||||
@ -87,10 +78,10 @@ services:
|
|||||||
cache:
|
cache:
|
||||||
image: redis:7-alpine
|
image: redis:7-alpine
|
||||||
container_name: portal-cache
|
container_name: portal-cache
|
||||||
# No public port exposure; internal only
|
|
||||||
volumes:
|
volumes:
|
||||||
- redis_data:/data
|
- redis_data:/data
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
network_mode: bridge
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD", "redis-cli", "ping"]
|
test: ["CMD", "redis-cli", "ping"]
|
||||||
interval: 10s
|
interval: 10s
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user