Add production Dockerfile (php-fpm + nginx) for Coolify
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,17 @@
|
|||||||
|
.git
|
||||||
|
.gitignore
|
||||||
|
.github
|
||||||
|
node_modules
|
||||||
|
vendor
|
||||||
|
public/build
|
||||||
|
public/hot
|
||||||
|
.env
|
||||||
|
.env.*
|
||||||
|
storage/logs/*
|
||||||
|
storage/framework/cache/data/*
|
||||||
|
storage/framework/sessions/*
|
||||||
|
storage/framework/views/*
|
||||||
|
tests
|
||||||
|
.phpunit.result.cache
|
||||||
|
.DS_Store
|
||||||
|
README.md
|
||||||
+53
@@ -0,0 +1,53 @@
|
|||||||
|
# syntax=docker/dockerfile:1
|
||||||
|
|
||||||
|
# ---------- Stage 1: Frontend assets (Vite + Tailwind) ----------
|
||||||
|
FROM node:20-alpine AS assets
|
||||||
|
WORKDIR /app
|
||||||
|
COPY package.json package-lock.json ./
|
||||||
|
RUN npm ci
|
||||||
|
COPY resources ./resources
|
||||||
|
COPY vite.config.js ./
|
||||||
|
COPY public ./public
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
# ---------- Stage 2: PHP runtime (php-fpm + nginx) ----------
|
||||||
|
FROM serversideup/php:8.3-fpm-nginx AS app
|
||||||
|
|
||||||
|
# Install PHP extensions the app needs
|
||||||
|
USER root
|
||||||
|
RUN install-php-extensions \
|
||||||
|
pdo_mysql \
|
||||||
|
bcmath \
|
||||||
|
gd \
|
||||||
|
intl \
|
||||||
|
zip \
|
||||||
|
exif \
|
||||||
|
pcntl \
|
||||||
|
redis \
|
||||||
|
opcache
|
||||||
|
|
||||||
|
WORKDIR /var/www/html
|
||||||
|
|
||||||
|
# Composer dependencies first (better layer caching)
|
||||||
|
COPY --chown=www-data:www-data composer.json composer.lock ./
|
||||||
|
RUN composer install \
|
||||||
|
--no-dev \
|
||||||
|
--no-scripts \
|
||||||
|
--no-autoloader \
|
||||||
|
--prefer-dist \
|
||||||
|
--no-interaction
|
||||||
|
|
||||||
|
# Application source
|
||||||
|
COPY --chown=www-data:www-data . .
|
||||||
|
|
||||||
|
# Compiled frontend assets from stage 1
|
||||||
|
COPY --chown=www-data:www-data --from=assets /app/public/build ./public/build
|
||||||
|
|
||||||
|
# Optimize autoloader
|
||||||
|
RUN composer dump-autoload --optimize --no-dev --no-interaction
|
||||||
|
|
||||||
|
# Runtime init (migrate + cache) runs on container start
|
||||||
|
COPY --chown=www-data:www-data docker/entrypoint.d/ /etc/entrypoint.d/
|
||||||
|
RUN chmod +x /etc/entrypoint.d/*.sh
|
||||||
|
|
||||||
|
USER www-data
|
||||||
Executable
+16
@@ -0,0 +1,16 @@
|
|||||||
|
#!/command/with-contenv bash
|
||||||
|
# Runs on every container start (after DB/Redis are reachable on the Coolify network).
|
||||||
|
set -e
|
||||||
|
|
||||||
|
cd /var/www/html
|
||||||
|
|
||||||
|
# Storage symlink (idempotent)
|
||||||
|
php artisan storage:link 2>/dev/null || true
|
||||||
|
|
||||||
|
# Run pending migrations
|
||||||
|
php artisan migrate --force --no-interaction || true
|
||||||
|
|
||||||
|
# Cache config/routes/views for production speed
|
||||||
|
php artisan config:cache
|
||||||
|
php artisan route:cache
|
||||||
|
php artisan view:cache
|
||||||
Reference in New Issue
Block a user