forked from YoanWaza/SpaceFly
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
51 lines (48 loc) · 1.91 KB
/
docker-compose.yml
File metadata and controls
51 lines (48 loc) · 1.91 KB
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
services:
backend:
build:
context: ./backend # Specify the backend directory for the Docker build context.
# environment:
# - PORT=5001
# - DB_HOST=db
# - DB_USER=postgres
# - DB_PASSWORD=postgres
# - DB_NAME=flightdb
# - DB_PORT=5432
environment:
- PORT=${PORT} # Port on which the backend server will run.
- DB_HOST=${DB_HOST} # Hostname for the database container.
- DB_USER=${DB_USER} # Database username.
- DB_PASSWORD=${DB_PASSWORD} # Database password.
- DB_NAME=${DB_NAME} # Name of the database to connect to.
- DB_PORT=${DB_PORT} # Port number for the database.
ports:
- "5001:5001" # Map port 5001 of the container to port 5001 on the host machine.
depends_on:
db:
condition: service_healthy # Wait for the database container to be healthy before starting.
db:
image: postgres:13
environment:
POSTGRES_USER: postgres # Set the default database username.
POSTGRES_PASSWORD: postgres # Set the default database password.
POSTGRES_DB: flightdb # Create a database named "flightdb".
volumes:
- pgdata:/var/lib/postgresql/data # Persistent storage for database data.
- ./db/init.sql:/docker-entrypoint-initdb.d/init.sql # Initialize the database with this SQL script.
ports:
- "5434:5432" # Map port 5432 of the container to port 5434 on the host machine.
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"] # Check if the database is ready to accept connections.
interval: 5s
timeout: 5s
retries: 5
frontend:
build:
context: ./frontend
ports:
- "3000:3000"
environment:
- REACT_APP_BACKEND_URL=http://localhost:5001 # URL for the frontend to reach the backend
volumes:
pgdata: # Persistent volume for PostgreSQL data.