117 lines
No EOL
3 KiB
Text
117 lines
No EOL
3 KiB
Text
# Development Dockerfile with FrankenPHP
|
|
FROM dunglas/frankenphp:latest-php8.3-alpine
|
|
|
|
# Install system dependencies + development tools (except nodejs/npm)
|
|
RUN apk add --no-cache \
|
|
git \
|
|
mysql-client \
|
|
vim \
|
|
bash \
|
|
nano \
|
|
curl
|
|
|
|
# Install Node.js 20.19.0+ from NodeSource (for compatibility with Vite 7)
|
|
RUN curl -fsSL https://unofficial-builds.nodejs.org/download/release/v20.19.0/node-v20.19.0-linux-x64-musl.tar.xz | tar -xJ -C /usr/local --strip-components=1
|
|
|
|
# Install PHP extensions including xdebug for development
|
|
RUN install-php-extensions \
|
|
pdo_mysql \
|
|
opcache \
|
|
zip \
|
|
gd \
|
|
intl \
|
|
xdebug
|
|
|
|
# Install Composer
|
|
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Configure PHP for development
|
|
RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"
|
|
|
|
# Configure Xdebug (disabled by default to reduce noise)
|
|
RUN echo "xdebug.mode=off" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
|
|
&& echo ";xdebug.mode=debug" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
|
|
&& echo ";xdebug.client_host=host.docker.internal" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
|
|
&& echo ";xdebug.start_with_request=yes" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
|
|
|
|
# Configure Caddy for development (simpler, no worker mode)
|
|
RUN cat > /etc/caddy/Caddyfile <<EOF
|
|
{
|
|
frankenphp
|
|
order php_server before file_server
|
|
}
|
|
|
|
:8000 {
|
|
root * /app/public
|
|
|
|
php_server {
|
|
index index.php
|
|
}
|
|
|
|
encode gzip
|
|
|
|
file_server
|
|
|
|
# Less strict headers for development
|
|
header {
|
|
X-Frame-Options "SAMEORIGIN"
|
|
}
|
|
}
|
|
EOF
|
|
|
|
# Install Node development dependencies globally
|
|
RUN npm install -g nodemon
|
|
|
|
# Create startup script for development (runs as host user)
|
|
RUN cat > /start.sh <<'EOF'
|
|
#!/bin/sh
|
|
set -e
|
|
|
|
# Fix DNS resolution by adding db host entry
|
|
# This is a workaround for podman-compose DNS issues
|
|
echo "10.89.1.2 db" >> /etc/hosts 2>/dev/null || true
|
|
|
|
# Create .env file if it doesn't exist
|
|
if [ ! -f ".env" ]; then
|
|
echo "Creating .env file from .env.example..."
|
|
cp .env.example .env
|
|
fi
|
|
|
|
# Skip composer install - use mounted vendor directory
|
|
echo "Using mounted vendor directory, skipping composer install"
|
|
|
|
# Skip npm install - use mounted node_modules
|
|
echo "Using mounted node_modules directory, skipping npm install"
|
|
|
|
# Clear Laravel caches
|
|
php artisan config:clear || true
|
|
php artisan cache:clear || true
|
|
|
|
# Wait for database and run migrations
|
|
echo "Waiting for database..."
|
|
sleep 5
|
|
php artisan migrate --force || echo "Migration failed or not needed"
|
|
|
|
# Generate app key if not set
|
|
if [ -z "$APP_KEY" ] || [ "$APP_KEY" = "base64:YOUR_KEY_HERE" ]; then
|
|
echo "Generating application key..."
|
|
php artisan key:generate
|
|
fi
|
|
|
|
# Start Vite dev server in background
|
|
npm run dev &
|
|
|
|
# Start FrankenPHP
|
|
exec frankenphp run --config /etc/caddy/Caddyfile
|
|
EOF
|
|
|
|
RUN chmod +x /start.sh
|
|
|
|
# Expose ports
|
|
EXPOSE 8000 5173
|
|
|
|
# Use the startup script
|
|
CMD ["/start.sh"] |