Skip to content

chore: Refactor Docker setup — single multi-stage Dockerfile + AIO image#2

Merged
bun4uk merged 6 commits into
bun4uk:mainfrom
everythings-gonna-be-alright:chore/improve-docker-containers
May 19, 2026
Merged

chore: Refactor Docker setup — single multi-stage Dockerfile + AIO image#2
bun4uk merged 6 commits into
bun4uk:mainfrom
everythings-gonna-be-alright:chore/improve-docker-containers

Conversation

@everythings-gonna-be-alright
Copy link
Copy Markdown
Contributor

Summary

Consolidates the Docker setup from a fragmented multi-file layout into a clean, security-hardened structure under docker/.

What changed

Dockerfile (Dockerfiledocker/Dockerfile)

  • Moved to docker/ and restructured as a proper multi-stage build:
    • vendor — Composer deps via composer:2.9.8 image
    • frontend — Node 24 + Vite build via node:24.15.0-alpine3.23
    • basephp:8.5.5-fpm-alpine3.23 runtime only (no nginx/supervisor)
    • aio — All-in-one target: adds nginx + supervisord into a single image for zero-dependency deployments (e.g. docker run -p 80:80)
  • Dedicated non-root user chadmin (UID 1984) owns the app files and runs PHP-FPM
  • Old Dockerfile at root deleted
    Configs (docker/configs/)
  • nginx.conf — main nginx config extracted from legacy docker/prod/nginx.conf
  • nginx-chadmin.conf — vhost config (was nested under docker/dev/nginx/)
  • php-fpm.conf — pool config (was docker/prod/php-fpm.conf)
  • supervisord.conf — manages nginx + php-fpm processes inside the aio target
    Entrypoint (docker/aio-entrypoint.sh)
  • Renamed from docker/entrypoint.sh
  • Generates a random APP_SECRET fallback if not set, preventing container crash on first run without full env config
    docker-compose.yml
  • Replaces heavyweight custom nginx + php Dockerfiles with:
    • nginxinc/nginx-unprivileged:1.31.0-alpine3.23-slim — rootless nginx out of the box
    • docker/Dockerfile base target for PHP-FPM
    • Official composer:latest and node:24.15.0-alpine3.23 images for deps
  • Unix socket (php-sock volume) for nginx ↔ PHP-FPM communication instead of TCP
    Deleted
  • docker/dev/nginx/Dockerfile, docker/dev/php/Dockerfile — replaced by official images
  • docker/prod/nginx.conf, php-fpm.conf, php.ini, supervisord.conf — consolidated into docker/configs/

Why

Before After
3 separate Dockerfiles 1 multi-stage Dockerfile with named targets
nginx ran as root rootless nginx-unprivileged (UID 1984)
Scattered prod configs All configs under docker/configs/
No single-container option aio target: one image, one docker run
dev/prod config duplication Single config set reused across compose + aio

Testing

# Dev (compose)
docker-compose up -d
open http://localhost
# AIO single container
docker build --target aio -t chadmin:aio -f docker/Dockerfile .
docker run -p 80:80 --env-file .env chadmin:aio
open http://localhost

@bun4uk bun4uk merged commit 0bb28f0 into bun4uk:main May 19, 2026
3 checks passed
bun4uk added a commit that referenced this pull request May 19, 2026
The CVE-2026-24049 mitigation from the original root Dockerfile
(commit d91576e) was dropped when the build moved to docker/Dockerfile
in #2. Re-add the rm -rf for /usr/lib/python*/site-packages/setuptools/_vendor/wheel-*.dist-info
inside the aio target's apk RUN. See vex/chadmin.openvex.json for rationale.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
bun4uk added a commit that referenced this pull request May 19, 2026
The Critical CVE-2023-27482 finding cleared in v2.0.1 because PR #2
bumped the base from alpine3.22 (supervisor 4.2.5-r5, matched by the
scanner) to alpine3.23 (supervisor 4.3.0-r0, out of range) — not
because Docker Scout honored the cosign-attached VEX. CVE-2026-24049
is handled directly by the wheel-*.dist-info removal in
docker/Dockerfile.

Removing the unproven layer of complexity:
- vex/chadmin.openvex.json deleted
- cosign install + attest steps removed from docker-publish.yml
- id-token: write permission no longer needed

If a scanner false-positive comes back, VEX can be reintroduced in
a few minutes — keeping it speculatively was not paying for itself.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants