Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update doc #639

Closed
wants to merge 33 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
558eddf
adapt for laravel
fouteox Feb 16, 2024
2a19594
adapt for laravel
fouteox Feb 16, 2024
37366dc
Merge remote-tracking branch 'origin/main'
fouteox Feb 16, 2024
d1e2282
adapt for laravel
fouteox Feb 16, 2024
20abf09
update README.md
fouteox Feb 16, 2024
3bc1d9f
update README.md
fouteox Feb 16, 2024
502e74b
move alpine to debian
fouteox Jun 14, 2024
9b2d891
add complete arg
fouteox Jun 14, 2024
5633aa0
update app.ini
fouteox Jun 14, 2024
ea029ce
remove bootstrap
fouteox Jun 14, 2024
13e0483
move install
fouteox Jun 14, 2024
1aaa856
adjust script for ignore installation and script "à certains endroits"
fouteox Jun 14, 2024
5de3ab0
standard of laravel for APP_ENV
fouteox Jun 14, 2024
96352ad
add node for prod
fouteox Jun 14, 2024
686b565
fix node version
fouteox Jun 14, 2024
8aab444
add node for dev
fouteox Jun 14, 2024
6d2921d
write for laravel
fouteox Jun 14, 2024
5ce4d83
write for laravel
fouteox Jun 14, 2024
196bdf9
switch bin/console to artisan
fouteox Jun 14, 2024
3980ffb
add node env
fouteox Jun 14, 2024
6b4c6a1
add volume for persistent data
fouteox Jun 15, 2024
adbcb6d
fix command not found for laravel
fouteox Jun 15, 2024
890a0e6
APP_ENV for production standard laravel
fouteox Jun 15, 2024
b62e457
fix composer install and artisan optimize for production
fouteox Jun 15, 2024
0904e44
fix composer install and artisan optimize for production
fouteox Jun 15, 2024
1603e73
add cert
fouteox Jun 15, 2024
6d8a2b5
not work with laravel
fouteox Jun 15, 2024
f799060
fix issue with volume when has deleted on dev
fouteox Jun 15, 2024
3835c43
setfcal only on prod
fouteox Jun 15, 2024
6237bbf
Update README.md
fouteox Jun 15, 2024
8d3aae5
Create vite.md
fouteox Jun 15, 2024
f37f2b7
Update vite.md
fouteox Jun 15, 2024
c7ce204
Merge branch 'main' into update-doc
fouteox Jun 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
**/Dockerfile
**/Thumbs.db
.github/
cert/
docs/
public/bundles/
tests/
Expand Down
52 changes: 6 additions & 46 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,58 +1,18 @@
# 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
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true

[*.{js,html,ts,tsx}]
indent_size = 2

[*.json]
indent_size = 2
trim_trailing_whitespace = true

[*.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]
[*.{yml,yaml}]
indent_size = 2

[.gitmodules]
indent_style = tab

[.php_cs{,.dist}]
indent_style = space
indent_size = 4

[composer.json]
[docker-compose.yml]
indent_size = 4

[{,docker-}compose{,.*}.{yaml,yml}]
indent_style = space
indent_size = 2

[{,*.*}Dockerfile]
indent_style = tab

[{,*.*}Caddyfile]
indent_style = tab
22 changes: 8 additions & 14 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
* 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
*.blade.php diff=html
*.css diff=css
*.html diff=html
*.md diff=markdown
*.php diff=php

*.ico binary
*.png binary
/.github export-ignore
CHANGELOG.md export-ignore
.styleci.yml export-ignore
65 changes: 53 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# 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

Expand Down Expand Up @@ -51,10 +50,15 @@
# Dev FrankenPHP image
FROM frankenphp_base AS frankenphp_dev

ENV APP_ENV=dev XDEBUG_MODE=off
ENV APP_ENV=local XDEBUG_MODE=off

RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"

RUN curl -fsSL https://deb.nodesource.com/setup_lts.x -o nodesource_setup.sh; \

Check failure on line 57 in Dockerfile

View workflow job for this annotation

GitHub Actions / Docker Lint

DL3008 warning: Pin versions in apt get install. Instead of `apt-get install <package>` use `apt-get install <package>=<version>`

Check failure on line 57 in Dockerfile

View workflow job for this annotation

GitHub Actions / Docker Lint

