-
-
Notifications
You must be signed in to change notification settings - Fork 2
feat: Add FrankenPHP
support with docker configuration and Caddyserver
setup.
#105
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,25 @@ | ||
|
||
services: | ||
yii2-frankenphp: | ||
build: | ||
dockerfile: docker/frankenphp/Dockerfile | ||
container_name: yii2-frankenphp | ||
restart: always | ||
working_dir: /app | ||
volumes: | ||
- ./:/app | ||
- ~/.composer-docker/cache:/root/.composer/cache:delegated | ||
- caddy_data:/data | ||
- caddy_config:/config | ||
ports: | ||
- '8082:80' | ||
- '8443:443' | ||
- '8443:443/udp' | ||
environment: | ||
TZ: "UTC" | ||
tty: true | ||
|
||
# Volumes needed for Caddy certificates and configuration | ||
volumes: | ||
caddy_data: | ||
caddy_config: |
This file contains hidden or 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,52 @@ | ||
{ | ||
# Global options | ||
auto_https off | ||
} | ||
|
||
# Main server block | ||
:80 { | ||
# Document root | ||
root * /app/public | ||
|
||
# Enable PHP processing with FrankenPHP | ||
php_server | ||
|
||
# Security headers | ||
header { | ||
X-Frame-Options "SAMEORIGIN" | ||
X-XSS-Protection "1; mode=block" | ||
X-Content-Type-Options "nosniff" | ||
-Server | ||
} | ||
|
||
# Logging | ||
log { | ||
output stdout | ||
format console | ||
} | ||
|
||
# Handle static files | ||
@static { | ||
file | ||
path *.css *.js *.png *.jpg *.jpeg *.gif *.ico *.svg *.woff *.woff2 *.ttf *.eot | ||
} | ||
handle @static { | ||
header Cache-Control "public, max-age=31536000" | ||
file_server | ||
} | ||
|
||
# Block access to sensitive directories | ||
@forbidden { | ||
path /.git/* /vendor/* /runtime/* /.env* | ||
} | ||
respond @forbidden 404 | ||
|
||
# Deny PHP execution in assets directory (Yii2 security) | ||
@assets_php { | ||
path /assets/*.php | ||
} | ||
respond @assets_php 403 | ||
|
||
# Try files for Yii2 URL rewriting | ||
try_files {path} {path}/ /index.php?{query} | ||
} |
This file contains hidden or 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,53 @@ | ||
FROM dunglas/frankenphp:1.8-php8.4 | ||
|
||
# change web server config | ||
COPY docker/frankenphp/Caddyfile /etc/caddy/Caddyfile | ||
|
||
# set document root to /app/public (Yii2 structure) | ||
WORKDIR /app | ||
|
||
# install required system packages for PHP extensions for Yii 2.0 Framework | ||
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/ | ||
RUN install-php-extensions \ | ||
bcmath \ | ||
@composer \ | ||
exif \ | ||
gd \ | ||
imagick \ | ||
intl \ | ||
opcache \ | ||
pdo_mysql \ | ||
pdo_pgsql \ | ||
soap \ | ||
xdebug \ | ||
zip | ||
|
||
# set composer environment | ||
ENV COMPOSER_ALLOW_SUPERUSER=1 | ||
|
||
# change PHP config | ||
COPY docker/php/php.ini /usr/local/etc/php/conf.d/base.ini | ||
|
||
# install supervisord and Node.js (includes npm) | ||
RUN apt-get update && apt-get install -y \ | ||
supervisor \ | ||
curl \ | ||
--no-install-recommends \ | ||
&& curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - \ | ||
&& apt-get install -y nodejs \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | ||
|
||
# copy supervisord config | ||
COPY docker/frankenphp/supervisord/supervisord.conf /etc/supervisor/supervisord.conf | ||
|
||
# copy supervisord program configs | ||
COPY docker/frankenphp/supervisord/conf.d/frankenphp.conf /etc/supervisor/conf.d/frankenphp.conf | ||
|
||
# copy queue worker config uncommented for use with yii2-queue | ||
#COPY docker/frankenphp/supervisord/conf.d/queue.conf /etc/supervisor/conf.d/queue.conf | ||
|
||
RUN mkdir -p /var/run && chown -R www-data:www-data /var/run | ||
|
||
# Run supervisord | ||
CMD ["supervisord", "-c", "/etc/supervisor/supervisord.conf"] |
This file contains hidden or 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,13 @@ | ||
[program:frankenphp] | ||
command=/usr/local/bin/frankenphp run --config /etc/caddy/Caddyfile | ||
autostart=true | ||
autorestart=true | ||
priority=10 | ||
killasgroup=true | ||
stopasgroup=true | ||
stopsignal=QUIT | ||
stdout_logfile=/dev/stdout | ||
stdout_logfile_maxbytes=0 | ||
stderr_logfile=/dev/stderr | ||
stderr_logfile_maxbytes=0 | ||
user=www-data |
This file contains hidden or 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,14 @@ | ||
[program:yii-queue-worker] | ||
process_name=%(program_name)s_%(process_num)02d | ||
command=/usr/local/bin/php /app/yii queue/listen --verbose=1 --color=0 | ||
autorestart=true | ||
autostart=true | ||
killasgroup=true | ||
numprocs=4 | ||
redirect_stderr=true | ||
stderr_logfile=/dev/stderr | ||
stderr_logfile_maxbytes=0 | ||
stdout_logfile=/dev/stdout | ||
stdout_logfile_maxbytes=0 | ||
stopasgroup=true | ||
user=www-data |
This file contains hidden or 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,2 @@ | ||
* | ||
!.gitignore |
This file contains hidden or 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,15 @@ | ||
[supervisord] | ||
nodaemon=true | ||
logfile=/dev/stdout | ||
logfile_maxbytes=0 | ||
pidfile=/var/run/supervisord.pid | ||
|
||
[include] | ||
files = /etc/supervisor/conf.d/*.conf | ||
|
||
[supervisorctl] | ||
serverurl=unix:///var/run/supervisor.sock | ||
|
||
[unix_http_server] | ||
file=/var/run/supervisor.sock | ||
chmod=0700 | ||
terabytesoftw marked this conversation as resolved.
Show resolved
Hide resolved
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.