Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
19 changes: 0 additions & 19 deletions docker/Caddyfile

This file was deleted.

20 changes: 10 additions & 10 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
FROM composer/composer:2-bin AS composer

FROM dunglas/frankenphp:1-php8.5-bookworm AS base
FROM ghcr.io/freeunitorg/freeunit:latest-php8.5 AS base

RUN apt update && apt -y install \
unzip
unzip \
curl

RUN install-php-extensions \
opcache \
Expand Down Expand Up @@ -37,17 +38,16 @@ ARG GROUP_NAME=appuser

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

# Based on https://frankenphp.dev/docs/docker/#running-as-a-non-root-user
RUN \
groupadd --gid ${GROUP_ID} ${GROUP_NAME}; \
groupadd --gid ${GROUP_ID} ${GROUP_NAME}; \
useradd --gid ${GROUP_ID} --uid ${USER_ID} ${GROUP_NAME}; \
# Add additional capability to bind to port 80 and 443
setcap CAP_NET_BIND_SERVICE=+eip /usr/local/bin/frankenphp; \
# Give write access to /data/caddy and /config/caddy
chown -R ${USER_NAME}:${GROUP_NAME} /data/caddy && chown -R ${USER_NAME}:${GROUP_NAME} /config/caddy
# Give write access to /var/run for Unit control socket
mkdir -p /var/run && chown -R ${USER_NAME}:${GROUP_NAME} /var/run; \
# Give write access to runtime directory
mkdir -p /app/runtime && chown -R ${USER_NAME}:${GROUP_NAME} /app/runtime
USER ${USER_NAME}

COPY docker/dev/Caddyfile /etc/frankenphp/Caddyfile
COPY docker/dev/unit-config.json /var/lib/unit/config.json

#
# Production
Expand All @@ -62,6 +62,6 @@ RUN --mount=type=cache,target=/tmp/cache \

FROM base AS prod
ENV APP_ENV=prod
COPY docker/Caddyfile /etc/frankenphp/Caddyfile
COPY docker/unit-config.json /var/lib/unit/config.json
COPY --from=prod-builder --chown=www-data:www-data /app /app
USER www-data
2 changes: 0 additions & 2 deletions docker/compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,5 @@ services:
- "host.docker.internal:host-gateway"

volumes:
caddy_data:
caddy_config:
postgres_data:
valkey_data:
20 changes: 0 additions & 20 deletions docker/dev/Caddyfile

This file was deleted.

43 changes: 43 additions & 0 deletions docker/dev/unit-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"listeners": {
"*:80": {
"pass": "routes"
}
},
"routes": [
{
"match": {
"uri": [
"!/assets/*",
"*.php",
"*.php/*"
]
},
"action": {
"pass": "applications/yii/direct"
}
},
{
"action": {
"share": "/app/public$uri",
"fallback": {
"pass": "applications/yii/index"
}
}
}
],
"applications": {
"yii": {
"type": "php",
"targets": {
"direct": {
"root": "/app/public/"
},
"index": {
"root": "/app/public/",
"script": "index.php"
}
}
}
}
}
13 changes: 2 additions & 11 deletions docker/prod/compose.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
services:
app:
image: ${IMAGE}:${IMAGE_TAG}
networks:
- caddy_public
ports:
- "80:80"
volumes:
- runtime:/app/runtime
- caddy_data:/data
- caddy_config:/config
env_file:
- path: ./prod/.env
- path: ./prod/override.env
Expand All @@ -27,13 +25,6 @@ services:
delay: 5s
max_attempts: 3
window: 120s
labels:
caddy: ${PROD_HOST:-app-api.example.com}
caddy.reverse_proxy: "{{upstreams 80}}"

volumes:
runtime:

networks:
caddy_public:
external: true
43 changes: 43 additions & 0 deletions docker/unit-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"listeners": {
"*:80": {
"pass": "routes"
}
},
"routes": [
{
"match": {
"uri": [
"!/assets/*",
"*.php",
"*.php/*"
]
},
"action": {
"pass": "applications/yii/direct"
}
},
{
"action": {
"share": "/app/public$uri",
"fallback": {
"pass": "applications/yii/index"
}
}
}
],
"applications": {
"yii": {
"type": "php",
"targets": {
"direct": {
"root": "/app/public/"
},
"index": {
"root": "/app/public/",
"script": "index.php"
}
}
}
}
}
Loading