Skip to content

Commit

Permalink
infra: update Docker config (#29)
Browse files Browse the repository at this point in the history
* rename docker-compose files

* update Dockerfile

* update frankenphp Caddyfile, docker-entrypoint.sh

* update ci.yml

* update .dockerignore

* update .editorconfig

close: #28
  • Loading branch information
n3wborn authored Nov 1, 2023
1 parent 2f8c2a0 commit 2981484
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 78 deletions.
5 changes: 4 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
**/.git/
**/.gitattributes
**/.gitignore
**/.gitmodules
***/compose.*.yaml
**/compose.*.yml
**/compose.yaml
**/compose.yml*/.gitmodules
**/docker-compose.*.yaml
**/docker-compose.*.yml
**/docker-compose.yaml
Expand Down
27 changes: 5 additions & 22 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,63 +12,46 @@ trim_trailing_whitespace = true
insert_final_newline = true

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

[*.json]
indent_style = space
indent_size = 2

[*.md]
trim_trailing_whitespace = false

[*.php]
indent_style = space
indent_size = 4

[*.sh]
indent_style = tab
indent_size = 4

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

[*.{yaml,yml}]
indent_style = space
indent_size = 4
trim_trailing_whitespace = false

[.github/workflows/*.yml]
indent_style = space
indent_size = 2

[.gitmodules]
indent_style = tab
indent_size = 4

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

[.travis.yml]
indent_style = space
indent_size = 2

[composer.json]
indent_style = space
indent_size = 4

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

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

[Makefile]
[{,*.*}Caddyfile]
indent_style = tab
indent_size = 4
tab_width = 4

[Makefile]
indent_style = tab
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Lint Dockerfile
uses: hadolint/[email protected]
tests:
Expand All @@ -28,18 +28,18 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3
-
name: Build Docker images
uses: docker/bake-action@v3
uses: docker/bake-action@v4
with:
load: true
files: |
docker-compose.yml
docker-compose.override.yml
compose.yaml
compose.override.yaml
set: |
*.cache-from=type=gha,scope=${{github.ref}}
*.cache-from=type=gha,scope=refs/heads/main
Expand Down
32 changes: 16 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@ WORKDIR /app
# persistent / runtime deps
# hadolint ignore=DL3018
RUN apk add --no-cache \
acl \
fcgi \
file \
gettext \
git \
postgresql-dev \
acl \
file \
gettext \
git \
postgresql-dev \
;

RUN set -eux; \
install-php-extensions \
apcu \
intl \
opcache \
zip \
pdo_pgsql \
;
install-php-extensions \
apcu \
intl \
opcache \
opcache \
zip \
pdo_pgsql \
;

COPY --link docker/frankenphp/conf.d/app.ini $PHP_INI_DIR/conf.d/
COPY --link --chmod=755 docker/frankenphp/docker-entrypoint.sh /usr/local/bin/docker-entrypoint
Expand All @@ -45,7 +45,7 @@ ENV PATH="${PATH}:/root/.composer/vendor/bin"

COPY --from=composer_upstream --link /composer /usr/bin/composer

HEALTHCHECK CMD wget --no-verbose --tries=1 --spider http://localhost:2019/metrics || exit 1
HEALTHCHECK --start-period=60s CMD curl -f http://localhost:2019/metrics || exit 1
CMD [ "frankenphp", "run", "--config", "/etc/caddy/Caddyfile" ]

# Dev FrankenPHP image
Expand All @@ -58,8 +58,8 @@ RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"

RUN set -eux; \
install-php-extensions \
xdebug \
;
xdebug \
;

COPY --link docker/frankenphp/conf.d/app.dev.ini $PHP_INI_DIR/conf.d/

Expand Down
1 change: 1 addition & 0 deletions docker-compose.override.yml → compose.override.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ services:
extra_hosts:
# Ensure that host.docker.internal is correctly defined on Linux
- host.docker.internal:host-gateway
tty: true

database:
image: postgres:${POSTGRES_VERSION:-15}-alpine
Expand Down
File renamed without changes.
File renamed without changes.
52 changes: 20 additions & 32 deletions docker/frankenphp/Caddyfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,31 @@
frankenphp {
{$FRANKENPHP_CONFIG}
}
}

{$SERVER_NAME:localhost}
# https://caddyserver.com/docs/caddyfile/directives#sorting-algorithm
order mercure after encode
order vulcain after reverse_proxy
order php_server before file_server
}

{$CADDY_EXTRA_CONFIG}

log {
# Redact the authorization query parameter that can be set by Mercure
format filter {
wrap console
fields {
uri query {
replace authorization REDACTED
{$SERVER_NAME:localhost} {
log {
# Redact the authorization query parameter that can be set by Mercure
format filter {
wrap console
fields {
uri query {
replace authorization REDACTED
}
}
}
}
}

route {
root * /app/public
encode zstd gzip

mercure {
# Transport to use (default to Bolt)
transport_url {$MERCURE_TRANSPORT_URL:bolt:///data/mercure.db}
Expand All @@ -38,28 +43,11 @@ route {
# Extra directives
{$MERCURE_EXTRA_DIRECTIVES}
}
vulcain

# Add trailing slash for directory requests
@canonicalPath {
file {path}/index.php
not path */
}
redir @canonicalPath {path}/ 308

# If the requested file does not exist, try index files
@indexFiles file {
try_files {path} {path}/index.php index.php
split_path .php
}
rewrite @indexFiles {http.matchers.file.relative}

# FrankenPHP!
@phpFiles path *.php
php @phpFiles
vulcain

encode zstd gzip
file_server
# Disable Topics tracking if not enabled explicitly: https://github.com/jkarlin/topics
header ?Permissions-Policy "browsing-topics=()"

respond 404
php_server
}
2 changes: 1 addition & 1 deletion docker/frankenphp/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -e

if [ "$1" = 'frankenphp' ] || [ "$1" = 'php' ] || [ "$1" = 'bin/console' ]; then
if [ ! -d 'vendor/' ]; then
if [ -z "$(ls -A 'vendor/' 2>/dev/null)" ]; then
composer install --prefer-dist --no-progress --no-interaction
fi

Expand Down

0 comments on commit 2981484

Please sign in to comment.