Files
AFC-Demo/Dockerfile
T

69 lines
2.4 KiB
Docker
Raw Normal View History

2025-10-23 08:25:29 +02:00
# -------- 1) Composer deps (no scripts; avoids artisan during build) --------
2025-10-23 07:58:06 +02:00
FROM composer:2 AS vendor
ARG COMPOSER_NO_DEV=1
WORKDIR /app
COPY composer.json composer.lock ./
RUN if [ "$COMPOSER_NO_DEV" = "1" ]; then \
composer install --no-dev --prefer-dist --no-progress --no-interaction --classmap-authoritative --no-scripts; \
else \
2025-10-23 11:25:13 +02:00
composer install --prefer-dist --no-progress --no-interaction --classmap-authoritative --no-scripts; \
2025-10-23 07:58:06 +02:00
fi
2025-10-23 08:25:29 +02:00
# -------- 2) App source --------
2025-10-23 10:28:00 +02:00
FROM alpine:3.22 AS app_src
2025-10-23 07:58:06 +02:00
WORKDIR /app
COPY . ./
2025-10-23 08:25:29 +02:00
# -------- 3) Final: Nginx + PHP-FPM + PGSQL drivers --------
2025-10-23 07:58:06 +02:00
FROM php:8.4-fpm-alpine
2025-10-23 08:25:29 +02:00
# Build + runtime deps (incl. oniguruma for mbstring, GD runtime libs)
2025-10-23 07:58:06 +02:00
RUN set -eux; \
2025-10-23 08:10:45 +02:00
apk add --no-cache --virtual .build-deps \
$PHPIZE_DEPS icu-dev libzip-dev postgresql-dev \
freetype-dev libjpeg-turbo-dev libpng-dev \
oniguruma-dev pkgconf \
&& apk add --no-cache \
icu-libs libzip libpq tzdata bash git curl \
nginx supervisor \
2025-10-23 08:25:29 +02:00
oniguruma freetype libjpeg-turbo libpng \
2025-10-23 08:10:45 +02:00
&& docker-php-ext-configure intl \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
2025-10-23 08:25:29 +02:00
&& docker-php-ext-install -j"$(nproc)" intl opcache zip bcmath mbstring gd pdo pdo_pgsql pgsql \
2025-10-23 08:10:45 +02:00
&& apk del .build-deps \
&& rm -rf /var/cache/apk/* /tmp/*
2025-10-23 07:58:06 +02:00
2025-10-23 08:10:45 +02:00
# PHP runtime tuning
2025-10-23 07:58:06 +02:00
RUN set -eux; \
{ \
echo "memory_limit=512M"; \
echo "upload_max_filesize=64M"; \
echo "post_max_size=64M"; \
echo "max_execution_time=60"; \
} > /usr/local/etc/php/conf.d/laravel.ini
2025-10-23 11:25:13 +02:00
# Set timezone
RUN ln -sf /usr/share/zoneinfo/UTC /etc/localtime
2025-10-23 07:58:06 +02:00
2025-10-23 11:25:13 +02:00
# Copy application source
WORKDIR /app
COPY --from=app_src /app /app
COPY --from=vendor /app/vendor /app/vendor
2025-10-23 07:58:06 +02:00
2025-10-23 11:25:13 +02:00
# Set permissions for Laravel storage and cache
2025-10-23 08:25:29 +02:00
RUN set -eux; \
2025-10-23 11:25:13 +02:00
chown -R www-data:www-data /app/storage /app/bootstrap/cache /app/public; \
chmod -R 775 /app/storage /app/bootstrap/cache /app/public
2025-10-23 08:25:29 +02:00
2025-10-23 11:25:13 +02:00
# Configure Nginx
RUN mkdir -p /run/nginx
COPY ./deploy/nginx/default.conf /etc/nginx/nginx.conf
# Configure Supervisor
COPY ./deploy/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
# Expose ports
2025-10-23 08:25:29 +02:00
EXPOSE 80
2025-10-23 11:25:13 +02:00
# Start Supervisor
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]