-
Notifications
You must be signed in to change notification settings - Fork 2
/
docker-compose.yaml
76 lines (72 loc) · 4.06 KB
/
docker-compose.yaml
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
services:
# Local PostgreSQL container (used for local development when needed)
postgres:
image: postgres:17 # Use PostgreSQL version 17
container_name: postgres # Name the container "postgres"
environment:
POSTGRES_USER: ${POSTGRES_USER} # Set PostgreSQL user from environment variable
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} # Set PostgreSQL password from environment variable
POSTGRES_DB: ${POSTGRES_DB} # Set PostgreSQL database name from environment variable
ports:
- "${POSTGRES_PORT}:5432" # Map host port to container's PostgreSQL port
volumes:
- postgres_data:/var/lib/postgresql/data # Persist PostgreSQL data
- ./migration/src/setup.sql:/docker-entrypoint-initdb.d/0-setup.sql # Initialize database with setup.sql
- ./migration/src/refactor_platform_rs.sql:/docker-entrypoint-initdb.d/1-refactor_plaform_rs.sql # Initialize with refactor_platform_rs.sql
- ./migration/src/setup_default_user.sql:/docker-entrypoint-initdb.d/2-setup_default_user.sql # Initialize with setup_default_user.sql
networks:
- backend_network # Connect to backend_network
# Rust application that connects to either local or remote PostgreSQL
rust-app:
image: rust-backend # Use the built image
build:
context: . # Build context is current directory
dockerfile: Dockerfile # Use specified Dockerfile
target: runtime # Use runtime target
platform: ${PLATFORM} # Specify the platform
container_name: ${CONTAINER_NAME} # Name the container, default is "rust-app"
environment:
POSTGRES_USER: ${POSTGRES_USER} # Set PostgreSQL user from environment variable
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} # Set PostgreSQL password from environment variable
POSTGRES_DB: ${POSTGRES_DB} # Set PostgreSQL database name from environment variable
POSTGRES_SCHEMA: ${POSTGRES_SCHEMA} # Set PostgreSQL schema from environment variable
POSTGRES_HOST: postgres # Set PostgreSQL host to "postgres" service
POSTGRES_PORT: ${POSTGRES_PORT} # Set PostgreSQL port from environment variable
DATABASE_URL: postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:${POSTGRES_PORT}/${POSTGRES_DB} # Configure database URL
BACKEND_PORT: ${BACKEND_PORT} # Set service port from environment variable
BACKEND_INTERFACE: ${BACKEND_INTERFACE} # Set service interface from environment variable
BACKEND_ALLOWED_ORIGINS: ${BACKEND_ALLOWED_ORIGINS}
BACKEND_LOG_FILTER_LEVEL: ${BACKEND_LOG_FILTER_LEVEL}
ports:
- "${BACKEND_PORT}:${BACKEND_PORT}" # Map host port to container's service port
depends_on:
- postgres # Ensure postgres service starts before rust-app
networks:
- backend_network # Connect to backend_network
command: ["sh", "-c", "sleep 5 && /usr/local/bin/refactor_platform_rs"] # Wait for Postgres and run the app
nextjs-app:
build:
context: https://github.com/refactor-group/refactor-platform-fe.git#main # change to fs directory to run locally
dockerfile: Dockerfile
target: runner # Use runner target
args:
NEXT_PUBLIC_BACKEND_SERVICE_PROTOCOL: ${BACKEND_SERVICE_PROTOCOL}
NEXT_PUBLIC_BACKEND_SERVICE_PORT: ${BACKEND_PORT}
NEXT_PUBLIC_BACKEND_SERVICE_HOST: ${BACKEND_SERVICE_HOST}
NEXT_PUBLIC_BACKEND_API_VERSION: ${BACKEND_API_VERSION}
FRONTEND_SERVICE_PORT: ${FRONTEND_SERVICE_PORT}
FRONTEND_SERVICE_INTERFACE: ${FRONTEND_SERVICE_INTERFACE}
environment:
NEXT_PUBLIC_BACKEND_SERVICE_PROTOCOL: ${BACKEND_SERVICE_PROTOCOL}
NEXT_PUBLIC_BACKEND_SERVICE_PORT: ${BACKEND_PORT}
NEXT_PUBLIC_BACKEND_SERVICE_HOST: ${BACKEND_SERVICE_HOST}
NEXT_PUBLIC_BACKEND_API_VERSION: ${BACKEND_API_VERSION}
ports:
- "${FRONTEND_SERVICE_PORT}:${FRONTEND_SERVICE_PORT}" # Map host port to frontend container's service port
depends_on:
- rust-app # Ensure postgres service starts before rust-app
networks:
backend_network:
driver: bridge # Use bridge network driver
volumes:
postgres_data: # Define postgres_data volume