add dockerfile for production

This commit is contained in:
2026-04-27 15:18:35 +03:30
parent 52ed10f831
commit 1dbd816da2
3 changed files with 60 additions and 24 deletions

View File

@@ -1,21 +1,6 @@
FROM docker.arvancloud.ir/composer:latest AS builder FROM php:8.5.3-fpm-alpine3.23
WORKDIR /app
COPY composer.json composer.lock ./
RUN composer install \
--no-dev \
--no-scripts \
--no-autoloader \
--prefer-dist
COPY . .
RUN composer dump-autoload --optimize --classmap-authoritative
FROM php:8.5.3-fpm-alpine3.23 AS application
# Install common PHP extension dependencies
RUN apk update && apk add --no-cache \ RUN apk update && apk add --no-cache \
bash \ bash \
curl \ curl \
@@ -29,13 +14,23 @@ RUN apk update && apk add --no-cache \
libzip-dev \ libzip-dev \
libpq-dev \ libpq-dev \
&& docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp \ && docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp \
&& docker-php-ext-install pdo_pgsql pdo_mysql gd zip && docker-php-ext-install pdo_pgsql gd zip
# Set the working directory
WORKDIR /var/www/payment WORKDIR /var/www/payment
COPY --from=builder /app /var/www/payment COPY . .
RUN chown -R www-data:www-data /var/www/payment \ RUN chmod -R 665 /var/www/payment/storage /var/www/payment/bootstrap/cache
&& chmod -R 665 storage bootstrap/cache
CMD ["php-fpm"] # Install Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
ENV COMPOSER_ALLOW_SUPERUSER=1
# Default command
CMD composer install ;\
composer dump-autoload --optimize --classmap-authoritative ;\
php artisan key:generate ;\
php artisan migrate ;\
php artisan db:seed ;\
php-fpm

View File

@@ -0,0 +1,41 @@
FROM docker.arvancloud.ir/composer:latest AS builder
WORKDIR /app
COPY composer.json composer.lock ./
RUN composer install \
--no-dev \
--no-scripts \
--no-autoloader \
--prefer-dist
COPY . .
RUN composer dump-autoload --optimize --classmap-authoritative
FROM php:8.5.3-fpm-alpine3.23 AS application
RUN apk update && apk add --no-cache \
bash \
curl \
libpng \
libpng-dev \
libjpeg-turbo-dev \
freetype-dev \
libwebp-dev \
libxml2-dev \
unzip \
libzip-dev \
libpq-dev \
&& docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp \
&& docker-php-ext-install pdo_pgsql gd zip
WORKDIR /var/www/payment
COPY --from=builder /app /var/www/payment
RUN chown -R www-data:www-data /var/www/payment \
&& chmod -R 665 storage bootstrap/cache
CMD ["php-fpm"]

View File

@@ -1,6 +1,6 @@
services: services:
nginx: nginx:
image: docker.arvancloud.ir/nginx:stable-alpine3.23-perl image: nginx:stable-alpine3.23-perl
container_name: nginx container_name: nginx
restart: unless-stopped restart: unless-stopped
ports: ports:
@@ -12,7 +12,7 @@ services:
- payment - payment
redis: redis:
image: docker.arvancloud.ir/redis:8.6.0-alpine3.23 image: redis:8.6.0-alpine3.23
container_name: redis container_name: redis
restart: unless-stopped restart: unless-stopped
tty: true tty: true