-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-compose.production.yml
107 lines (100 loc) · 3.92 KB
/
docker-compose.production.yml
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
# ===========================================
# Overwrites the docker-compose.yml file (Production Mode).
#
# @author Björn Hempel <[email protected]>
# @version 1.0 (2024-01-23)
# ===========================================
# ===========================================
# Start app (Production + Traefik):
# ----------
# ❯ docker-compose -f docker-compose.yml -f docker-compose.production.yml up -d
#
# Show containers:
# ----------------
# ❯ docker container ls
#
# Build images:
# -------------
# ❯ docker-compose -f docker-compose.yml -f docker-compose.production.yml build
#
# Show logs:
# ----------------
# ❯ docker-compose -f docker-compose.yml -f docker-compose.production.yml logs -f
#
# Login into containers:
# ----------------------
# ❯ docker-compose -f docker-compose.yml -f docker-compose.production.yml exec nginx bash
# ❯ docker-compose -f docker-compose.yml -f docker-compose.production.yml exec php bash
#
# Open app (local - localhost):
# -----------------
#
# - https://loc8.place/
#
# Restart containers:
# -------------------
# ❯ docker-compose -f docker-compose.yml -f docker-compose.production.yml restart
#
# Shutdown containers:
# --------------------
# ❯ docker-compose -f docker-compose.yml -f docker-compose.production.yml down
#
# Installation:
# -------------
# ❯ docker-compose -f docker-compose.yml -f docker-compose.production.yml up -d
# ❯ docker-compose -f docker-compose.yml -f docker-compose.production.yml exec php composer install
#
# ===========================================
# Configures the services
services:
# PHP FPM 8.2.1 and apache to serve the app
php:
networks:
- network-internal
- network-traefik
labels:
# enable traefik
- "traefik.enable=true"
# middleware -> https redirect
- "traefik.http.middlewares.${NAMESPACE_UNDERLINE}_https.redirectscheme.scheme=https"
- "traefik.http.middlewares.${NAMESPACE_UNDERLINE}_frame.headers.customFrameOptionsValue=sameorigin"
# middleware -> remove headers
- "traefik.http.middlewares.${NAMESPACE_UNDERLINE}_remove_headers.headers.customResponseHeaders.Server="
- "traefik.http.middlewares.${NAMESPACE_UNDERLINE}_remove_headers.headers.customResponseHeaders.X-Powered-By="
# services (load balancer)
- "traefik.http.services.${NAMESPACE_UNDERLINE}_https_lb.loadbalancer.server.port=${PORT_HTTPS}"
- "traefik.http.services.${NAMESPACE_UNDERLINE}_https_lb.loadbalancer.server.scheme=https"
# http layer -> redirect https
- "traefik.http.routers.${NAMESPACE_UNDERLINE}_http.entrypoints=web"
- "traefik.http.routers.${NAMESPACE_UNDERLINE}_http.rule=Host(`${URL_PRODUCTION}`)"
- "traefik.http.routers.${NAMESPACE_UNDERLINE}_http.middlewares=${NAMESPACE_UNDERLINE}_https"
- "traefik.http.routers.${NAMESPACE_UNDERLINE}_http.service=${NAMESPACE_UNDERLINE}_https_lb"
# https layer
- "traefik.http.routers.${NAMESPACE_UNDERLINE}_https.entrypoints=websecure"
- "traefik.http.routers.${NAMESPACE_UNDERLINE}_https.rule=Host(`${URL_PRODUCTION}`)"
- "traefik.http.routers.${NAMESPACE_UNDERLINE}_https.middlewares=${NAMESPACE_UNDERLINE}_frame,${NAMESPACE_UNDERLINE}_remove_headers"
- "traefik.http.routers.${NAMESPACE_UNDERLINE}_https.service=${NAMESPACE_UNDERLINE}_https_lb"
- "traefik.http.routers.${NAMESPACE_UNDERLINE}_https.tls=true"
- "traefik.http.routers.${NAMESPACE_UNDERLINE}_https.tls.certresolver=letsencryptresolver"
# network
- "traefik.docker.network=${NETWORK_NAME_TRAEFIK_PUBLIC_PRODUCTION}"
# PostgreSQL 14.7
postgresql:
networks:
- network-internal
# Adminer MySQL Client
adminer:
networks:
- network-internal
# Maildev
maildev:
networks:
- network-internal
# configure networks
networks:
network-traefik:
external: true
name: "${NETWORK_NAME_TRAEFIK_PUBLIC_PRODUCTION}"
network-internal:
external: false
name: "${NAMESPACE_HOSTNAME}.network.internal"