-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose.yml
185 lines (177 loc) · 5.16 KB
/
docker-compose.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
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# ===========================================
# A recipe to deliver the app via Nginx, PHP 8.1.x and MySQL 8.0.31.
#
# @author Björn Hempel <[email protected]>
# @version 0.1.0 (2023-06-24)
# @since 0.1.0 (2023-06-24) First version.
# ===========================================
# ===========================================
# Start app:
# ----------
# ❯ docker-compose up -d
#
# Show containers:
# ----------------
# ❯ docker container ls
#
# Build images:
# -------------
# ❯ docker-compose build
#
# Show logs:
# ----------------
# ❯ docker-compose logs -f
#
# Login into containers:
# ----------------------
# ❯ docker-compose exec nginx bash
# ❯ docker-compose exec php bash
#
# Open app (local - localhost):
# -----------------
#
# With Traefik proxy:
# - https://www.api-version.localhost/
# - https://www.api-version.localhost/api/v1/docs.html
#
# Without Traefik proxy:
# - https://localhost:44443/
# - https://localhost:44443/api/v1/docs.html
#
# Restart containers:
# -------------------
# ❯ docker-compose restart
#
# Shutdown containers:
# --------------------
# ❯ docker-compose down
#
# Installation:
# -------------
# ❯ docker-compose up -d
# ❯ docker-compose exec php composer install
#
# ===========================================
# Configures the services
services:
# PHP FPM 8.2.1 and apache to serve the app
php:
# @see: https://hub.docker.com/_/php
build:
dockerfile: "${DOCKERFILE_PHP_FPM}"
context: "docker/php"
args:
- IMAGE_ADD=${IMAGE_ADD}
image: "${IMAGE_PHP}:${VERSION_APP_LATEST}"
container_name: "${NAMESPACE_DEVELOPMENT}.php.${PHP_VERSION}"
hostname: "${NAMESPACE_HOSTNAME_DEVELOPMENT}-php-${PHP_VERSION_HOSTNAME}"
restart: always
volumes:
# Server content (development mode)
- .:/var/www/web:delegated
# Exclude folder vendor
- php-data-vendor:/var/www/web/vendor
# Exclude folder var/cache
- php-data-var:/var/www/web/var
# Include cron tasks
- ./docker/php/cron.d/symfony.local:/etc/cron.d/symfony
#user: "www-data:users"
networks:
- network-internal
environment:
# app version
VERSION_APP: "${VERSION_APP}"
# database configuration
ENV_DB_USER: "${POSTGRESQL_SERVER_ROOT_USER}"
ENV_DB_PASS: "${POSTGRESQL_SERVER_ROOT_PASSWORD}"
ENV_DB_HOST: "${POSTGRESQL_SERVER_HOST}"
ENV_DB_PORT: "${POSTGRESQL_SERVER_PORT}"
ENV_DB_NAME: "${POSTGRESQL_SERVER_DB}"
ENV_DB_VERSION: "${POSTGRESQL_SERVER_VERSION}"
ENV_DB_DRIVER: "${POSTGRESQL_SERVER_DRIVER}"
# mail configuration
ENV_MAIL_SERVER_TRANSPORT: "${MAIL_SERVER_TRANSPORT}"
ENV_MAIL_SERVER_HOST: "${MAIL_SERVER_HOST}"
ENV_MAIL_SERVER_PORT: "${MAIL_SERVER_PORT}"
depends_on:
- postgresql
# PostgreSQL 14.7
postgresql:
# @see: https://hub.docker.com/_/php
build:
dockerfile: "${DOCKERFILE_POSTGRESQL}"
context: "docker/postgresql"
args:
- IMAGE_ADD=${IMAGE_ADD}
image: "${IMAGE_POSTGRESQL}"
container_name: "${NAMESPACE_DEVELOPMENT}.postgresql"
hostname: "${NAMESPACE_HOSTNAME_DEVELOPMENT}-postgresql"
shm_size: 2g
restart: always
# command: >
# -c work_mem=4MB
# -c maintenance_work_mem=64kB
# -c max_wal_size=1GB
environment:
POSTGRES_USER: "${POSTGRESQL_SERVER_ROOT_USER}"
POSTGRES_PASSWORD: "${POSTGRESQL_SERVER_ROOT_PASSWORD}"
POSTGRES_DB: "${POSTGRESQL_SERVER_DB}"
volumes:
# Add database data volume
- postgresql-data:/var/lib/postgresql/data:rw
# Mount fixtures
- ./fixtures/db:/fixtures/db
networks:
- network-internal
# Adminer MySQL Client (MySQL + PostgreSQL)
adminer:
# @see: https://hub.docker.com/_/adminer/
build:
dockerfile: "${DOCKERFILE_ADMINER}"
context: "docker/adminer"
args:
- IMAGE_ADD=${IMAGE_ADD}
image: "${IMAGE_ADMINER}:${VERSION_APP_LATEST}"
container_name: "${NAMESPACE_DEVELOPMENT}.adminer"
hostname: "${NAMESPACE_HOSTNAME_DEVELOPMENT}-adminer"
restart: always
environment:
ADMINER_DEFAULT_SERVER: "${NAMESPACE_HOSTNAME_DEVELOPMENT}-postgresql"
ADMINER_DESIGN: "flat"
ADMINER_PLUGINS: "tables-filter tinymce"
networks:
- network-internal
depends_on:
- postgresql
# Maildev
maildev:
image: "maildev/maildev:latest"
container_name: "${NAMESPACE_DEVELOPMENT}.maildev"
hostname: "${NAMESPACE_HOSTNAME_DEVELOPMENT}-maildev"
command: ["--mail-directory=/maildir"]
volumes:
- maildev-data:/maildir
restart: always
networks:
- network-internal
depends_on:
- php
# configure volumes
volumes:
# PHP vendor volume to avoid using local folder
php-data-vendor:
name: "${NAMESPACE_DEVELOPMENT}.php.data.vendor"
# PHP var volume to avoid using local folder
php-data-var:
name: "${NAMESPACE_DEVELOPMENT}.php.data.var"
# Volume to persist the DB data
postgresql-data:
name: "${NAMESPACE_DEVELOPMENT}.postgresql.data"
# Volume to persist the Mail data
maildev-data:
name: "${NAMESPACE_DEVELOPMENT}.maildev.data"
# configure networks
networks:
network-internal:
external: false
name: "${NAMESPACE_HOSTNAME}.network.internal"