feat: enterprise-grade Docker setup for Dokploy deployment
- Add multi-stage Dockerfile (node-builder, composer-builder, production) - Add Nginx config with WebSocket proxy at /_ws path - Add PHP-FPM pool config, php.ini with OPcache tuning - Add Supervisord managing 7 processes: php-fpm, nginx, horizon, scheduler, reverb, pulse-check, pulse-work - Add entrypoint.sh with auto-migration, config caching, storage setup - Add .dockerignore and .env.production.example - Install laravel/horizon for production queue management and dashboard - Install laravel/pulse for production monitoring with Reverb integration - Configure TrustProxies middleware for HTTPS behind Traefik - Add horizon:snapshot to scheduler - Add VITE_REVERB_PATH for WebSocket path routing through Nginx
This commit is contained in:
76
Dockerfile
Normal file
76
Dockerfile
Normal file
@@ -0,0 +1,76 @@
|
||||
# 1. Node Builder Stage
|
||||
FROM node:22-alpine AS node-builder
|
||||
WORKDIR /app
|
||||
COPY package.json package-lock.json ./
|
||||
RUN npm ci
|
||||
COPY ./ ./
|
||||
RUN npm run build
|
||||
|
||||
# 2. Composer Builder Stage
|
||||
FROM php:8.4-cli-alpine AS composer-builder
|
||||
RUN apk add --no-cache unzip
|
||||
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
|
||||
WORKDIR /app
|
||||
COPY composer.json composer.lock ./
|
||||
# Note: ignoring platform requirements since mongo/redis aren't natively in this alpine CLI image
|
||||
RUN composer install --no-dev --no-scripts --no-autoloader --prefer-dist --ignore-platform-reqs
|
||||
COPY ./ ./
|
||||
RUN composer dump-autoload --optimize --no-dev
|
||||
|
||||
# 3. Production Stage
|
||||
FROM php:8.4-fpm-alpine
|
||||
WORKDIR /var/www/html
|
||||
|
||||
# Install system dependencies
|
||||
RUN apk add --no-cache \
|
||||
nginx \
|
||||
supervisor \
|
||||
libpng-dev \
|
||||
libjpeg-turbo-dev \
|
||||
freetype-dev \
|
||||
libzip-dev \
|
||||
icu-dev \
|
||||
git \
|
||||
$PHPIZE_DEPS \
|
||||
linux-headers \
|
||||
openssl-dev
|
||||
|
||||
# Install PHP extensions
|
||||
RUN docker-php-ext-configure gd --with-freetype --with-jpeg \
|
||||
&& docker-php-ext-install -j$(nproc) \
|
||||
pdo_mysql \
|
||||
gd \
|
||||
zip \
|
||||
intl \
|
||||
bcmath \
|
||||
pcntl \
|
||||
opcache \
|
||||
sockets
|
||||
|
||||
# Install PECL extensions (MongoDB and Redis)
|
||||
RUN pecl install mongodb redis \
|
||||
&& docker-php-ext-enable mongodb redis \
|
||||
&& rm -rf /tmp/pear
|
||||
|
||||
# Copy source code and vendor dependencies
|
||||
COPY . .
|
||||
COPY --from=composer-builder /app/vendor ./vendor
|
||||
COPY --from=node-builder /app/public/build ./public/build
|
||||
|
||||
# Copy configuration files
|
||||
COPY docker/nginx.conf /etc/nginx/http.d/default.conf
|
||||
COPY docker/php-fpm.conf /usr/local/etc/php-fpm.d/www.conf
|
||||
COPY docker/php.ini /usr/local/etc/php/conf.d/production.ini
|
||||
COPY docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
||||
COPY docker/entrypoint.sh /usr/local/bin/entrypoint.sh
|
||||
|
||||
# Make entrypoint executable
|
||||
RUN chmod +x /usr/local/bin/entrypoint.sh
|
||||
|
||||
# Cleanup
|
||||
RUN apk del $PHPIZE_DEPS \
|
||||
&& rm -rf /var/cache/apk/*
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
|
||||
Reference in New Issue
Block a user