fedi-feed-router/docker/production/Dockerfile

85 lines
1.8 KiB
Text
Raw Normal View History

2025-08-02 03:22:09 +02:00
# Multi-stage build for FFR Laravel application
2025-08-12 01:14:02 +02:00
FROM node:22-alpine AS frontend-builder
2025-08-02 03:22:09 +02:00
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install Node dependencies
RUN npm ci
# Copy frontend source
COPY resources/ resources/
COPY public/ public/
COPY vite.config.js ./
COPY tsconfig.json ./
# Build frontend assets
RUN npm run build
# PHP runtime stage
FROM php:8.4-fpm-alpine
# Install system dependencies
RUN apk add --no-cache \
git \
curl \
libpng-dev \
libxml2-dev \
zip \
unzip \
oniguruma-dev \
mysql-client \
nginx \
supervisor \
autoconf \
gcc \
g++ \
make
# Install PHP extensions
RUN docker-php-ext-install \
pdo_mysql \
mbstring \
exif \
pcntl \
bcmath \
gd \
&& pecl install redis \
&& docker-php-ext-enable redis
# Install Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
# Set working directory
WORKDIR /var/www/html
# Copy application code first
COPY . .
# Install PHP dependencies after copying all files
RUN composer install --no-dev --optimize-autoloader --no-interaction
# Copy built frontend assets from builder stage
COPY --from=frontend-builder /app/public/build/ ./public/build/
# Copy nginx and supervisor configurations
COPY docker/production/nginx.conf /etc/nginx/http.d/default.conf
COPY docker/production/supervisord.conf /etc/supervisord.conf
COPY docker/production/start-app.sh /usr/local/bin/start-app
# Set proper permissions
RUN chown -R www-data:www-data storage bootstrap/cache public/build \
&& chmod -R 755 storage bootstrap/cache \
&& chmod +x /usr/local/bin/start-app
# Expose port 80 for nginx
EXPOSE 80
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD php artisan --version || exit 1
# Start the application
CMD ["/usr/local/bin/start-app"]