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:
T. Narantuya 2025-09-01 15:50:53 +09:00
parent 2dd049fcd4
commit 853a5473b3

View File

@ -1,25 +1,11 @@
# 🚀 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:
frontend:
image: portal-frontend:latest
container_name: portal-frontend
# Bind to loopback; Plesk nginx will proxy via Proxy Rules
ports:
- "127.0.0.1:3000:3000"
# Only public, client-safe vars
env_file:
- /var/www/vhosts/asolutions.jp/private/env/portal-frontend.env
environment:
@ -28,6 +14,11 @@ services:
restart: unless-stopped
depends_on:
- 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:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3000/api/health"]
interval: 30s
@ -38,22 +29,22 @@ services:
backend:
image: portal-backend:latest
container_name: portal-backend
# Bind to loopback; Plesk nginx will proxy via Proxy Rules
ports:
- "127.0.0.1:4000:4000"
# Secrets and server-side config only
env_file:
- /var/www/vhosts/asolutions.jp/private/env/portal-backend.env
environment:
- PORT=4000
volumes:
# Mount secrets from Plesk private directory
- /var/www/vhosts/asolutions.jp/private/secrets:/app/secrets:ro
restart: unless-stopped
depends_on:
- database
- cache
# Wait for DB, run migrations, then start
network_mode: bridge
links:
- database
- cache
command: >
sh -c "
until nc -z database 5432; do echo 'waiting for db'; sleep 2; done;
@ -69,7 +60,6 @@ services:
database:
image: postgres:17-alpine
container_name: portal-database
# No public port exposure; internal only
env_file:
- /var/www/vhosts/asolutions.jp/private/env/portal-backend.env
environment:
@ -77,6 +67,7 @@ services:
volumes:
- postgres_data:/var/lib/postgresql/data
restart: unless-stopped
network_mode: bridge
healthcheck:
test: ["CMD-SHELL", "pg_isready -U portal -d portal_prod"]
interval: 10s
@ -87,10 +78,10 @@ services:
cache:
image: redis:7-alpine
container_name: portal-cache
# No public port exposure; internal only
volumes:
- redis_data:/data
restart: unless-stopped
network_mode: bridge
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s