-
-
Notifications
You must be signed in to change notification settings - Fork 759
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
219 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Using Alpine Linux Instead of Debian | ||
|
||
By default, Symfony Docker uses Debian-based FrankenPHP Docker images. | ||
This is the recommended solution. | ||
|
||
Alternatively, it's possible to use Alpine-based images, which are smaller but | ||
are known to be slower, and have several known issues. | ||
|
||
To switch to Alpine-based images, apply the following changes to the `Dockerfile`: | ||
|
||
```patch | ||
-FROM dunglas/frankenphp:1-php8.3 AS frankenphp_upstream | ||
+FROM dunglas/frankenphp:1-php8.3-alpine AS frankenphp_upstream | ||
|
||
-# hadolint ignore=DL3008 | ||
-RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
- acl \ | ||
- file \ | ||
- gettext \ | ||
- git \ | ||
- && rm -rf /var/lib/apt/lists/* | ||
+# hadolint ignore=DL3018 | ||
+RUN apk add --no-cache \ | ||
+ acl \ | ||
+ file \ | ||
+ gettext \ | ||
+ git \ | ||
+ ; | ||
``` |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# Using MySQL | ||
|
||
The Docker configuration of this repository is extensible thanks to Flex recipes. By default, the recipe installs PostgreSQL. | ||
If you prefer to work with MySQL, follow these steps: | ||
|
||
First, install the `symfony/orm-pack` package as described: `docker compose exec php composer req symfony/orm-pack` | ||
|
||
## Docker Configuration | ||
Change the database image to use MySQL instead of PostgreSQL in `compose.yaml`: | ||
|
||
```diff | ||
###> doctrine/doctrine-bundle ### | ||
- image: postgres:${POSTGRES_VERSION:-15}-alpine | ||
+ image: mysql:${MYSQL_VERSION:-8} | ||
environment: | ||
- POSTGRES_DB: ${POSTGRES_DB:-app} | ||
+ MYSQL_DATABASE: ${MYSQL_DATABASE:-app} | ||
# You should definitely change the password in production | ||
+ MYSQL_RANDOM_ROOT_PASSWORD: "true" | ||
- POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-!ChangeMe!} | ||
+ MYSQL_PASSWORD: ${MYSQL_PASSWORD:-!ChangeMe!} | ||
- POSTGRES_USER: ${POSTGRES_USER:-app} | ||
+ MYSQL_USER: ${MYSQL_USER:-app} | ||
volumes: | ||
- - database_data:/var/lib/postgresql/data:rw | ||
+ - database_data:/var/lib/mysql:rw | ||
# You may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data! | ||
- # - ./docker/db/data:/var/lib/postgresql/data:rw | ||
+ # - ./docker/db/data:/var/lib/mysql:rw | ||
###< doctrine/doctrine-bundle ### | ||
``` | ||
|
||
Depending on the database configuration, modify the environment in the same file at `services.php.environment.DATABASE_URL` | ||
``` | ||
DATABASE_URL: mysql://${MYSQL_USER:-app}:${MYSQL_PASSWORD:-!ChangeMe!}@database:3306/${MYSQL_DATABASE:-app}?serverVersion=${MYSQL_VERSION:-8}&charset=${MYSQL_CHARSET:-utf8mb4} | ||
``` | ||
|
||
Since we changed the port, we also have to define this in the `compose.override.yaml`: | ||
```diff | ||
###> doctrine/doctrine-bundle ### | ||
database: | ||
ports: | ||
- - "5432" | ||
+ - "3306" | ||
###< doctrine/doctrine-bundle ### | ||
``` | ||
|
||
Last but not least, we need to install the MySQL driver in `Dockerfile`: | ||
```diff | ||
###> doctrine/doctrine-bundle ### | ||
-RUN install-php-extensions pdo_pgsql | ||
+RUN install-php-extensions pdo_mysql | ||
###< doctrine/doctrine-bundle ### | ||
``` | ||
|
||
## Change Environment | ||
Change the database configuration in `.env`: | ||
|
||
```dotenv | ||
DATABASE_URL=mysql://${MYSQL_USER:-app}:${MYSQL_PASSWORD:-!ChangeMe!}@database:3306/${MYSQL_DATABASE:-app}?serverVersion=${MYSQL_VERSION:-8}&charset=${MYSQL_CHARSET:-utf8mb4} | ||
``` | ||
|
||
## Final steps | ||
Rebuild the docker environment: | ||
```shell | ||
docker compose down --remove-orphans && docker compose build --pull --no-cache | ||
``` | ||
|
||
Test your setup: | ||
```shell | ||
docker compose exec php bin/console dbal:run-sql -q "SELECT 1" && echo "OK" || echo "Connection is not working" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# Docker Build Options | ||
|
||
You can customize the docker build process using these environment variables. | ||
|
||
> [!NOTE] | ||
> All Symfony-specific environment variables are used only if no `composer.json` file is found in the project directory. | ||
## Selecting a Specific Symfony Version | ||
|
||
Use the `SYMFONY_VERSION` environment variable to select a specific Symfony version. | ||
|
||
For instance, use the following command to install Symfony 6.4: | ||
|
||
On Linux: | ||
|
||
SYMFONY_VERSION=6.4.* docker compose up -d --wait | ||
On Windows: | ||
|
||
set SYMFONY_VERSION=6.4.* && docker compose up -d --wait&set SYMFONY_VERSION= | ||
|
||
## Installing Development Versions of Symfony | ||
|
||
To install a non-stable version of Symfony, use the `STABILITY` environment variable during the build. | ||
The value must be [a valid Composer stability option](https://getcomposer.org/doc/04-schema.md#minimum-stability). | ||
|
||
For instance, use the following command to use the development branch of Symfony: | ||
|
||
On Linux: | ||
|
||
STABILITY=dev docker compose up -d --wait | ||
|
||
On Windows: | ||
|
||
set STABILITY=dev && docker compose up -d --wait&set STABILITY= | ||
|
||
## Using custom HTTP ports | ||
|
||
Use the environment variables `HTTP_PORT`, `HTTPS_PORT` and/or `HTTP3_PORT` to adjust the ports to your needs, e.g. | ||
|
||
HTTP_PORT=8000 HTTPS_PORT=4443 HTTP3_PORT=4443 docker compose up -d --wait | ||
|
||
to access your application on [https://localhost:4443](https://localhost:4443). | ||
|
||
> [!NOTE] | ||
> Let's Encrypt only supports the standard HTTP and HTTPS ports. Creating a Let's Encrypt certificate for another port will not work, you have to use the standard ports or to configure Caddy to use another provider. | ||
|
||
## Caddyfile Options | ||
|
||
You can also customize the `Caddyfile` by using the following environment variables to inject options block, directive or configuration. | ||
|
||
> [!TIP] | ||
> All the following environment variables can be defined in your `.env` file at the root of the project to keep them persistent at each startup | ||
| Environment variable | Description | Default value | | ||
|---------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------| | ||
| `CADDY_GLOBAL_OPTIONS` | the [global options block](https://caddyserver.com/docs/caddyfile/options#global-options), one per line | | | ||
| `CADDY_EXTRA_CONFIG` | the [snippet](https://caddyserver.com/docs/caddyfile/concepts#snippets) or the [named-routes](https://caddyserver.com/docs/caddyfile/concepts#named-routes) options block, one per line | | | ||
| `CADDY_SERVER_EXTRA_DIRECTIVES` | the [`Caddyfile` directives](https://caddyserver.com/docs/caddyfile/concepts#directives) | | | ||
| `SERVER_NAME` | the server name or address | `localhost` | | ||
| `FRANKENPHP_CONFIG` | a list of extra [FrankenPHP directives](https://frankenphp.dev/docs/config/#caddyfile-config), one per line | `import worker.Caddyfile` | | ||
| `MERCURE_TRANSPORT_URL` | the value passed to the `transport_url` directive | `bolt://mercure.db` | | ||
| `MERCURE_PUBLISHER_JWT_KEY` | the JWT key to use for publishers | | | ||
| `MERCURE_PUBLISHER_JWT_ALG` | the JWT algorithm to use for publishers | `HS256` | | ||
| `MERCURE_SUBSCRIBER_JWT_KEY` | the JWT key to use for subscribers | | | ||
| `MERCURE_SUBSCRIBER_JWT_ALG` | the JWT algorithm to use for subscribers | `HS256` | | ||
| `MERCURE_EXTRA_DIRECTIVES` | a list of extra [Mercure directives](https://mercure.rocks/docs/hub/config), one per line | | | ||
|
||
### Example of server name customize: | ||
|
||
SERVER_NAME="app.localhost" docker compose up -d --wait |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters