Skip to content

Commit 46c2fe2

Browse files
committed
Add new docker setup with PHP 8.2, Apache 2.4, Cron and Supervisord
1 parent d38cf0e commit 46c2fe2

40 files changed

+1952
-440
lines changed

.env

Lines changed: 92 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,11 @@ IMAGE_APP=ixnode/php-api-version/${IMAGE_ADD}app
3636
# Namespace of app image (development)
3737
IMAGE_PHP=ixnode/php-api-version/${IMAGE_ADD}php
3838

39-
# Namespace of nginx image
40-
IMAGE_NGINX=ixnode/php-api-version/${IMAGE_ADD}nginx
39+
# Namesapce of PostgreSQL image
40+
IMAGE_POSTGRESQL=postgres:14.7-alpine
4141

42-
# Namespace of mysql image
43-
IMAGE_MYSQL=${IMAGE_ADD}mysql:8.0.31
44-
45-
IMAGE_ADMINER=${IMAGE_ADD}adminer:4.8.1
42+
# Namespace of adminer image (development)
43+
IMAGE_ADMINER=ixnode/php-api-version/${IMAGE_ADD}adminer
4644

4745
# The general URL of this project
4846
URL_PRODUCTION=php-api-version-bundle.ixnode.de
@@ -75,105 +73,117 @@ NETWORK_NAME_TRAEFIK_PUBLIC_LOCAL=traefik
7573
# Traefik network name (public)
7674
NETWORK_NAME_TRAEFIK_PUBLIC_PRODUCTION=traefik-public
7775

78-
# https port (is usually not changed)
76+
# HTTP ports
7977
PORT_HTTP=80
80-
81-
# https port (is usually not changed)
82-
PORT_HTTPS=443
83-
84-
# Internal docker adminer http port (is usually not changed)
85-
PORT_MYSQL_INTERNAL=3306
86-
87-
# Internal docker adminer http port (is usually not changed)
88-
PORT_HTTP_ADMINER_INTERNAL=8080
89-
90-
# Internal docker mailhog http port (is usually not changed)
91-
PORT_HTTP_MAILHOG_INTERNAL=8025
92-
93-
# Internal docker mailhog smtp port (is usually not changed)
94-
PORT_SMTP_MAILHOG_INTERNAL=1025
95-
96-
# Expose api https port (To bypass the Traefik proxy or if it is not installed)
9778
PORT_HTTP_APP_EXPOSE=5080
9879

99-
# Expose api https port (To bypass the Traefik proxy or if it is not installed)
80+
# HTTPS ports
81+
PORT_HTTPS=443
10082
PORT_HTTPS_APP_EXPOSE=5043
10183

102-
# Expose db (mysql) port (External db app)
103-
# Attention for PORT_DB_MAIN_EXPOSE: Please also make changes to the DOCTRINE_DB_PORT variable.
104-
PORT_DB_MAIN_EXPOSE=5006
84+
# Adminer HTTP ports
85+
PORT_HTTP_ADMINER_INTERNAL=8080
86+
PORT_HTTP_ADMINER_EXPOSE=5081
10587

106-
# Expose db (mysql) port (External db app)
107-
PORT_DB_TEST_EXPOSE=5007
88+
# Maildev HTTP ports
89+
PORT_HTTP_MAILDEV_INTERNAL=1080
90+
PORT_HTTP_MAILDEV_EXPOSE=5082
10891

109-
# Expose adminer http port (To bypass the Traefik proxy or if it is not installed)
110-
PORT_HTTP_ADMINER_EXPOSE=5081
92+
# Maildev SMTP ports
93+
PORT_SMTP_MAILDEV_INTERNAL=1025
94+
PORT_SMTP_MAILDEV_EXPOSE=5025
11195

112-
# Expose mailhog http port (To bypass the Traefik proxy or if it is not installed)
113-
PORT_HTTP_MAILHOG_EXPOSE=5082
96+
# PostgreSQL ports
97+
PORT_POSTGRESQL_INTERNAL=5432
98+
PORT_POSTGRESQL_EXPOSE=5032
11499

