Skip to content

Commit 1d71f79

Browse files
committed
FrankenPHP+AssetMapp+Tailwind
1 parent 403940e commit 1d71f79

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1484
-949
lines changed

.gitignore

+4-7
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@
77
/var/
88
/vendor/
99
###< symfony/framework-bundle ###
10-
11-
###> symfony/webpack-encore-bundle ###
12-
/node_modules/
13-
/public/build/
14-
npm-debug.log
15-
yarn-error.log
16-
###< symfony/webpack-encore-bundle ###
1710
###> phpunit/phpunit ###
1811
/phpunit.xml
1912
.phpunit.result.cache
@@ -28,3 +21,7 @@ yarn-error.log
2821
/node_modules/
2922
/public/build/
3023
###< symfony/webpack-encore-pack ###
24+
25+
###> symfony/asset-mapper ###
26+
/public/assets/
27+
###< symfony/asset-mapper ###

Dockerfile

+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#syntax=docker/dockerfile:1.4
2+
3+
# Versions
4+
FROM dunglas/frankenphp:latest-alpine AS frankenphp_upstream
5+
FROM composer/composer:2-bin AS composer_upstream
6+
7+
8+
# The different stages of this Dockerfile are meant to be built into separate images
9+
# https://docs.docker.com/develop/develop-images/multistage-build/#stop-at-a-specific-build-stage
10+
# https://docs.docker.com/compose/compose-file/#target
11+
12+
13+
# Base FrankenPHP image
14+
FROM frankenphp_upstream AS frankenphp_base
15+
16+
WORKDIR /app
17+
18+
# persistent / runtime deps
19+
# hadolint ignore=DL3018
20+
RUN apk add --no-cache \
21+
acl \
22+
file \
23+
gettext \
24+
git \
25+
;
26+
27+
RUN set -eux; \
28+
install-php-extensions \
29+
apcu \
30+
intl \
31+
opcache \
32+
zip \
33+
pdo_pgsql \
34+
gd \
35+
;
36+
37+
###> recipes ###
38+
###< recipes ###
39+
40+
COPY --link frankenphp/conf.d/app.ini $PHP_INI_DIR/conf.d/
41+
COPY --link --chmod=755 frankenphp/docker-entrypoint.sh /usr/local/bin/docker-entrypoint
42+
COPY --link frankenphp/Caddyfile /etc/caddy/Caddyfile
43+
44+
ENTRYPOINT ["docker-entrypoint"]
45+
46+
# https://getcomposer.org/doc/03-cli.md#composer-allow-superuser
47+
ENV COMPOSER_ALLOW_SUPERUSER=1
48+
ENV PATH="${PATH}:/root/.composer/vendor/bin"
49+
50+
COPY --from=composer_upstream --link /composer /usr/bin/composer
51+
52+
HEALTHCHECK CMD wget --no-verbose --tries=1 --spider http://localhost:2019/metrics || exit 1
53+
CMD [ "frankenphp", "run", "--config", "/etc/caddy/Caddyfile" ]
54+
55+
# Dev FrankenPHP image
56+
FROM frankenphp_base AS frankenphp_dev
57+
58+
ENV APP_ENV=dev XDEBUG_MODE=off
59+
VOLUME /app/var/
60+
61+
RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"
62+
63+
RUN set -eux; \
64+
install-php-extensions \
65+
xdebug \
66+
;
67+
68+
COPY --link frankenphp/conf.d/app.dev.ini $PHP_INI_DIR/conf.d/
69+
70+
CMD [ "frankenphp", "run", "--config", "/etc/caddy/Caddyfile", "--watch" ]
71+
72+
# Prod FrankenPHP image
73+
FROM frankenphp_base AS frankenphp_prod
74+
75+
ENV APP_ENV=prod
76+
ENV FRANKENPHP_CONFIG="import worker.Caddyfile"
77+
78+
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
79+
80+
COPY --link frankenphp/conf.d/app.prod.ini $PHP_INI_DIR/conf.d/
81+
COPY --link frankenphp/worker.Caddyfile /etc/caddy/worker.Caddyfile
82+
83+
# prevent the reinstallation of vendors at every changes in the source code
84+
COPY --link composer.* symfony.* ./
85+
RUN set -eux; \
86+
composer install --no-cache --prefer-dist --no-dev --no-autoloader --no-scripts --no-progress
87+
88+
# copy sources
89+
COPY --link . ./
90+
RUN rm -Rf frankenphp/
91+
92+
RUN set -eux; \
93+
mkdir -p var/cache var/log; \
94+
composer dump-autoload --classmap-authoritative --no-dev; \
95+
composer dump-env prod; \
96+
composer run-script --no-dev post-install-cmd; \
97+
chmod +x bin/console; sync;

