-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
129 lines (120 loc) · 3.96 KB
/
docker-compose.yml
File metadata and controls
129 lines (120 loc) · 3.96 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# =================================================================
# Docker Compose - Development Environment
# =================================================================
# This compose file sets up a complete development environment with:
# - API application container
# - SQL Server database container
# - Seq log server container (optional)
# =================================================================
version: '3.8'
services:
# =================================================================
# API Application
# =================================================================
api:
build:
context: .
dockerfile: Dockerfile
container_name: dotnet-api-template
ports:
- "8080:8080"
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=http://+:8080
- ConnectionStrings__DefaultConnection=Server=sqlserver;Database=DotNetCoreAPITemplateDb;User Id=sa;Password=YourStrong@Password;TrustServerCertificate=true;MultipleActiveResultSets=true
- CorsSettings__AllowedOrigins__0=http://localhost:3000
- CorsSettings__AllowedOrigins__1=https://localhost:3000
- CorsSettings__AllowCredentials=true
- Serilog__WriteTo__0__Args__serverUrl=http://seq:5341
depends_on:
sqlserver:
condition: service_healthy
networks:
- app-network
volumes:
- ./logs:/app/logs
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/health/live"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
# =================================================================
# SQL Server Database
# =================================================================
sqlserver:
image: mcr.microsoft.com/mssql/server:2022-latest
container_name: sqlserver-db
ports:
- "1433:1433"
environment:
- ACCEPT_EULA=Y
- SA_PASSWORD=YourStrong@Password
- MSSQL_PID=Developer
volumes:
- sqlserver-data:/var/opt/mssql
- ./scripts/db-init:/docker-entrypoint-initdb.d:ro
networks:
- app-network
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P YourStrong@Password -Q 'SELECT 1'"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
# =================================================================
# Seq Log Server (Optional - for structured log viewing)
# =================================================================
seq:
image: datalust/seq:latest
container_name: seq-logs
ports:
- "5341:80"
environment:
- ACCEPT_EULA=Y
- SEQ_FIRSTRUN_ADMINPASSWORDHASH=# Run this to get hash: echo 'admin' | docker run --rm -i datalust/seq config hash
volumes:
- seq-data:/data
networks:
- app-network
restart: unless-stopped
profiles:
- logging
# =================================================================
# Redis Cache (Optional - for future caching needs)
# =================================================================
redis:
image: redis:7-alpine
container_name: redis-cache
ports:
- "6379:6379"
command: redis-server --appendonly yes --maxmemory 256mb --maxmemory-policy allkeys-lru
volumes:
- redis-data:/data
networks:
- app-network
restart: unless-stopped
profiles:
- cache
# =================================================================
# Networks
# =================================================================
networks:
app-network:
driver: bridge
name: dotnet-api-network
# =================================================================
# Volumes
# =================================================================
volumes:
sqlserver-data:
driver: local
name: dotnet-api-sqlserver-data
seq-data:
driver: local
name: dotnet-api-seq-data
redis-data:
driver: local
name: dotnet-api-redis-data