fedi-feed-router/docker/production/Dockerfile

87 lines
1.9 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
2025-08-12 12:17:27 +02:00
# Copy frontend package files
COPY frontend/package*.json ./
2025-08-02 03:22:09 +02:00
# Install Node dependencies
RUN npm ci
# Copy frontend source
2025-08-12 12:17:27 +02:00
COPY frontend/ ./
2025-08-02 03:22:09 +02:00
# 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
2025-08-12 12:17:27 +02:00
# Copy application code
2025-08-02 03:22:09 +02:00
COPY . .
2025-08-12 12:17:27 +02:00
# Install PHP dependencies in backend directory
WORKDIR /var/www/html/backend
2025-08-02 03:22:09 +02:00
RUN composer install --no-dev --optimize-autoloader --no-interaction
2025-08-12 12:17:27 +02:00
# Copy built frontend assets from builder stage to frontend dist
COPY --from=frontend-builder /app/dist/ /var/www/html/frontend/dist/
# Back to main directory
WORKDIR /var/www/html
2025-08-02 03:22:09 +02:00
# 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
2025-08-12 12:17:27 +02:00
RUN chown -R www-data:www-data /var/www/html \
&& chmod -R 755 /var/www/html/backend/storage \
&& chmod -R 755 /var/www/html/backend/bootstrap/cache \
2025-08-02 03:22:09 +02:00
&& 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 \
2025-08-12 12:17:27 +02:00
CMD cd /var/www/html/backend && php artisan --version || exit 1
2025-08-02 03:22:09 +02:00
# Start the application
CMD ["/usr/local/bin/start-app"]