DL3015 info: Avoid additional packages by specifying `--no-install-recommends`
bash nodesource_setup.sh; \
apt-get install -y nodejs; \
rm nodesource_setup.sh;

RUN set -eux; \
install-php-extensions \
xdebug \
Expand All @@ -64,29 +68,66 @@

CMD [ "frankenphp", "run", "--config", "/etc/caddy/Caddyfile", "--watch" ]

FROM node:20-alpine AS build

WORKDIR /app

RUN npm config set update-notifier false && npm set progress=false

COPY --link package*.json ./

RUN if [ -f $ROOT/package-lock.json ]; \

Check failure on line 79 in Dockerfile

View workflow job for this annotation

GitHub Actions / Docker Lint

SC2086 info: Double quote to prevent globbing and word splitting.
then \
npm ci --loglevel=error --no-audit; \
else \
npm install --loglevel=error --no-audit; \
fi

COPY --link . .

RUN npm run build

# Prod FrankenPHP image
FROM frankenphp_base AS frankenphp_prod

ENV APP_ENV=prod
ENV FRANKENPHP_CONFIG="import worker.Caddyfile"
ENV APP_ENV=production

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.* ./
COPY --link composer.* ./

RUN set -eux; \
composer install --no-cache --prefer-dist --no-dev --no-autoloader --no-scripts --no-progress
composer install \
--no-dev \
--no-interaction \
--no-autoloader \
--no-ansi \
--no-scripts \
--audit;

# copy sources
COPY --link . ./
RUN rm -Rf frankenphp/

# copy build assets
COPY --link --from=build /app/public ./public

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;
mkdir -p storage/framework/sessions; \
mkdir -p storage/framework/views; \
mkdir -p storage/framework/cache; \
mkdir -p storage/framework/testing; \
mkdir -p storage/logs; \
mkdir -p bootstrap/cache; \
chmod -R a+rw storage; \
composer install \
--classmap-authoritative \
--no-interaction \
--no-ansi \
--no-dev; \
composer clear-cache; \
php artisan storage:link; \
php artisan optimize; sync;
19 changes: 8 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Symfony Docker
# Laravel Docker

