use nginx instead of symfony serve
This commit is contained in:
parent
9cfbdeaa3c
commit
d0db43610b
18
Dockerfile
18
Dockerfile
@ -1,4 +1,4 @@
|
||||
FROM php:8.2-cli as base
|
||||
FROM php:8.2-fpm as base
|
||||
|
||||
# Install system dependencies
|
||||
RUN apt-get update && apt-get install -y \
|
||||
@ -21,15 +21,23 @@ RUN curl -sS https://get.symfony.com/cli/installer | bash && \
|
||||
# Set working directory
|
||||
WORKDIR /var/www/html
|
||||
|
||||
CMD ["symfony", "serve", "--port=8000", "--no-tls", "--allow-http", "--allow-all-ip"]
|
||||
FROM base as dev
|
||||
|
||||
CMD ["php-fpm"]
|
||||
|
||||
FROM base as production
|
||||
|
||||
# Install Nginx
|
||||
RUN apt-get update && apt-get install -y nginx
|
||||
|
||||
# Copy application files
|
||||
COPY . .
|
||||
|
||||
# Install dependencies
|
||||
RUN composer install --no-interaction --optimize-autoloader
|
||||
RUN composer install --no-interaction --optimize-autoloader --no-dev
|
||||
|
||||
# Command to run Symfony server
|
||||
CMD ["symfony", "serve", "--port=8000", "--no-tls", "--allow-http", "--allow-all-ip"]
|
||||
# Copy Nginx configuration
|
||||
COPY docker/nginx/default.conf /etc/nginx/conf.d/default.conf
|
||||
|
||||
# Start Nginx and PHP-FPM
|
||||
CMD ["/bin/bash", "-c", "service nginx start && php-fpm"]
|
||||
|
||||
@ -8,7 +8,7 @@ services:
|
||||
target: production
|
||||
environment:
|
||||
- APP_ENV=prod
|
||||
- APP_DEBUG=1
|
||||
- APP_DEBUG=0
|
||||
networks:
|
||||
- proxy
|
||||
|
||||
|
||||
@ -3,9 +3,9 @@ services:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
target: base
|
||||
target: production
|
||||
ports:
|
||||
- 8000:8000
|
||||
- 8000:80
|
||||
environment:
|
||||
- APP_ENV=dev
|
||||
- APP_DEBUG=1
|
||||
|
||||
25
docker/nginx/default.conf
Normal file
25
docker/nginx/default.conf
Normal file
@ -0,0 +1,25 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
root /var/www/html/public;
|
||||
|
||||
location / {
|
||||
try_files $uri /index.php$is_args$args;
|
||||
}
|
||||
|
||||
location ~ ^/index\.php(/|$) {
|
||||
fastcgi_pass 127.0.0.1:9000;
|
||||
fastcgi_split_path_info ^(.+\.php)(/.*)$;
|
||||
include fastcgi_params;
|
||||
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
|
||||
fastcgi_param DOCUMENT_ROOT $realpath_root;
|
||||
internal;
|
||||
}
|
||||
|
||||
location ~ \.php$ {
|
||||
return 404;
|
||||
}
|
||||
|
||||
error_log /var/log/nginx/project_error.log;
|
||||
access_log /var/log/nginx/project_access.log;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user