generated from dunglas/symfony-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
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
0 parents
commit ada2ee5
Showing
28 changed files
with
1,055 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
**/*.log | ||
**/*.md | ||
**/*.php~ | ||
**/*.dist.php | ||
**/*.dist | ||
**/*.cache | ||
**/._* | ||
**/.dockerignore | ||
**/.DS_Store | ||
**/.git/ | ||
**/.gitattributes | ||
**/.gitignore | ||
**/.gitmodules | ||
**/compose.*.yaml | ||
**/compose.*.yml | ||
**/compose.yaml | ||
**/compose.yml | ||
**/docker-compose.*.yaml | ||
**/docker-compose.*.yml | ||
**/docker-compose.yaml | ||
**/docker-compose.yml | ||
**/Dockerfile | ||
**/Thumbs.db | ||
.github/ | ||
docs/ | ||
public/bundles/ | ||
tests/ | ||
var/ | ||
vendor/ | ||
.editorconfig | ||
.env.*.local | ||
.env.local | ||
.env.local.php | ||
.env.test |
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,58 @@ | ||
# EditorConfig helps developers define and maintain consistent | ||
# coding styles between different editors and IDEs | ||
# editorconfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
# Change these settings to your own preference | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
# We recommend you to keep these unchanged | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.{js,html,ts,tsx}] | ||
indent_size = 2 | ||
|
||
[*.json] | ||
indent_size = 2 | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
[*.sh] | ||
indent_style = tab | ||
|
||
[*.xml{,.dist}] | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
[*.{yaml,yml}] | ||
trim_trailing_whitespace = false | ||
|
||
[.github/workflows/*.yml] | ||
indent_size = 2 | ||
|
||
[.gitmodules] | ||
indent_style = tab | ||
|
||
[.php_cs{,.dist}] | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
[composer.json] | ||
indent_size = 4 | ||
|
||
[{,docker-}compose{,.*}.{yaml,yml}] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[{,*.*}Dockerfile] | ||
indent_style = tab | ||
|
||
[{,*.*}Caddyfile] | ||
indent_style = tab |
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,17 @@ | ||
* text=auto eol=lf | ||
|
||
*.conf text eol=lf | ||
*.html text eol=lf | ||
*.ini text eol=lf | ||
*.js text eol=lf | ||
*.json text eol=lf | ||
*.md text eol=lf | ||
*.php text eol=lf | ||
*.sh text eol=lf | ||
*.yaml text eol=lf | ||
*.yml text eol=lf | ||
bin/console text eol=lf | ||
composer.lock text eol=lf merge=ours | ||
|
||
*.ico binary | ||
*.png binary |
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 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: ~ | ||
workflow_dispatch: ~ | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
tests: | ||
name: Tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v4 | ||
- | ||
name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- | ||
name: Build Docker images | ||
uses: docker/bake-action@v4 | ||
with: | ||
pull: true | ||
load: true | ||
files: | | ||
compose.yaml | ||
compose.override.yaml | ||
set: | | ||
*.cache-from=type=gha,scope=${{github.ref}} | ||
*.cache-from=type=gha,scope=refs/heads/main | ||
*.cache-to=type=gha,scope=${{github.ref}},mode=max | ||
- | ||
name: Start services | ||
run: docker compose up --wait --no-build | ||
- | ||
name: Check HTTP reachability | ||
run: curl -v -o /dev/null http://localhost | ||
- | ||
name: Check HTTPS reachability | ||
run: curl -vk -o /dev/null https://localhost | ||
- | ||
name: Create test database | ||
if: false # Remove this line if Doctrine ORM is installed | ||
run: docker compose exec -T php bin/console -e test doctrine:database:create | ||
- | ||
name: Run migrations | ||
if: false # Remove this line if Doctrine Migrations is installed | ||
run: docker compose exec -T php bin/console -e test doctrine:migrations:migrate --no-interaction | ||
- | ||
name: Run PHPUnit | ||
if: false # Remove this line if PHPUnit is installed | ||
run: docker compose exec -T php bin/phpunit | ||
- | ||
name: Doctrine Schema Validator | ||
if: false # Remove this line if Doctrine ORM is installed | ||
run: docker compose exec -T php bin/console -e test doctrine:schema:validate | ||
lint: | ||
name: Docker Lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v4 | ||
- | ||
name: Lint Dockerfile | ||
uses: hadolint/[email protected] |
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,91 @@ | ||
#syntax=docker/dockerfile:1.4 | ||
|
||
# Versions | ||
FROM dunglas/frankenphp:1-alpine AS frankenphp_upstream | ||
|
||
# The different stages of this Dockerfile are meant to be built into separate images | ||
# https://docs.docker.com/develop/develop-images/multistage-build/#stop-at-a-specific-build-stage | ||
# https://docs.docker.com/compose/compose-file/#target | ||
|
||
|
||
# Base FrankenPHP image | ||
FROM frankenphp_upstream AS frankenphp_base | ||
|
||
WORKDIR /app | ||
|
||
# persistent / runtime deps | ||
# hadolint ignore=DL3018 | ||
RUN apk add --no-cache \ | ||
acl \ | ||
file \ | ||
gettext \ | ||
git \ | ||
; | ||
|
||
RUN set -eux; \ | ||
install-php-extensions \ | ||
@composer \ | ||
apcu \ | ||
intl \ | ||
opcache \ | ||
zip \ | ||
; | ||
|
||
# https://getcomposer.org/doc/03-cli.md#composer-allow-superuser | ||
ENV COMPOSER_ALLOW_SUPERUSER=1 | ||
|
||
###> recipes ### | ||
###< recipes ### | ||
|
||
COPY --link frankenphp/conf.d/app.ini $PHP_INI_DIR/conf.d/ | ||
COPY --link --chmod=755 frankenphp/docker-entrypoint.sh /usr/local/bin/docker-entrypoint | ||
COPY --link frankenphp/Caddyfile /etc/caddy/Caddyfile | ||
|
||
ENTRYPOINT ["docker-entrypoint"] | ||
|
||
HEALTHCHECK --start-period=60s CMD curl -f http://localhost:2019/metrics || exit 1 | ||
CMD [ "frankenphp", "run", "--config", "/etc/caddy/Caddyfile" ] | ||
|
||
# Dev FrankenPHP image | ||
FROM frankenphp_base AS frankenphp_dev | ||
|
||
ENV APP_ENV=dev XDEBUG_MODE=off | ||
VOLUME /app/var/ | ||
|
||
RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini" | ||
|
||
RUN set -eux; \ | ||
install-php-extensions \ | ||
xdebug \ | ||
; | ||
|
||
COPY --link frankenphp/conf.d/app.dev.ini $PHP_INI_DIR/conf.d/ | ||
|
||
CMD [ "frankenphp", "run", "--config", "/etc/caddy/Caddyfile", "--watch" ] | ||
|
||
# Prod FrankenPHP image | ||
FROM frankenphp_base AS frankenphp_prod | ||
|
||
ENV APP_ENV=prod | ||
ENV FRANKENPHP_CONFIG="import worker.Caddyfile" | ||
|
||
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" | ||
|
||
COPY --link frankenphp/conf.d/app.prod.ini $PHP_INI_DIR/conf.d/ | ||
COPY --link frankenphp/worker.Caddyfile /etc/caddy/worker.Caddyfile | ||
|
||
# prevent the reinstallation of vendors at every changes in the source code | ||
COPY --link composer.* symfony.* ./ | ||
RUN set -eux; \ | ||
composer install --no-cache --prefer-dist --no-dev --no-autoloader --no-scripts --no-progress | ||
|
||
# copy sources | ||
COPY --link . ./ | ||
RUN rm -Rf frankenphp/ | ||
|
||
RUN set -eux; \ | ||
mkdir -p var/cache var/log; \ | ||
composer dump-autoload --classmap-authoritative --no-dev; \ | ||
composer dump-env prod; \ | ||
composer run-script --no-dev post-install-cmd; \ | ||
chmod +x bin/console; sync; |
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,50 @@ | ||
# Symfony Docker | ||
|
||
A [Docker](https://www.docker.com/)-based installer and runtime for the [Symfony](https://symfony.com) web framework, | ||
with [FrankenPHP](https://frankenphp.dev) and [Caddy](https://caddyserver.com/) inside! | ||
|
||
![CI](https://github.com/dunglas/symfony-docker/workflows/CI/badge.svg) | ||
|
||
## Getting Started | ||
|
||
1. If not already done, [install Docker Compose](https://docs.docker.com/compose/install/) (v2.10+) | ||
2. Run `docker compose build --no-cache` to build fresh images | ||
3. Run `docker compose up --pull always -d --wait` to start the project | ||
4. Open `https://localhost` in your favorite web browser and [accept the auto-generated TLS certificate](https://stackoverflow.com/a/15076602/1352334) | ||
5. Run `docker compose down --remove-orphans` to stop the Docker containers. | ||
|
||
## Features | ||
|
||
* Production, development and CI ready | ||
* Just 1 service by default | ||
* Blazing-fast performance thanks to [the worker mode of FrankenPHP](https://github.com/dunglas/frankenphp/blob/main/docs/worker.md) (automatically enabled in prod mode) | ||
* [Installation of extra Docker Compose services](docs/extra-services.md) with Symfony Flex | ||
* Automatic HTTPS (in dev and prod) | ||
* HTTP/3 and [Early Hints](https://symfony.com/blog/new-in-symfony-6-3-early-hints) support | ||
* Real-time messaging thanks to a built-in [Mercure hub](https://symfony.com/doc/current/mercure.html) | ||
* [Vulcain](https://vulcain.rocks) support | ||
* Native [XDebug](docs/xdebug.md) integration | ||
* Super-readable configuration | ||
|
||
**Enjoy!** | ||
|
||
## Docs | ||
|
||
1. [Build options](docs/build.md) | ||
2. [Using Symfony Docker with an existing project](docs/existing-project.md) | ||
3. [Support for extra services](docs/extra-services.md) | ||
4. [Deploying in production](docs/production.md) | ||
5. [Debugging with Xdebug](docs/xdebug.md) | ||
6. [TLS Certificates](docs/tls.md) | ||
7. [Using a Makefile](docs/makefile.md) | ||
8. [Using MySQL instead of PostgreSQL](docs/mysql.md) | ||
9. [Troubleshooting](docs/troubleshooting.md) | ||
10. [Updating the template](docs/updating.md) | ||
|
||
## License | ||
|
||
Symfony Docker is available under the MIT License. | ||
|
||
## Credits | ||
|
||
Created by [Kévin Dunglas](https://dunglas.dev), co-maintained by [Maxime Helias](https://twitter.com/maxhelias) and sponsored by [Les-Tilleuls.coop](https://les-tilleuls.coop). |
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,24 @@ | ||
# Development environment override | ||
services: | ||
php: | ||
build: | ||
context: . | ||
target: frankenphp_dev | ||
volumes: | ||
- ./:/app | ||
- ./frankenphp/Caddyfile:/etc/caddy/Caddyfile:ro | ||
- ./frankenphp/conf.d/app.dev.ini:/usr/local/etc/php/conf.d/app.dev.ini:ro | ||
# If you develop on Mac or Windows you can remove the vendor/ directory | ||
# from the bind-mount for better performance by enabling the next line: | ||
#- /app/vendor | ||
environment: | ||
MERCURE_EXTRA_DIRECTIVES: demo | ||
# See https://xdebug.org/docs/all_settings#mode | ||
XDEBUG_MODE: "${XDEBUG_MODE:-off}" | ||
extra_hosts: | ||
# Ensure that host.docker.internal is correctly defined on Linux | ||
- host.docker.internal:host-gateway | ||
tty: true | ||
|
||
###> symfony/mercure-bundle ### | ||
###< symfony/mercure-bundle ### |
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,10 @@ | ||
# Production environment override | ||
services: | ||
php: | ||
build: | ||
context: . | ||
target: frankenphp_prod | ||
environment: | ||
APP_SECRET: ${APP_SECRET} | ||
MERCURE_PUBLISHER_JWT_KEY: ${CADDY_MERCURE_JWT_SECRET} | ||
MERCURE_SUBSCRIBER_JWT_KEY: ${CADDY_MERCURE_JWT_SECRET} |
Oops, something went wrong.