A [Docker](https://www.docker.com/)-based installer and runtime for the [Symfony](https://symfony.com) web framework,
A [Docker](https://www.docker.com/)-based installer and runtime for the [Laravel](https://laravel.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)
Expand All @@ -18,11 +18,9 @@ with [FrankenPHP](https://frankenphp.dev) and [Caddy](https://caddyserver.com/)
* 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
* [Installation of extra Docker Compose services](docs/extra-services.md)
* 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

Expand All @@ -36,16 +34,15 @@ with [FrankenPHP](https://frankenphp.dev) and [Caddy](https://caddyserver.com/)
4. [Deploying in production](docs/production.md)
5. [Debugging with Xdebug](docs/xdebug.md)
6. [TLS Certificates](docs/tls.md)
7. [Using MySQL instead of PostgreSQL](docs/mysql.md)
8. [Using Alpine Linux instead of Debian](docs/alpine.md)
9. [Using a Makefile](docs/makefile.md)
7. [Using a Makefile](docs/makefile.md)
8. [Troubleshooting](docs/troubleshooting.md)
9. [Use With Vite](docs/vite.md)
10. [Updating the template](docs/updating.md)
11. [Troubleshooting](docs/troubleshooting.md)

## License

Symfony Docker is available under the MIT License.
Laravel 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).
Original 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).
9 changes: 5 additions & 4 deletions compose.override.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ services:
# 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}"
NODE_ENV: development
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 ###
ports:
- target: 5173
published: 5173
protocol: tcp
11 changes: 7 additions & 4 deletions compose.prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ services:
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}
volumes:
- storage_data:/app/storage
- cache_data:/app/bootstrap/cache

volumes:
storage_data:
cache_data:
18 changes: 2 additions & 16 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,10 @@ services:
restart: unless-stopped
environment:
SERVER_NAME: ${SERVER_NAME:-localhost}, php:80
MERCURE_PUBLISHER_JWT_KEY: ${CADDY_MERCURE_JWT_SECRET:-!ChangeThisMercureHubJWTSecretKey!}
MERCURE_SUBSCRIBER_JWT_KEY: ${CADDY_MERCURE_JWT_SECRET:-!ChangeThisMercureHubJWTSecretKey!}
TRUSTED_PROXIES: ${TRUSTED_PROXIES:-127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16}
TRUSTED_HOSTS: ${TRUSTED_HOSTS:-^${SERVER_NAME:-example\.com|localhost}|php$$}
# Run "composer require symfony/orm-pack" to install and configure Doctrine ORM
DATABASE_URL: postgresql://${POSTGRES_USER:-app}:${POSTGRES_PASSWORD:-!ChangeMe!}@database:5432/${POSTGRES_DB:-app}?serverVersion=${POSTGRES_VERSION:-15}&charset=${POSTGRES_CHARSET:-utf8}
# Run "composer require symfony/mercure-bundle" to install and configure the Mercure integration
MERCURE_URL: ${CADDY_MERCURE_URL:-http://php/.well-known/mercure}
MERCURE_PUBLIC_URL: ${CADDY_MERCURE_PUBLIC_URL:-https://${SERVER_NAME:-localhost}/.well-known/mercure}
MERCURE_JWT_SECRET: ${CADDY_MERCURE_JWT_SECRET:-!ChangeThisMercureHubJWTSecretKey!}
TRUSTED_HOSTS: ^${SERVER_NAME:-example\.com|localhost}|php$$
# The two next lines can be removed after initial installation
SYMFONY_VERSION: ${SYMFONY_VERSION:-}
LARAVEL_VERSION: ${LARAVEL_VERSION:-}
STABILITY: ${STABILITY:-stable}
volumes:
- caddy_data:/data
Expand All @@ -34,12 +26,6 @@ services:
published: ${HTTP3_PORT:-443}
protocol: udp

# Mercure is installed as a Caddy module, prevent the Flex recipe from installing another service
###> symfony/mercure-bundle ###
###< symfony/mercure-bundle ###

volumes:
caddy_data:
caddy_config:
###> symfony/mercure-bundle ###
###< symfony/mercure-bundle ###
25 changes: 17 additions & 8 deletions docs/makefile.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,14 @@ PHP_CONT = $(DOCKER_COMP) exec php
# Executables
PHP = $(PHP_CONT) php
COMPOSER = $(PHP_CONT) composer
SYMFONY = $(PHP) bin/console
NPM = $(PHP_CONT) npm
LARAVEL = $(PHP) artisan

# Misc
.DEFAULT_GOAL = help
.PHONY : help build up start down logs sh composer vendor sf cc test
.PHONY : help build up start down logs sh composer vendor npm dev a cc test

## —— 🎵 🐳 The Symfony Docker Makefile 🐳 🎵 ——————————————————————————————————
## —— 🎵 🐳 The Laravel Docker Makefile 🐳 🎵 ——————————————————————————————————
help: ## Outputs this help screen
@grep -E '(^[a-zA-Z0-9\./_-]+:.*?##.*$$)|(^##)' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}{printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}' | sed -e 's/\[32m##/[33m/'

Expand Down Expand Up @@ -79,19 +80,27 @@ test: ## Start tests with phpunit, pass the parameter "c=" to add options to php


## —— Composer 🧙 ——————————————————————————————————————————————————————————————
composer: ## Run composer, pass the parameter "c=" to run a given command, example: make composer c='req symfony/orm-pack'
composer: ## Run composer, pass the parameter "c=" to run a given command, example: make composer c='req laravel/breeze --dev'
@$(eval c ?=)
@$(COMPOSER) $(c)

vendor: ## Install vendors according to the current composer.lock file
vendor: c=install --prefer-dist --no-dev --no-progress --no-scripts --no-interaction
vendor: composer

## —— Symfony 🎵 ———————————————————————————————————————————————————————————————
sf: ## List all Symfony commands or pass the parameter "c=" to run a given command, example: make sf c=about
## —— Npm 🟩 ——————————————————————————————————————————————————————————————
npm: ## Run npm, pass the parameter "c=" to run a given command, example: make npm c='install'
@$(eval c ?=)
@$(SYMFONY) $(c)
@$(NPM) $(c)

dev: ## Run npm run dev
@$(NPM) run dev

## —— Laravel 🟥 ———————————————————————————————————————————————————————————————
a: ## List all Laravel commands or pass the parameter "c=" to run a given command, example: make a c=about
@$(eval c ?=)
@$(LARAVEL) $(c)

cc: c=c:c ## Clear the cache
cc: sf
cc: a
```
Loading