115-
# Expose mailhog smtp port (To bypass the Traefik proxy or if it is not installed)
116-
PORT_SMTP_MAILHOG_EXPOSE=5025
100+
# Supervisord ports
101+
PORT_SUPERVISORD_INTERNAL=9001
102+
PORT_SUPERVISORD_EXPOSE=5001
117103

118104
###< General Config / Docker Compose Settings ###
119105

120106
###> symfony/framework-bundle ###
121107
APP_ENV=prod
122108
APP_DEBUG=0
123109
APP_SECRET=3b337448a0100c94f60efc26437e0a57
110+
APP_PATH_MIGRATION=migrations/postgresql
111+
# see config/packages/doctrine.yaml: postgresql, sqlite
112+
DEFAULT_DB_DRIVER=postgresql
113+
DEFAULT_DB_TEST_DRIVER=sqlite
124114
###< symfony/framework-bundle ###
125115

126-
###> PHP Configuration ###
127-
DOCKERFILE_PHP_FPM=php-fpm.dockerfile
128-
DOCKERFILE_NGINX=nginx.dockerfile
129-
PHP_VERSION=8.1.11
130-
PHP_VERSION_HOSTNAME=8-1-11
131-
###< PHP Configuration ###
132-
133-
###> Docker Configuration: MySQL secrets and configurations
134-
MYSQL_SERVER_HOST=127.0.0.1
135-
MYSQL_SERVER_ROOT_USER=root
136-
MYSQL_SERVER_ROOT_PASSWORD=secret-pass
137-
MYSQL_SERVER_DB=pavb
138-
MYSQL_SERVER_DB_TEST=pavb-test
139-
MYSQL_SERVER_PORT=${PORT_MYSQL_INTERNAL}
140-
MYSQL_SERVER_VERSION=8.0
141-
MYSQL_SERVER_DRIVER=pdo_mysql
142-
###< Docker Configuration: MySQL secrets and configurations
143-
144-
###> Docker Configuration: Mail secrets and configurations
145-
MAIL_SERVER_TRANSPORT=smtp
146-
MAIL_SERVER_HOST=localhost
147-
#MAIL_SERVER_HOST=${NAMESPACE_HOSTNAME_DEVELOPMENT}-mailhog
148-
MAIL_SERVER_PORT=1025
149-
###< Docker Configuration: Mail secrets and configurations
150-
151-
##> doctrine/doctrine-bundle (mysql) ###
152-
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
153-
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
154-
DOCTRINE_DB_DRIVER=${MYSQL_SERVER_DRIVER}
155-
DOCTRINE_DB_VERSION=${MYSQL_SERVER_VERSION}
156-
DOCTRINE_DB_PATH=
157-
DOCTRINE_DB_NAME=${MYSQL_SERVER_DB}
158-
DOCTRINE_DB_HOST=${ENV_DB_HOST:-127.0.0.1}
159-
# Workaround for default port for DOCTRINE_DB_PORT: Because ${ENV_DB_PORT:-${PORT_DB_MAIN_EXPOSE}} does not work
160-
DOCTRINE_DB_PORT=${ENV_DB_PORT:-5006}
161-
DOCTRINE_DB_USER=${MYSQL_SERVER_ROOT_USER}
162-
DOCTRINE_DB_PASS=${MYSQL_SERVER_ROOT_PASSWORD}
163-
DOCTRINE_DB_SSL_CA=
164-
DOCTRINE_DB_SSL_VERIFY_SERVER_CERT=false
165-
DOCTRINE_DB_INIT_COMMAND="SET NAMES utf8"
166-
###< doctrine/doctrine-bundle (mysql) ###
167-
168116
###> own variables ###
169117
PROJECT_NAME="PHP Api Version Bundle"
170118
PROJECT_DESCRIPTION="Provides the base API plattform functionality."
171119
API_BASE_URL=/api/v1
172120
API_COUNTRY_CODE=de_DE
173121
###< own variables ###
174122

