Repository navigation
Expand file tree
/
Copy pathcompose-proxy.yml
More file actions
88 lines (83 loc) · 2.98 KB
/
Copy pathcompose-proxy.yml
File metadata and controls
88 lines (83 loc) · 2.98 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
services:
# Application service with Traefik integration
app:
labels:
- traefik.enable=true # Enable Traefik for this service
- traefik.http.routers.app.rule=PathPrefix(`/restjpa`) # Route all /restjpa/* requests
- traefik.http.services.app.loadbalancer.server.port=80
image: 'restjpa:latest'
build:
context: .
depends_on:
db:
condition: service_healthy # Ensures database is ready before starting
environment:
- DATASOURCE_URL=jdbc:postgresql://db:5432/demo-db
- DATASOURCE_USERNAME=dba
- DATASOURCE_PASSWORD=secret # Should use .env file for secrets
networks:
- frontend # For Traefik communication
- backend # For database communication
restart: unless-stopped # Add restart policy for reliability
# PostgreSQL Database service
db:
image: 'postgres:15.2-alpine'
ports:
- "5432:5432" # Consider removing if external access isn't needed
environment:
- POSTGRES_USER=dba
- POSTGRES_PASSWORD=secret # Should use .env file for secrets
- POSTGRES_DB=demo-db
volumes:
- restjpa-pg-data:/var/lib/postgresql/data # Persistent storage
networks:
- backend
healthcheck:
test: ["CMD-SHELL", "pg_isready -U dba -d demo-db"] # Improved healthcheck
interval: 10s
timeout: 5s
retries: 5
# Traefik reverse proxy service
traefik:
image: 'traefik:v3.3'
ports:
- '10080:80' # HTTP entrypoint
- '10443:443' # HTTPS entrypoint
- '18080:8080' # Traefik dashboard
networks:
- frontend
restart: unless-stopped
command:
- --api.dashboard=true
- --log.level=INFO
#- --log.filepath=/var/log/traefik.log
- --accesslog=true
#- --accesslog.filepath=/var/log/traefik-access.log
- --providers.docker.network=frontend
- --providers.docker.exposedByDefault=false
- --entrypoints.web.address=:80
- --entrypoints.web.http.redirections.entrypoint.to=websecure
- --entryPoints.web.http.redirections.entrypoint.scheme=https
#- --entrypoints.websecure.address=:443
# - --entrypoints.websecure.asDefault=true
#- --entrypoints.websecure.http.tls.certresolver=myresolver
#- --certificatesresolvers.myresolver.acme.tlschallenge=true
#- --certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json
labels:
- traefik.enable=true
- traefik.http.routers.mydashboard.rule=Host(`traefik.example.com`)
- traefik.http.routers.mydashboard.service=api@internal
#- traefik.http.routers.mydashboard.middlewares=myauth
#- traefik.http.middlewares.myauth.basicauth.users=test:$$apr1$$H6uskkkW$$IgXLP6ewTrSuBkTrqE8wj/
depends_on:
- db
- app
volumes:
- '/var/run/docker.sock:/var/run/docker.sock:ro' # Docker socket for auto-discovery
volumes:
restjpa-pg-data:
certifactes:
networks:
frontend:
backend: