fedi-feed-router/Dockerfile

66 lines
1.7 KiB
Docker

# Multi-stage build for Laravel with React frontend
FROM node:22-alpine AS frontend-builder
WORKDIR /app
COPY package*.json ./
RUN npm install --only=production
COPY . .
RUN npm run build
FROM php:8.4-fpm-alpine
# Install system dependencies and PHP extensions
RUN apk add --no-cache \
git \
curl \
libpng-dev \
oniguruma-dev \
libxml2-dev \
zip \
unzip \
autoconf \
gcc \
g++ \
make \
gettext \
&& 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 composer files
COPY composer*.json ./
# Copy application files (needed for artisan in composer scripts)
COPY . .
# Install dependencies
RUN composer install --no-dev --optimize-autoloader --no-interaction --ignore-platform-reqs
# Copy production environment file and generate APP_KEY
COPY docker/build/laravel.env .env
RUN php artisan key:generate
# Copy built frontend assets
COPY --from=frontend-builder /app/public/build /var/www/html/public/build
# Set permissions
RUN chown -R www-data:www-data /var/www/html \
&& chmod -R 755 /var/www/html/storage \
&& chmod -R 755 /var/www/html/bootstrap/cache
# Create entrypoint script and health check scripts
COPY docker/build/entrypoint.sh /entrypoint.sh
COPY docker/build/wait-for-db.php /docker/wait-for-db.php
COPY docker/build/wait-for-redis.php /docker/wait-for-redis.php
RUN chmod +x /entrypoint.sh /docker/wait-for-db.php /docker/wait-for-redis.php
EXPOSE 8000
ENTRYPOINT ["/entrypoint.sh"]
CMD ["web"]