123+
###> Dockerfile Configuration ###
124+
DOCKERFILE_BUILD_APP=build-app.dockerfile
125+
DOCKERFILE_PHP_FPM=php-fpm.dockerfile
126+
DOCKERFILE_ADMINER=adminer.dockerfile
127+
###< Dockerfile Configuration ###
128+
129+
###> PHP Configuration ###
130+
PHP_VERSION=8.2.1
131+
PHP_VERSION_HOSTNAME=8-2-1
132+
###< PHP Configuration ###
133+
134+
###> Docker Configuration: PostgreSQL secrets and configurations (used to set the docker-compose configuration)
135+
POSTGRESQL_SERVER_ROOT_USER=root
136+
POSTGRESQL_SERVER_ROOT_PASSWORD=secret-pass
137+
POSTGRESQL_SERVER_HOST=${NAMESPACE_HOSTNAME_DEVELOPMENT}-postgresql
138+
POSTGRESQL_SERVER_DB=pavb
139+
POSTGRESQL_SERVER_PORT=${PORT_POSTGRESQL_INTERNAL}
140+
POSTGRESQL_SERVER_VERSION=14.7
141+
POSTGRESQL_SERVER_DRIVER=pdo_pgsql
142+
###< Docker Configuration: PostgreSQL secrets and configurations
143+
144+
##> doctrine/doctrine-bundle (postgresql - used from doctrine) ###
145+
DOCTRINE_DB_USER_POSTGRESQL=${ENV_DB_USER:-root}
146+
DOCTRINE_DB_PASS_POSTGRESQL=${ENV_DB_PASS:-secret-pass}
147+
DOCTRINE_DB_HOST_POSTGRESQL=${ENV_DB_HOST:-127.0.0.1}
148+
DOCTRINE_DB_PORT_POSTGRESQL=${ENV_DB_PORT:-5032}
149+
DOCTRINE_DB_NAME_POSTGRESQL=${ENV_DB_NAME:-pavb}
150+
DOCTRINE_DB_VERSION_POSTGRESQL=${ENV_DB_VERSION:-14.7}
151+
DOCTRINE_DB_DRIVER_POSTGRESQL=${ENV_DB_DRIVER:-pdo_pgsql}
152+
DOCTRINE_DB_PATH_POSTGRESQL=
153+
DOCTRINE_DB_SSL_CA_POSTGRESQL=
154+
DOCTRINE_DB_SSL_VERIFY_SERVER_CERT_POSTGRESQL=false
155+
DOCTRINE_DB_INIT_COMMAND_POSTGRESQL="SET NAMES utf8"
156+
###< doctrine/doctrine-bundle (postgresql) ###
157+
158+
##> doctrine/doctrine-bundle (sqlite - used from doctrine) ###
159+
DOCTRINE_DB_USER_SQLITE=root
160+
DOCTRINE_DB_PASS_SQLITE=secret-pass
161+
DOCTRINE_DB_HOST_SQLITE=
162+
DOCTRINE_DB_PORT_SQLITE=
163+
DOCTRINE_DB_NAME_SQLITE=opa
164+
DOCTRINE_DB_VERSION_SQLITE=8.0
165+
DOCTRINE_DB_DRIVER_SQLITE=pdo_sqlite
166+
DOCTRINE_DB_PATH_SQLITE="%kernel.project_dir%/var/app.db"
167+
DOCTRINE_DB_SSL_CA_SQLITE=
168+
DOCTRINE_DB_SSL_VERIFY_SERVER_CERT_SQLITE=false
169+
DOCTRINE_DB_INIT_COMMAND_SQLITE="SET NAMES utf8"
170+
###< doctrine/doctrine-bundle (sqlite) ###
171+
172+
###> Docker Configuration: Mail secrets and configurations (used to set the docker-compose configuration)
173+
MAIL_SERVER_TRANSPORT_DOCKER=smtp
174+
MAIL_SERVER_HOST_DOCKER=${NAMESPACE_HOSTNAME_DEVELOPMENT}-maildev
175+
MAIL_SERVER_PORT_DOCKER=${PORT_SMTP_MAILDEV_INTERNAL}
176+
###< Docker Configuration: Mail secrets and configurations (used to set the docker-compose configuration)
177+
178+
###> symfony/mailer ###
179+
MAIL_SERVER_TRANSPORT=${ENV_MAIL_SERVER_TRANSPORT:-smtp}
180+
MAIL_SERVER_HOST=${ENV_MAIL_SERVER_HOST:-localhost}
181+
MAIL_SERVER_PORT=${ENV_MAIL_SERVER_PORT:-5025}
182+
MAILER_DSN=${MAIL_SERVER_TRANSPORT}://${MAIL_SERVER_HOST}:${MAIL_SERVER_PORT}
183+
###< symfony/mailer ###
184+
175185
###> table-dumper (local docker settings) ###
176-
MYSQLDUMP_DATABASE_URL=mysql://${MYSQL_SERVER_ROOT_USER}:${MYSQL_SERVER_ROOT_PASSWORD}@${MYSQL_SERVER_HOST}:${MYSQL_SERVER_PORT}/${MYSQL_SERVER_DB}?serverVersion=${MYSQL_SERVER_VERSION}
186+
MYSQLDUMP_DATABASE_URL=mysql://${POSTGRESQL_SERVER_ROOT_USER}:${POSTGRESQL_SERVER_ROOT_PASSWORD}@localhost:5032/pavb?serverVersion=14.7
177187
MYSQLDUMP_IGNORED_TABLES=
178188
#MYSQLDUMP_FILTERED_TABLES=
179189
#MYSQLDUMP_TABLES_NO_DATA=
@@ -184,6 +194,6 @@ MYSQLDUMP_IGNORED_TABLES=
184194
CORS_ALLOW_ORIGIN='^https?://(php-api-version-bundle.ixnode.de|api-version.localhost|localhost|127\.0\.0\.1)(:[0-9]+)?$'
185195
###< nelmio/cors-bundle ###
186196

