43 lines
1.1 KiB
Docker
43 lines
1.1 KiB
Docker
# Stage 1: build frontend assets
|
|
FROM node:20-alpine AS frontend
|
|
WORKDIR /app
|
|
COPY package*.json ./
|
|
RUN npm ci --no-audit
|
|
COPY . .
|
|
RUN npm run build
|
|
|
|
# Stage 2: PHP-FPM app
|
|
FROM php:8.2-fpm-alpine AS app
|
|
WORKDIR /var/www/html
|
|
|
|
RUN apk add --no-cache \
|
|
libpng-dev libjpeg-turbo-dev freetype-dev libzip-dev \
|
|
zip unzip git mysql-client
|
|
|
|
RUN docker-php-ext-configure gd --with-freetype --with-jpeg \
|
|
&& docker-php-ext-install pdo pdo_mysql gd zip opcache pcntl
|
|
|
|
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
|
|
|
|
COPY docker/php/php.ini $PHP_INI_DIR/conf.d/app.ini
|
|
|
|
COPY . .
|
|
COPY --from=frontend /app/public/build ./public/build
|
|
|
|
RUN composer install --no-dev --optimize-autoloader --no-interaction
|
|
|
|
RUN chown -R www-data:www-data storage bootstrap/cache \
|
|
&& chmod -R 775 storage bootstrap/cache
|
|
|
|
COPY docker/entrypoint.sh /entrypoint.sh
|
|
RUN chmod +x /entrypoint.sh
|
|
|
|
EXPOSE 9000
|
|
ENTRYPOINT ["/entrypoint.sh"]
|
|
CMD ["php-fpm"]
|
|
|
|
# Stage 3: nginx with baked-in static assets
|
|
FROM nginx:1.27-alpine AS web
|
|
COPY nginx/nginx.conf /etc/nginx/conf.d/default.conf
|
|
COPY --from=app /var/www/html/public /var/www/html/public
|