use nginx and php-fpm for docker
This commit is contained in:
@@ -1,28 +1,34 @@
|
|||||||
FROM docker.arvancloud.ir/dunglas/frankenphp:1.11.2-php8.5-trixie
|
FROM docker.arvancloud.ir/php:8.5-fpm-alpine3.23
|
||||||
|
|
||||||
RUN apt-get update \
|
# Install common PHP extension dependencies
|
||||||
&& apt-get install -y --no-install-recommends libpq-dev \
|
RUN apk update && apk add --no-cache \
|
||||||
|
bash \
|
||||||
|
curl \
|
||||||
|
libpng \
|
||||||
|
libpng-dev \
|
||||||
|
libjpeg-turbo-dev \
|
||||||
|
freetype-dev \
|
||||||
|
libwebp-dev \
|
||||||
|
libxml2-dev \
|
||||||
unzip \
|
unzip \
|
||||||
zip \
|
libzip-dev \
|
||||||
&& install-php-extensions pdo_pgsql pgsql \
|
libpq-dev \
|
||||||
&& apt-get clean \
|
&& docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& docker-php-ext-install pdo_pgsql pdo_mysql gd zip
|
||||||
|
|
||||||
|
# Set the working directory
|
||||||
WORKDIR /var/www/payment
|
WORKDIR /var/www/payment
|
||||||
|
|
||||||
#ENV SERVER_NAME=your-domain-name.example.com
|
|
||||||
|
|
||||||
# Copy Laravel application
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Give permissions to storage and bootstrap/cache
|
RUN chmod -R 777 /var/www/payment/storage /var/www/payment/bootstrap/cache
|
||||||
RUN chmod -R 777 storage bootstrap/cache
|
|
||||||
|
|
||||||
# Install Composer
|
# Install Composer
|
||||||
COPY --from=docker.arvancloud.ir/composer:latest /usr/bin/composer /usr/bin/composer
|
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
||||||
|
ENV COMPOSER_ALLOW_SUPERUSER=1
|
||||||
|
|
||||||
CMD composer install;\
|
# Default command
|
||||||
php artisan key:generate;\
|
CMD composer install ;\
|
||||||
php artisan migrate;\
|
php artisan key:generate ;\
|
||||||
php artisan db:seed;\
|
php artisan migrate ;\
|
||||||
frankenphp php-server -r public/
|
php artisan db:seed ;\
|
||||||
|
php-fpm
|
||||||
|
|||||||
@@ -14,13 +14,22 @@ COPY . .
|
|||||||
|
|
||||||
RUN composer dump-autoload --optimize --classmap-authoritative
|
RUN composer dump-autoload --optimize --classmap-authoritative
|
||||||
|
|
||||||
FROM docker.arvancloud.ir/dunglas/frankenphp:1.11.2-php8.5-trixie AS application
|
FROM docker.arvancloud.ir/php:8.5-fpm-alpine3.23 AS application
|
||||||
|
|
||||||
RUN apt-get update \
|
RUN apk update && apk add --no-cache \
|
||||||
&& apt-get install -y --no-install-recommends libpq-dev unzip zip \
|
bash \
|
||||||
&& install-php-extensions pdo_pgsql pgsql \
|
curl \
|
||||||
&& apt-get clean \
|
libpng \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
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 pdo_mysql gd zip
|
||||||
|
|
||||||
WORKDIR /var/www/payment
|
WORKDIR /var/www/payment
|
||||||
|
|
||||||
@@ -29,4 +38,4 @@ COPY --from=builder /app /var/www/payment
|
|||||||
RUN chown -R www-data:www-data /var/www/payment \
|
RUN chown -R www-data:www-data /var/www/payment \
|
||||||
&& chmod -R 775 storage bootstrap/cache
|
&& chmod -R 775 storage bootstrap/cache
|
||||||
|
|
||||||
CMD ["frankenphp", "php-server", "-r", "public/"]
|
CMD ["php-fpm"]
|
||||||
|
|||||||
@@ -1,6 +1,26 @@
|
|||||||
services:
|
services:
|
||||||
|
nginx:
|
||||||
|
image: docker.arvancloud.ir/nginx:stable-alpine3.23-perl
|
||||||
|
container_name: nginx
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- "80:80"
|
||||||
|
volumes:
|
||||||
|
- ./nginx/payment.conf:/etc/nginx/conf.d/default.conf
|
||||||
|
- ${BACKEND_PATH}:/var/www/${PROJECT_NAME}
|
||||||
|
networks:
|
||||||
|
- payment
|
||||||
|
|
||||||
|
redis:
|
||||||
|
image: docker.arvancloud.ir/redis:8.6.0-alpine3.23
|
||||||
|
container_name: redis
|
||||||
|
restart: unless-stopped
|
||||||
|
tty: true
|
||||||
|
networks:
|
||||||
|
- payment
|
||||||
|
|
||||||
postgres:
|
postgres:
|
||||||
image: docker.arvancloud.ir/postgres:17.8-alpine3.23
|
image: docker.arvancloud.ir/postgres:18.3-alpine3.23
|
||||||
container_name: pgsql
|
container_name: pgsql
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
@@ -26,15 +46,8 @@ services:
|
|||||||
container_name: laravel
|
container_name: laravel
|
||||||
tty: true
|
tty: true
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
healthcheck:
|
|
||||||
test: ["CMD", "curl", "-f", "http://localhost:80"]
|
|
||||||
interval: 30s
|
|
||||||
timeout: 10s
|
|
||||||
retries: 3
|
|
||||||
ports:
|
ports:
|
||||||
- "8003:80"
|
- "80:80"
|
||||||
- "443:443"
|
|
||||||
- "443:443/udp"
|
|
||||||
volumes:
|
volumes:
|
||||||
- ${BACKEND_PATH}:/var/www/${PROJECT_NAME}
|
- ${BACKEND_PATH}:/var/www/${PROJECT_NAME}
|
||||||
depends_on:
|
depends_on:
|
||||||
|
|||||||
@@ -1,6 +1,26 @@
|
|||||||
services:
|
services:
|
||||||
|
nginx:
|
||||||
|
image: docker.arvancloud.ir/nginx:stable-alpine3.23-perl
|
||||||
|
container_name: nginx
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- "80:80"
|
||||||
|
volumes:
|
||||||
|
- ./nginx/payment.conf:/etc/nginx/conf.d/default.conf
|
||||||
|
- ${BACKEND_PATH}:/var/www/${PROJECT_NAME}
|
||||||
|
networks:
|
||||||
|
- payment
|
||||||
|
|
||||||
|
redis:
|
||||||
|
image: docker.arvancloud.ir/redis:8.6.0-alpine3.23
|
||||||
|
container_name: redis
|
||||||
|
restart: unless-stopped
|
||||||
|
tty: true
|
||||||
|
networks:
|
||||||
|
- payment
|
||||||
|
|
||||||
postgres:
|
postgres:
|
||||||
image: docker.arvancloud.ir/postgres:17.8-alpine3.23
|
image: docker.arvancloud.ir/postgres:18.3-alpine3.23
|
||||||
container_name: pgsql
|
container_name: pgsql
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
@@ -22,13 +42,9 @@ services:
|
|||||||
tty: true
|
tty: true
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
- "8003:80"
|
- "9000:9000"
|
||||||
- "443:443"
|
|
||||||
- "443:443/udp"
|
|
||||||
volumes:
|
volumes:
|
||||||
- ${BACKEND_PATH}:/var/www/${PROJECT_NAME}
|
- ${BACKEND_PATH}:/var/www/${PROJECT_NAME}
|
||||||
# - caddy_data:/data
|
|
||||||
# - caddy_config:/config
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- postgres
|
- postgres
|
||||||
networks:
|
networks:
|
||||||
|
|||||||
21
nginx/payment.conf
Normal file
21
nginx/payment.conf
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
listen [::]:80;
|
||||||
|
charset utf-8;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ /index.php?$query_string;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ ^/index\.php(/|$) {
|
||||||
|
include fastcgi_params;
|
||||||
|
fastcgi_pass laravel:9000;
|
||||||
|
fastcgi_index index.php;
|
||||||
|
fastcgi_hide_header X-Powered-By;
|
||||||
|
fastcgi_param SCRIPT_FILENAME /var/www/payment/backend/public/index.php;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ /\.(?!well-known).* {
|
||||||
|
deny all;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user