187-
###> symfony/mailer ###
188-
MAILER_DSN=smtp://${MAIL_SERVER_PORT}:${MAIL_SERVER_PORT}
189-
###< symfony/mailer ###
197+
###> symfony/messenger ###
198+
MESSENGER_TRANSPORT_DSN=doctrine://postgresql?auto_setup=1
199+
###< symfony/messenger ###

.env.test

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,3 @@ SYMFONY_DEPRECATIONS_HELPER=999999
55
PANTHER_APP_ENV=panther
66
PANTHER_ERROR_SCREENSHOT_DIR=./var/error-screenshots
77
###< symfony/framework-bundle ###
8-
9-
###> doctrine/doctrine-bundle (sqlite) ###
10-
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
11-
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
12-
DOCTRINE_DB_DRIVER=pdo_sqlite
13-
DOCTRINE_DB_VERSION=${MYSQL_SERVER_VERSION}
14-
DOCTRINE_DB_PATH="%kernel.project_dir%/var/app.db"
15-
DOCTRINE_DB_NAME=${MYSQL_SERVER_DB}
16-
DOCTRINE_DB_HOST=${ENV_DB_HOST:-127.0.0.1}
17-
# Workaround for default port for DOCTRINE_DB_PORT: Because ${ENV_DB_PORT:-${PORT_DB_MAIN_EXPOSE}} does not work
18-
DOCTRINE_DB_PORT=${ENV_DB_PORT:-5007}
19-
DOCTRINE_DB_USER=${MYSQL_SERVER_ROOT_USER}
20-
DOCTRINE_DB_PASS=${MYSQL_SERVER_ROOT_PASSWORD}
21-
DOCTRINE_DB_SSL_CA=
22-
DOCTRINE_DB_SSL_VERIFY_SERVER_CERT=false
23-
DOCTRINE_DB_INIT_COMMAND="SET NAMES utf8"
24-
###< doctrine/doctrine-bundle (sqlite) ###

bin/header/cache

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
3+
# ------------
4+
# This script prints the header for cache commands
5+
#
6+
# @author Björn Hempel <bjoern@hempel.li>
7+
# @version 0.1.0 (2023-06-24)
8+
# ------------
9+
10+
HEADER="Caching"
11+
COMMAND="$1"
12+
DESCRIPTION="$2"
13+
14+
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
15+
16+
eval "$SCRIPT_DIR/global \"$HEADER\" \"$COMMAND\" \"$DESCRIPTION\" \"$DESCRIPTION\""
17+
RETURN_CODE=$?
18+
19+
exit $RETURN_CODE
20+

