fix: Docker FPM on port 9000, proper healthcheck, runtime dep install

- Slim Dockerfile to env-only (deps install at container start via volume mount)
- Add FastCGI ping healthcheck instead of broken HTTP curl
- App startup: composer install + migrate + php-fpm
- Remove obsolete docker-compose version key
This commit is contained in:
Thorsten Bus 2026-03-30 17:29:32 +02:00
parent 07008f3f33
commit 6c7c6c076d
3 changed files with 16 additions and 30 deletions

View file

@ -1,6 +1,5 @@
FROM php:8.4-fpm-alpine FROM php:8.4-fpm-alpine
# Install system dependencies
RUN apk add --no-cache \ RUN apk add --no-cache \
curl \ curl \
git \ git \
@ -17,43 +16,24 @@ RUN apk add --no-cache \
postgresql-client \ postgresql-client \
mysql-client \ mysql-client \
nodejs \ nodejs \
npm npm \
fcgi
# Install PHP extensions (only those not built-in)
RUN docker-php-ext-install \ RUN docker-php-ext-install \
pdo_sqlite \ pdo_sqlite \
pdo_mysql \ pdo_mysql \
zip \ zip \
bcmath bcmath
# Install Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
# Set working directory
WORKDIR /app WORKDIR /app
# Copy application files COPY build/fpm-healthcheck.conf /usr/local/etc/php-fpm.d/zz-healthcheck.conf
COPY . .
# Install PHP dependencies EXPOSE 9000
RUN composer install --no-interaction --no-dev --optimize-autoloader
# Install Node dependencies HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
RUN npm install --legacy-peer-deps CMD SCRIPT_NAME=/ping SCRIPT_FILENAME=/ping REQUEST_METHOD=GET cgi-fcgi -bind -connect 127.0.0.1:9000 | grep -q pong || exit 1
# Build Vite assets
RUN npm run build
# Create necessary directories
RUN mkdir -p storage/logs storage/framework/views storage/framework/cache \
&& chmod -R 775 storage bootstrap/cache
# Expose port
EXPOSE 8000
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8000/up || exit 1
# Start PHP-FPM
CMD ["php-fpm"] CMD ["php-fpm"]

View file

@ -0,0 +1,3 @@
[www]
ping.path = /ping
ping.response = pong

View file

@ -1,5 +1,3 @@
version: "3.8"
services: services:
app: app:
build: build:
@ -8,7 +6,12 @@ services:
container_name: pp-planer-app container_name: pp-planer-app
restart: unless-stopped restart: unless-stopped
working_dir: /app working_dir: /app
command: sh -c "composer install --no-interaction && php-fpm" command: >-
sh -c "composer install --no-interaction
&& mkdir -p storage/logs storage/framework/views storage/framework/cache
&& chmod -R 775 storage bootstrap/cache
&& php artisan migrate --force
&& php-fpm"
environment: environment:
- APP_ENV=${APP_ENV} - APP_ENV=${APP_ENV}
- APP_DEBUG=${APP_DEBUG} - APP_DEBUG=${APP_DEBUG}
@ -26,7 +29,7 @@ services:
- /app/node_modules - /app/node_modules
- /app/vendor - /app/vendor
ports: ports:
- "8000:8000" - "9000:9000"
networks: networks:
- pp-planer-network - pp-planer-network
depends_on: depends_on: