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:
parent
07008f3f33
commit
6c7c6c076d
|
|
@ -1,6 +1,5 @@
|
|||
FROM php:8.4-fpm-alpine
|
||||
|
||||
# Install system dependencies
|
||||
RUN apk add --no-cache \
|
||||
curl \
|
||||
git \
|
||||
|
|
@ -17,43 +16,24 @@ RUN apk add --no-cache \
|
|||
postgresql-client \
|
||||
mysql-client \
|
||||
nodejs \
|
||||
npm
|
||||
npm \
|
||||
fcgi
|
||||
|
||||
# Install PHP extensions (only those not built-in)
|
||||
RUN docker-php-ext-install \
|
||||
pdo_sqlite \
|
||||
pdo_mysql \
|
||||
zip \
|
||||
bcmath
|
||||
|
||||
# Install Composer
|
||||
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Copy application files
|
||||
COPY . .
|
||||
COPY build/fpm-healthcheck.conf /usr/local/etc/php-fpm.d/zz-healthcheck.conf
|
||||
|
||||
# Install PHP dependencies
|
||||
RUN composer install --no-interaction --no-dev --optimize-autoloader
|
||||
EXPOSE 9000
|
||||
|
||||
# Install Node dependencies
|
||||
RUN npm install --legacy-peer-deps
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
|
||||
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"]
|
||||
|
|
|
|||
3
build/fpm-healthcheck.conf
Normal file
3
build/fpm-healthcheck.conf
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
[www]
|
||||
ping.path = /ping
|
||||
ping.response = pong
|
||||
|
|
@ -1,5 +1,3 @@
|
|||
version: "3.8"
|
||||
|
||||
services:
|
||||
app:
|
||||
build:
|
||||
|
|
@ -8,7 +6,12 @@ services:
|
|||
container_name: pp-planer-app
|
||||
restart: unless-stopped
|
||||
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:
|
||||
- APP_ENV=${APP_ENV}
|
||||
- APP_DEBUG=${APP_DEBUG}
|
||||
|
|
@ -26,7 +29,7 @@ services:
|
|||
- /app/node_modules
|
||||
- /app/vendor
|
||||
ports:
|
||||
- "8000:8000"
|
||||
- "9000:9000"
|
||||
networks:
|
||||
- pp-planer-network
|
||||
depends_on:
|
||||
|
|
|
|||
Loading…
Reference in a new issue