composer.json

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"ixnode/php-array-to-object": "^0.1.1",
2626
"ixnode/php-checker": "^0.1.3",
2727
"ixnode/php-container": "^0.1.2",
28-
"ixnode/php-exception": "^0.1.13",
28+
"ixnode/php-exception": "^0.1.19",
2929
"ixnode/php-json-schema-validator": "^0.1.2",
3030
"ixnode/php-naming-conventions": "^0.1.1",
3131
"nelmio/cors-bundle": "^2.2",
@@ -47,7 +47,9 @@
4747
"symfony/validator": "6.3.*",
4848
"symfony/yaml": "6.3.*",
4949
"monolog/monolog": "^3.4",
50-
"symfony/monolog-bundle": "^3.8"
50+
"symfony/monolog-bundle": "^3.8",
51+
"symfony/messenger": "6.3.*",
52+
"symfony/doctrine-messenger": "6.3.*"
5153
},
5254
"require-dev": {
5355
"doctrine/doctrine-fixtures-bundle": "^3.4",
@@ -98,6 +100,9 @@
98100

99101
"ixno:header": "bin/header/ixno",
100102

103+
"cache:clear": "bin/header/cache 'bin/console cache:clear' 'Clear Cache'",
104+
"cache:delete": "bin/header/cache 'rm -rf var/cache/*' 'Delete Cache'",
105+
101106
"db:initialize:test:fixture": "bin/header/dbinit 'bin/console db:reinitialize --format=text --env=test' 'Test-DB Initialization'",
102107
"db:initialize:main:fixture": "bin/header/dbinit 'bin/console db:reinitialize --format=text --env=dev' 'Test-DB Initialization'",
103108
"db:initialize:main:sql": "for dump in fixtures/db/*.sql; do mysql -h127.0.0.1 -P3336 -uroot -psecret-pass --default-character-set=utf8 opa < \"$dump\"; done",
@@ -129,18 +134,21 @@
129134
"phpunit:functional:debug": "bin/header/phpunit 'PHPUNIT_DEBUG=1 vendor/bin/phpunit -d memory_limit=512M --configuration .phpunit/phpunit.functional.xml' 'Functional'",
130135
"phpunit:unit:debug": "bin/header/phpunit 'PHPUNIT_DEBUG=1 vendor/bin/phpunit -d memory_limit=512M --configuration .phpunit/phpunit.unit.xml' 'Unit'",
131136
"phpunit:all": [
137+
"@cache:delete",
132138
"@db:initialize:test:fixture",
133139
"@phpunit:unit",
134140
"@phpunit:functional",
135141
"@phpunit:api"
136142
],
137143
"phpunit:all:coverage": [
144+
"@cache:delete",
138145
"@db:initialize:test:fixture",
139146
"@phpunit:unit:coverage",
140147
"@phpunit:functional:coverage",
141148
"@phpunit:api:coverage"
142149
],
143150
"phpunit:all:debug": [
151+
"@cache:delete",
144152
"@db:initialize:test:fixture",
145153
"@phpunit:unit:debug",
146154
"@phpunit:functional:debug",
@@ -203,15 +211,15 @@
203211
],
204212

205213
".test:basic": [
206-
"@rsm:header",
214+
"@ixno:header",
207215
"@phpstan",
208216
"@phpunit"
209217
],
210218
"test:basic": [
211219
"composer .test:basic && bin/header/success || bin/header/error"
212220
],
213221
".test:most": [
214-
"@rsm:header",
222+
"@ixno:header",
215223
"@phpmnd",
216224
"@phpstan",
217225
"@phpunit",
@@ -221,7 +229,7 @@
221229
"composer .test:most && bin/header/success || bin/header/error"
222230
],
223231
".test:all": [
224-
"@rsm:header",
232+
"@ixno:header",
225233
"@phpmnd",
226234
"@phpstan",
227235
"@phpunit",
@@ -232,7 +240,7 @@
232240
"composer .test:all && bin/header/success || bin/header/error"
233241
],
234242
".test:hardcore": [
235-
"@rsm:header",
243+
"@ixno:header",
236244
"@phpmnd",
237245
"@phpstan",
238246
"@phpunit",
@@ -244,7 +252,7 @@
244252
"composer .test:hardcore && bin/header/success || bin/header/error"
245253
],
246254
".test:static": [
247-
"@rsm:header",
255+
"@ixno:header",
248256
"@phpmnd",
249257
"@phpstan",
250258
"@phpcs",

0 commit comments

Comments
 (0)