-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
58 lines (53 loc) · 1.94 KB
/
Copy pathdocker-compose.yml
File metadata and controls
58 lines (53 loc) · 1.94 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
52
53
54
55
56
57
58
version: "3.8" # Specify Docker Compose version
services:
# Web API service
webapi:
build:
context: ./app/api
dockerfile: Dockerfile
ports:
- "8080:8080" # Expose port 80 of the container to port 8080 of the host
depends_on:
- postgres # Wait for Postgres to be ready before starting webapi
- redis # Wait for Redis to be ready before starting webapi
networks:
- my-app-net # Connect webapi to the custom network
# Postgres database
postgres:
image: postgres:alpine3.20 # Use the official Postgres image with Alpine 3.20 base
environment:
POSTGRES_PASSWORD: test123 # Set the Postgres password (matches your appsettings.json)
POSTGRES_USER: postgres # Set the Postgres username (matches your appsettings.json)
POSTGRES_DB: pstest # Set the Postgres database name (matches your appsettings.json)
volumes:
- postgres-data:/var/lib/postgresql/data # Persist Postgres data volume
networks:
- my-app-net # Connect Postgres to the custom network
# Redis server
redis:
image: redis:latest # Use the official latest Redis image
volumes:
- redis-data:/data # Persist Redis data volume
networks:
- my-app-net # Connect Redis to the custom network
# Frontend service
frontend:
build:
context: ./app/frontend
dockerfile: Dockerfile
ports:
- "3000:8080" # Expose port 80 of the container to port 3000 of the host
volumes:
- ./app/frontend:/app # Mount the frontend source code directory
- /app/node_modules # Ensure node_modules is not overwritten
command: npm run serve # Use the serve command for hot reload
networks:
- my-app-net # Connect frontend to the custom network
# Define a custom network for the application
networks:
my-app-net:
external: false # Create a new internal network
volumes:
# Define volumes for persistent data
postgres-data: {}
redis-data: {}