-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
144 lines (114 loc) · 4.1 KB
/
docker-compose.yml
File metadata and controls
144 lines (114 loc) · 4.1 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
name: fullstack-infrastructure-blueprint
networks:
leonobitech-net:
name: ${NETWORK_NAME:-leonobitech-net}
driver: bridge
services:
traefik:
image: traefik:latest
container_name: traefik
restart: unless-stopped
security_opt:
- no-new-privileges:true
env_file:
- .env
command:
# Dashboard y /ping (solo en 127.0.0.1:8080)
- --api.dashboard=true
- --api.insecure=false
- --ping=true
- --entrypoints.traefik.address=:8080
# Entrypoints HTTP/HTTPS
- --entrypoints.web.address=:80
- --entrypoints.web.http.redirections.entrypoint.to=websecure
- --entrypoints.web.http.redirections.entrypoint.scheme=https
- --entrypoints.web.http.redirections.entrypoint.permanent=true
- --entrypoints.websecure.address=:443
# Docker provider
- --providers.docker=true
- --providers.docker.exposedbydefault=false
- --providers.docker.network=${NETWORK_NAME:-leonobitech-net}
# File provider (middlewares/tls en dynamic/)
- --providers.file.directory=/etc/traefik/dynamic
- --providers.file.watch=true
# ACME (solo se activará en PROD override con certresolver y storage montado)
- --certificatesresolvers.le.acme.email=${ACME_EMAIL}
- --certificatesresolvers.le.acme.storage=/letsencrypt/acme.json
- --certificatesresolvers.le.acme.httpchallenge=true
- --certificatesresolvers.le.acme.httpchallenge.entrypoint=web
ports:
- "80:80"
- "443:443"
- "127.0.0.1:8080:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./traefik/dynamic/:/etc/traefik/dynamic:ro
# (sin certs ni acme.json aquí; se montan en los overrides)
networks:
- leonobitech-net
healthcheck:
test:
["CMD", "traefik", "healthcheck", "--ping", "--ping.entrypoint=traefik"]
interval: 10s
timeout: 3s
retries: 6
start_period: 10s
labels:
- "traefik.enable=true"
# Router dashboard (neutral: solo TLS true; certresolver va en PROD override)
- "traefik.http.routers.traefik.rule=Host(`${TRAEFIK_DOMAIN}`)"
- "traefik.http.routers.traefik.entrypoints=websecure"
- "traefik.http.routers.traefik.tls=true"
- "traefik.http.routers.traefik.service=api@internal"
# BasicAuth opcional desde .env
- "traefik.http.middlewares.auth-traefik.basicauth.users=${TRAEFIK_AUTH}"
# Middlewares desde archivos dinámicos (deben existir en traefik/dynamic/*.yml)
- "traefik.http.routers.traefik.middlewares=auth-traefik@docker,block-trackers@file,secure-strict@file"
core:
build:
context: ./repositories/core
dockerfile: Dockerfile
image: core:v1.0.0
container_name: core
restart: unless-stopped
read_only: true
tmpfs:
- /tmp
security_opt:
- no-new-privileges:true
env_file:
- ./repositories/core/.env
environment:
- NODE_ENV=${NODE_ENV:-production}
- PORT=${PORT:-8000}
# Expose only to the mesh; Traefik will route inbound traffic.
# If you also want to hit it directly (http://localhost:8000), uncomment ports:
# ports:
# - "8000:8000"
volumes:
- ./repositories/core/keys:/app/keys:ro
networks:
- leonobitech-net
depends_on:
traefik:
condition: service_started
healthcheck:
test:
[
"CMD-SHELL",
"curl -fsS http://localhost:${PORT:-8000}/health || exit 1",
]
interval: 15s
timeout: 3s
retries: 3
start_period: 10s
labels:
- "traefik.enable=true"
# Route: https://api.localhost (or your BACKEND_DOMAIN)
- "traefik.http.routers.core.rule=Host(`${BACKEND_DOMAIN}`)"
- "traefik.http.routers.core.entrypoints=websecure"
- "traefik.http.routers.core.tls=true"
# Middlewares defined in traefik/dynamic (optional; keep or remove as you like)
- "traefik.http.routers.core.middlewares=block-trackers@file,secure-strict@file"
# Tell Traefik which internal port to hit
- "traefik.http.services.core.loadbalancer.server.port=${PORT:-8000}"