|
| 1 | +version: '3.8' |
1 | 2 | services:
|
2 | 3 | # Local PostgreSQL container (used for local development when needed)
|
3 |
| - postgres: |
4 |
| - image: postgres:17 # Use PostgreSQL version 17 |
5 |
| - container_name: postgres # Name the container "postgres" |
6 |
| - environment: |
7 |
| - POSTGRES_USER: ${POSTGRES_USER} # Set PostgreSQL user from environment variable |
8 |
| - POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} # Set PostgreSQL password from environment variable |
9 |
| - POSTGRES_DB: ${POSTGRES_DB} # Set PostgreSQL database name from environment variable |
| 4 | + db: |
| 5 | + image: postgres:latest # Use latest PostgreSQL version |
| 6 | + env_file: |
| 7 | + - ${ENV_FILE:-.env.local} # Override by setting ENV_FILE; defaults to .env.local |
10 | 8 | ports:
|
11 |
| - - "${POSTGRES_PORT}:5432" # Map host port to container's PostgreSQL port |
| 9 | + - "${DB_PORT:-5432}:5432" # Map host port from .env variable to container's PostgreSQL port |
12 | 10 | volumes:
|
13 |
| - - postgres_data:/var/lib/postgresql/data # Persist PostgreSQL data |
| 11 | + - db_data:/var/lib/postgresql/data # Persist PostgreSQL data |
14 | 12 | - ./migration/src/setup.sql:/docker-entrypoint-initdb.d/0-setup.sql # Initialize database with setup.sql
|
15 |
| - - ./migration/src/refactor_platform_rs.sql:/docker-entrypoint-initdb.d/1-refactor_plaform_rs.sql # Initialize with refactor_platform_rs.sql |
| 13 | + - ./migration/src/refactor_platform_rs.sql:/docker-entrypoint-initdb.d/1-refactor_platform_rs.sql # Initialize with refactor_platform_rs.sql |
16 | 14 | - ./migration/src/setup_default_user.sql:/docker-entrypoint-initdb.d/2-setup_default_user.sql # Initialize with setup_default_user.sql
|
17 | 15 | networks:
|
18 | 16 | - backend_network # Connect to backend_network
|
19 | 17 |
|
20 | 18 | # Rust application that connects to either local or remote PostgreSQL
|
21 |
| - rust-app: |
22 |
| - image: rust-backend # Use the built image |
| 19 | + backend: |
23 | 20 | build:
|
24 | 21 | context: . # Build context is current directory
|
25 | 22 | dockerfile: Dockerfile # Use specified Dockerfile
|
26 |
| - target: runtime # Use runtime target |
27 |
| - platform: ${PLATFORM} # Specify the platform |
28 |
| - container_name: ${CONTAINER_NAME} # Name the container, default is "rust-app" |
29 |
| - environment: |
30 |
| - POSTGRES_USER: ${POSTGRES_USER} # Set PostgreSQL user from environment variable |
31 |
| - POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} # Set PostgreSQL password from environment variable |
32 |
| - POSTGRES_DB: ${POSTGRES_DB} # Set PostgreSQL database name from environment variable |
33 |
| - POSTGRES_SCHEMA: ${POSTGRES_SCHEMA} # Set PostgreSQL schema from environment variable |
34 |
| - POSTGRES_HOST: postgres # Set PostgreSQL host to "postgres" service |
35 |
| - POSTGRES_PORT: ${POSTGRES_PORT} # Set PostgreSQL port from environment variable |
36 |
| - DATABASE_URL: postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:${POSTGRES_PORT}/${POSTGRES_DB} # Configure database URL |
37 |
| - BACKEND_PORT: ${BACKEND_PORT} # Set service port from environment variable |
38 |
| - BACKEND_INTERFACE: ${BACKEND_INTERFACE} # Set service interface from environment variable |
39 |
| - BACKEND_ALLOWED_ORIGINS: ${BACKEND_ALLOWED_ORIGINS} |
40 |
| - BACKEND_LOG_FILTER_LEVEL: ${BACKEND_LOG_FILTER_LEVEL} |
| 23 | + env_file: |
| 24 | + - ${ENV_FILE:-.env.local} # Same override capability |
41 | 25 | ports:
|
42 | 26 | - "${BACKEND_PORT}:${BACKEND_PORT}" # Map host port to container's service port
|
43 | 27 | depends_on:
|
44 |
| - - postgres # Ensure postgres service starts before rust-app |
| 28 | + - db # Ensure db service starts before backend |
45 | 29 | networks:
|
46 | 30 | - backend_network # Connect to backend_network
|
47 | 31 | command: ["sh", "-c", "sleep 5 && /usr/local/bin/refactor_platform_rs"] # Wait for Postgres and run the app
|
48 | 32 |
|
49 |
| - nextjs-app: |
| 33 | + frontend: |
50 | 34 | build:
|
51 |
| - context: https://github.com/refactor-group/refactor-platform-fe.git#main # change to fs directory to run locally |
| 35 | + context: . |
52 | 36 | dockerfile: Dockerfile
|
53 |
| - target: runner # Use runner target |
54 |
| - args: |
55 |
| - NEXT_PUBLIC_BACKEND_SERVICE_PROTOCOL: ${BACKEND_SERVICE_PROTOCOL} |
56 |
| - NEXT_PUBLIC_BACKEND_SERVICE_PORT: ${BACKEND_PORT} |
57 |
| - NEXT_PUBLIC_BACKEND_SERVICE_HOST: ${BACKEND_SERVICE_HOST} |
58 |
| - NEXT_PUBLIC_BACKEND_API_VERSION: ${BACKEND_API_VERSION} |
59 |
| - FRONTEND_SERVICE_PORT: ${FRONTEND_SERVICE_PORT} |
60 |
| - FRONTEND_SERVICE_INTERFACE: ${FRONTEND_SERVICE_INTERFACE} |
61 |
| - environment: |
62 |
| - NEXT_PUBLIC_BACKEND_SERVICE_PROTOCOL: ${BACKEND_SERVICE_PROTOCOL} |
63 |
| - NEXT_PUBLIC_BACKEND_SERVICE_PORT: ${BACKEND_PORT} |
64 |
| - NEXT_PUBLIC_BACKEND_SERVICE_HOST: ${BACKEND_SERVICE_HOST} |
65 |
| - NEXT_PUBLIC_BACKEND_API_VERSION: ${BACKEND_API_VERSION} |
| 37 | + env_file: |
| 38 | + - ${ENV_FILE:-.env.local} |
66 | 39 | ports:
|
67 |
| - - "${FRONTEND_SERVICE_PORT}:${FRONTEND_SERVICE_PORT}" # Map host port to frontend container's service port |
| 40 | + - "${FRONTEND_PORT}:${FRONTEND_PORT}" # Map a different host port to distinguish frontend |
68 | 41 | depends_on:
|
69 |
| - - rust-app # Ensure postgres service starts before rust-app |
| 42 | + - backend |
| 43 | + # Override command to run the frontend binary instead of the backend binary |
| 44 | + command: ["sh", "-c", "sleep 5 && /usr/local/bin/refactor_platform_rs"] |
70 | 45 |
|
71 | 46 | networks:
|
72 | 47 | backend_network:
|
73 | 48 | driver: bridge # Use bridge network driver
|
74 | 49 |
|
75 | 50 | volumes:
|
76 |
| - postgres_data: # Define postgres_data volume |
| 51 | + db_data: # Define db_data volume |
0 commit comments