diff --git a/build/Dockerfile b/build/Dockerfile index 560ab0f..1b555cc 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -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"] diff --git a/build/fpm-healthcheck.conf b/build/fpm-healthcheck.conf new file mode 100644 index 0000000..4cb85e2 --- /dev/null +++ b/build/fpm-healthcheck.conf @@ -0,0 +1,3 @@ +[www] +ping.path = /ping +ping.response = pong diff --git a/docker-compose.yml b/docker-compose.yml index 11073f2..e6f504b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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: