Skip to content

Commit 5ccbed7

Browse files
committed
Setup initial containerisation with Caddy/frankenphp
1 parent 1450f4b commit 5ccbed7

3 files changed

Lines changed: 102 additions & 0 deletions

File tree

.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.git
2+
node_modules
3+
Dockerfile

Caddyfile

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# The Caddyfile is an easy way to configure FrankenPHP and the Caddy web server.
2+
#
3+
# https://frankenphp.dev/docs/config
4+
# https://caddyserver.com/docs/caddyfile
5+
6+
{
7+
skip_install_trust
8+
9+
{$CADDY_GLOBAL_OPTIONS}
10+
11+
frankenphp {
12+
{$FRANKENPHP_CONFIG}
13+
}
14+
15+
auto_https off
16+
}
17+
18+
{$CADDY_EXTRA_CONFIG}
19+
20+
http:// {
21+
#log {
22+
# # Redact the authorization query parameter that can be set by Mercure
23+
# format filter {
24+
# request>uri query {
25+
# replace authorization REDACTED
26+
# }
27+
# }
28+
#}
29+
30+
root /app/public
31+
encode zstd br gzip
32+
33+
# Uncomment the following lines to enable Mercure and Vulcain modules
34+
#mercure {
35+
# # Transport to use (default to Bolt)
36+
# transport_url {$MERCURE_TRANSPORT_URL:bolt:///data/mercure.db}
37+
# # Publisher JWT key
38+
# publisher_jwt {env.MERCURE_PUBLISHER_JWT_KEY} {env.MERCURE_PUBLISHER_JWT_ALG}
39+
# # Subscriber JWT key
40+
# subscriber_jwt {env.MERCURE_SUBSCRIBER_JWT_KEY} {env.MERCURE_SUBSCRIBER_JWT_ALG}
41+
# # Allow anonymous subscribers (double-check that it's what you want)
42+
# anonymous
43+
# # Enable the subscription API (double-check that it's what you want)
44+
# subscriptions
45+
# # Extra directives
46+
# {$MERCURE_EXTRA_DIRECTIVES}
47+
#}
48+
#vulcain
49+
50+
{$CADDY_SERVER_EXTRA_DIRECTIVES}
51+
52+
php_server {
53+
}
54+
}
55+
56+
# As an alternative to editing the above site block, you can add your own site
57+
# block files in the Caddyfile.d directory, and they will be included as long
58+
# as they use the .caddyfile extension.
59+
60+
import Caddyfile.d/*.caddyfile

Dockerfile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
FROM node:24.10 AS buildpublic
2+
WORKDIR /usr/local/src/bmac
3+
4+
5+
# Build public elements.
6+
COPY webpack.mix.js .
7+
COPY resources/ resources/
8+
COPY public/ public/
9+
COPY *.json .
10+
COPY artisan .
11+
12+
RUN npm i --omit dev
13+
RUN npm i laravel-mix
14+
RUN npx mix --production
15+
16+
RUN rm -rf node_modules/
17+
18+
FROM dunglas/frankenphp:1.9.1-php8.2 AS run
19+
20+
# Required extensions for app and composer.
21+
RUN apt update && apt install git zip -y
22+
RUN install-php-extensions mysqli pdo pdo_mysql
23+
24+
WORKDIR /app
25+
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
26+
COPY . .
27+
COPY --from=buildpublic /usr/local/src/bmac/public /app/public/
28+
29+
# Setup php server
30+
COPY ./Caddyfile /etc/frankenphp/Caddyfile
31+
RUN cp $PHP_INI_DIR/php.ini-production $PHP_INI_DIR/php.ini
32+
33+
RUN composer install --no-dev -o --ignore-platform-reqs
34+
35+
RUN php artisan storage:link
36+
37+
WORKDIR /app/public
38+
39+
EXPOSE 80

0 commit comments

Comments
 (0)