Makefile

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Executables (local)
2+
DOCKER_COMP = docker compose
3+
4+
# Docker containers
5+
PHP_CONT = $(DOCKER_COMP) exec php
6+
7+
# Executables
8+
PHP = $(PHP_CONT) php
9+
COMPOSER = $(PHP_CONT) composer
10+
SYMFONY = $(PHP_CONT) bin/console
11+
PHPUNIT = $(PHP_CONT) bin/phpunit
12+
13+
# Misc
14+
.DEFAULT_GOAL = help
15+
16+
## —— 🎵 🐳 The Symfony Docker Makefile 🐳 🎵 ——————————————————————————————————
17+
help: ## Outputs this help screen
18+
@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/'
19+
20+
## —— Docker 🐳 ————————————————————————————————————————————————————————————————
21+
build: ## Builds the Docker images
22+
@$(DOCKER_COMP) build --pull --no-cache
23+
24+
up: ## Start the docker hub in detached mode (no logs)
25+
@$(DOCKER_COMP) up --detach
26+
27+
start: build up ## Build and start the containers
28+
29+
down: ## Stop the docker hub
30+
@$(DOCKER_COMP) down --remove-orphans
31+
32+
logs: ## Show live logs
33+
@$(DOCKER_COMP) logs --tail=0 --follow
34+
35+
restart: down up ## Restarts the containers
36+
37+
sh: ## Connect to the PHP FPM container
38+
@$(PHP_CONT) sh
39+
40+
## —— Composer 🧙 ——————————————————————————————————————————————————————————————
41+
composer: ## Run composer, pass the parameter "c=" to run a given command, example: make composer c='req symfony/orm-pack'
42+
@$(eval c ?=)
43+
@$(COMPOSER) $(c)
44+
45+
vendor: ## Install vendors according to the current composer.lock file
46+
vendor: c=install --prefer-dist --no-dev --no-progress --no-scripts --no-interaction
47+
vendor: composer
48+
49+
## —— Symfony 🎵 ———————————————————————————————————————————————————————————————
50+
sf: ## List all Symfony commands or pass the parameter "c=" to run a given command, example: make sf c=about
51+
@$(eval c ?=)
52+
@$(SYMFONY) $(c)
53+
54+
cc: c=c:c ## Clear the cache
55+
cc: sf
56+
57+
install: ## Install dependencies
58+
@$(COMPOSER) install
59+
60+
watch: ## Watch assets
61+
@$(SYMFONY) importmap:update
62+
@$(SYMFONY) tailwind:build --watch
63+
64+
## —— Phpunit 🎵 ———————————————————————————————————————————————————————————————
65+
test: ## Execute all tests
66+
@$(PHPUNIT)
67+
68+
## —— Quality 🎵 ———————————————————————————————————————————————————————————————
69+
qa: ## Execute all Quality tools
70+
@$(PHP) vendor/bin/rector process
71+
@$(PHP) vendor/bin/ecs check --fix
72+
@$(PHP) vendor/bin/phpstan analyse --memory-limit=512M
73+
74+
75+
## —— Project 🎵 ———————————————————————————————————————————————————————————————
76+
init: ## Initialization of DB and the data
77+
@$(SYMFONY) d:d:c --if-not-exists
78+
@$(SYMFONY) d:m:m -n
79+
@$(SYMFONY) app:init:users
80+
@$(SYMFONY) app:init:regions
81+
@$(SYMFONY) app:init:departments
82+
@$(SYMFONY) app:init:cities

assets/app.js

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import './bootstrap.js';
12
/*
23
* Welcome to your app's main JavaScript file!
34
*
@@ -6,10 +7,3 @@
67
*/
78

89
// any CSS you import will output into a single css file (app.css in this case)
9-
import './styles/app.scss';
10-
11-
12-
// start the Stimulus application
13-
import './bootstrap';
14-
15-
import "@fortawesome/fontawesome-free/js/all"

assets/bootstrap.js

+2-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
1-
import { startStimulusApp } from '@symfony/stimulus-bridge';
2-
3-
// Registers Stimulus controllers from controllers.json and in the controllers/ directory
4-
export const app = startStimulusApp(require.context(
5-
'@symfony/stimulus-bridge/lazy-controller-loader!./controllers',
6-
true,
7-
/\.[jt]sx?$/
8-
));
1+
import { startStimulusApp } from '@symfony/stimulus-bundle';
92

3+
const app = startStimulusApp();
104
// register any custom, 3rd party controllers here
115
// app.register('some_controller_name', SomeImportedController);

assets/controllers/toast_controller.js

-16
This file was deleted.

assets/images/avatar.jpg

75.6 KB
Loading
Loading
Loading
Loading
Loading

assets/styles/app.css

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@tailwind base;
2+
@tailwind components;
3+
@tailwind utilities;

assets/styles/app.scss

-109
This file was deleted.

0 commit comments

Comments
 (0)