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 \
|
||||
&& apt-get install -y --no-install-recommends libpq-dev \
|
||||
# Install common PHP extension dependencies
|
||||
RUN apk update && apk add --no-cache \
|
||||
bash \
|
||||
curl \
|
||||
libpng \
|
||||
libpng-dev \
|
||||
libjpeg-turbo-dev \
|
||||
freetype-dev \
|
||||
libwebp-dev \
|
||||
libxml2-dev \
|
||||
unzip \
|
||||
zip \
|
||||
&& install-php-extensions pdo_pgsql pgsql \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
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
|
||||
|
||||
# Set the working directory
|
||||
WORKDIR /var/www/payment
|
||||
|
||||
#ENV SERVER_NAME=your-domain-name.example.com
|
||||
|
||||
# Copy Laravel application
|
||||
COPY . .
|
||||
|
||||
# Give permissions to storage and bootstrap/cache
|
||||
RUN chmod -R 777 storage bootstrap/cache
|
||||
RUN chmod -R 777 /var/www/payment/storage /var/www/payment/bootstrap/cache
|
||||
|
||||
# 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
|
||||
|
||||
# Default command
|
||||
CMD composer install ;\
|
||||
php artisan key:generate ;\
|
||||
php artisan migrate ;\
|
||||
php artisan db:seed ;\
|
||||
frankenphp php-server -r public/
|
||||
php-fpm
|
||||
|
||||
@@ -14,13 +14,22 @@ COPY . .
|
||||
|
||||
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 \
|
||||
&& apt-get install -y --no-install-recommends libpq-dev unzip zip \
|
||||
&& install-php-extensions pdo_pgsql pgsql \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
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 pdo_mysql gd zip
|
||||
|
||||
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 \
|
||||
&& chmod -R 775 storage bootstrap/cache
|
||||
|
||||
CMD ["frankenphp", "php-server", "-r", "public/"]
|
||||
CMD ["php-fpm"]
|
||||
|
||||
@@ -1,6 +1,26 @@
|
||||
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:
|
||||
image: docker.arvancloud.ir/postgres:17.8-alpine3.23
|
||||
image: docker.arvancloud.ir/postgres:18.3-alpine3.23
|
||||
container_name: pgsql
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
@@ -26,15 +46,8 @@ services:
|
||||
container_name: laravel
|
||||
tty: true
|
||||
restart: unless-stopped
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:80"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
ports:
|
||||
- "8003:80"
|
||||
- "443:443"
|
||||
- "443:443/udp"
|
||||
- "80:80"
|
||||
volumes:
|
||||
- ${BACKEND_PATH}:/var/www/${PROJECT_NAME}
|
||||
depends_on:
|
||||
|
||||
@@ -1,6 +1,26 @@
|
||||
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:
|
||||
image: docker.arvancloud.ir/postgres:17.8-alpine3.23
|
||||
image: docker.arvancloud.ir/postgres:18.3-alpine3.23
|
||||
container_name: pgsql
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
@@ -22,13 +42,9 @@ services:
|
||||
tty: true
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "8003:80"
|
||||
- "443:443"
|
||||
- "443:443/udp"
|
||||
- "9000:9000"
|
||||
volumes:
|
||||
- ${BACKEND_PATH}:/var/www/${PROJECT_NAME}
|
||||
# - caddy_data:/data
|
||||
# - caddy_config:/config
|
||||
depends_on:
|
||||
- postgres
|
||||
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