Files
project-manager/Dockerfile
T
aneurinandClaude Sonnet 5 d9db4a3a30 Serve the built SPA from the PHP image; drop the web container
The Dockerfile is now multi-stage: a Node stage runs `npm run build`, and the
PHP/Apache stage copies the result into public/. Apache + public/.htaccess route
/api* to the Slim front controller, serve real files, and fall back to
index.html for client-side routes.

docker-compose.yml loses the `web` service, its volume, and the source
bind-mount -- the image is the artifact now (rebuild to pick up changes).
Frontend dev moves to `npm run dev` on the host; APP_URL defaults to :8080 since
the one container serves both halves.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-04 13:37:07 +01:00

59 lines
2.1 KiB
Docker

# syntax=docker/dockerfile:1
# --- Stage 1: build the Vue frontend ---------------------------------------
FROM node:24-alpine AS frontend
WORKDIR /web
# Dependencies in their own layer, cached unless the manifests change. npm ci
# resolves this stage's (musl) platform binaries for rollup/esbuild.
COPY web/package.json web/package-lock.json ./
RUN npm ci
COPY web/ ./
RUN npm run build # vue-tsc type-check, then `vite build` -> /web/dist
# --- Stage 2: PHP + Apache runtime ---------------------------------------------
FROM php:8.3-apache
# --- PHP extensions and CLI tools ----------------------------------------------
RUN apt-get update && apt-get install -y --no-install-recommends \
libsqlite3-dev \
libonig-dev \
unzip \
curl \
&& docker-php-ext-install pdo_sqlite mbstring \
&& rm -rf /var/lib/apt/lists/*
# --- Composer ----------------------------------------------------------------
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
# --- Apache: document root -> public/, allow .htaccess rewrites -------------
RUN a2enmod rewrite
COPY docker/apache.conf /etc/apache2/sites-available/000-default.conf
WORKDIR /var/www/html
# --- PHP dependencies (own layer, cached unless composer.* changes) --------
COPY composer.json composer.lock ./
RUN composer install --no-dev --no-interaction --no-progress --prefer-dist --no-autoloader
# --- Application source ----------------------------------------------------
COPY . .
RUN composer dump-autoload --optimize --no-dev \
&& mkdir -p storage \
&& chown -R www-data:www-data storage
# --- Built frontend: served from the web root next to the API front controller
COPY --from=frontend /web/dist/ ./public/
# --- Entrypoint: migrate, then hand off to Apache ------------------------
COPY docker/entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
CMD ["apache2-foreground"]
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s \
CMD curl -fsS http://localhost/api/health || exit 1