Dockerfile desarrollo
This commit is contained in:
parent
3c66914804
commit
7fff56f592
@ -8,15 +8,7 @@ server {
|
|||||||
error_log /var/log/nginx/error.log;
|
error_log /var/log/nginx/error.log;
|
||||||
access_log /var/log/nginx/access.log;
|
access_log /var/log/nginx/access.log;
|
||||||
|
|
||||||
# Gzip compression
|
# Handle Laravel routes (Front Controller)
|
||||||
gzip on;
|
|
||||||
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
|
|
||||||
|
|
||||||
# Security headers
|
|
||||||
add_header X-Frame-Options "SAMEORIGIN";
|
|
||||||
add_header X-Content-Type-Options "nosniff";
|
|
||||||
|
|
||||||
# Handle Laravel routes
|
|
||||||
location / {
|
location / {
|
||||||
try_files $uri $uri/ /index.php?$query_string;
|
try_files $uri $uri/ /index.php?$query_string;
|
||||||
}
|
}
|
||||||
@ -25,22 +17,28 @@ server {
|
|||||||
location ~ \.php$ {
|
location ~ \.php$ {
|
||||||
try_files $uri =404;
|
try_files $uri =404;
|
||||||
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
||||||
fastcgi_pass holos-backend:9000; # Nombre del servicio en docker-compose
|
fastcgi_pass holos-backend:9000;
|
||||||
fastcgi_index index.php;
|
fastcgi_index index.php;
|
||||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
|
||||||
fastcgi_param PATH_INFO $fastcgi_path_info;
|
# Timeouts importantes para evitar errores 500
|
||||||
|
fastcgi_read_timeout 300;
|
||||||
|
fastcgi_connect_timeout 300;
|
||||||
|
fastcgi_send_timeout 300;
|
||||||
|
|
||||||
|
# Carga los parámetros por defecto
|
||||||
include fastcgi_params;
|
include fastcgi_params;
|
||||||
|
|
||||||
# Timeouts para requests largos
|
# Parámetros críticos para Laravel
|
||||||
fastcgi_read_timeout 300;
|
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||||
fastcgi_send_timeout 300;
|
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||||
}
|
fastcgi_param REQUEST_URI $request_uri;
|
||||||
|
fastcgi_param QUERY_STRING $query_string;
|
||||||
# Handle static files with caching
|
fastcgi_param REQUEST_METHOD $request_method;
|
||||||
location ~* \.(jpg|jpeg|png|gif|ico|css|js|pdf|txt|tar|woff|woff2|ttf|svg|eot)$ {
|
fastcgi_param CONTENT_TYPE $content_type;
|
||||||
expires 1y;
|
fastcgi_param CONTENT_LENGTH $content_length;
|
||||||
add_header Cache-Control "public, immutable";
|
fastcgi_param HTTP_HOST $http_host;
|
||||||
try_files $uri =404;
|
fastcgi_param HTTPS $https if_not_empty;
|
||||||
|
fastcgi_param HTTP_PROXY "";
|
||||||
}
|
}
|
||||||
|
|
||||||
# Handle storage files (Laravel storage link)
|
# Handle storage files (Laravel storage link)
|
||||||
@ -49,16 +47,8 @@ server {
|
|||||||
try_files $uri =404;
|
try_files $uri =404;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Handle profile images
|
# Denegar acceso a archivos ocultos como .htaccess
|
||||||
location /profile {
|
location ~ /\.ht {
|
||||||
alias /var/www/holos.backend/storage/app/profile;
|
deny all;
|
||||||
try_files $uri =404;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Handle images
|
|
||||||
location /images {
|
|
||||||
alias /var/www/holos.backend/storage/app/images;
|
|
||||||
try_files $uri =404;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
69
docker-compose-dev.yml
Normal file
69
docker-compose-dev.yml
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
services:
|
||||||
|
holos-backend:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: dockerfile.dev
|
||||||
|
working_dir: /var/www/holos.backend
|
||||||
|
volumes:
|
||||||
|
- ./:/var/www/holos.backend
|
||||||
|
- ./storage:/var/www/holos.backend/storage
|
||||||
|
networks:
|
||||||
|
- holos-network
|
||||||
|
depends_on:
|
||||||
|
- mysql
|
||||||
|
- redis
|
||||||
|
|
||||||
|
nginx:
|
||||||
|
image: nginx:alpine
|
||||||
|
ports:
|
||||||
|
- "8080:80"
|
||||||
|
volumes:
|
||||||
|
- ./public:/var/www/holos.backend/public
|
||||||
|
- ./Docker/nginx/nginx.conf:/etc/nginx/conf.d/default.conf
|
||||||
|
networks:
|
||||||
|
- holos-network
|
||||||
|
depends_on:
|
||||||
|
- holos-backend
|
||||||
|
|
||||||
|
mysql:
|
||||||
|
image: mysql:8.0
|
||||||
|
environment:
|
||||||
|
MYSQL_DATABASE: ${DB_DATABASE}
|
||||||
|
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
|
||||||
|
MYSQL_PASSWORD: ${DB_PASSWORD}
|
||||||
|
MYSQL_USER: ${DB_USERNAME}
|
||||||
|
ports:
|
||||||
|
- ${DB_PORT}:${DB_PORT}
|
||||||
|
volumes:
|
||||||
|
- mysql_data:/var/lib/mysql
|
||||||
|
networks:
|
||||||
|
- holos-network
|
||||||
|
|
||||||
|
phpmyadmin:
|
||||||
|
image: phpmyadmin/phpmyadmin
|
||||||
|
environment:
|
||||||
|
PMA_HOST: mysql
|
||||||
|
PMA_PORT: 3306
|
||||||
|
ports:
|
||||||
|
- '${PMA_PORT}:80'
|
||||||
|
depends_on:
|
||||||
|
- mysql
|
||||||
|
networks:
|
||||||
|
- holos-network
|
||||||
|
|
||||||
|
redis:
|
||||||
|
image: redis:alpine
|
||||||
|
volumes:
|
||||||
|
- redis_data:/data
|
||||||
|
networks:
|
||||||
|
- holos-network
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
mysql_data:
|
||||||
|
driver: local
|
||||||
|
redis_data:
|
||||||
|
driver: local
|
||||||
|
|
||||||
|
networks:
|
||||||
|
holos-network:
|
||||||
|
driver: bridge
|
||||||
10
dockerfile
10
dockerfile
@ -12,8 +12,7 @@ RUN apt-get update && apt-get install -y\
|
|||||||
libxml2-dev \
|
libxml2-dev \
|
||||||
zip \
|
zip \
|
||||||
unzip \
|
unzip \
|
||||||
libzip-dev \
|
libzip-dev
|
||||||
&& curl -fsSL https://deb.nodesource.com/setup_18.x | bash -
|
|
||||||
|
|
||||||
RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd zip
|
RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd zip
|
||||||
|
|
||||||
@ -25,13 +24,6 @@ RUN composer install --no-dev --no-scripts --optimize-autoloader --no-interactio
|
|||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
RUN php artisan config:cache \
|
|
||||||
&& php artisan route:cache
|
|
||||||
|
|
||||||
RUN chown -R www-data:www-data /var/www/holos.backend \
|
|
||||||
&& chmod -R 755 /var/www/holos.backend/storage \
|
|
||||||
&& chmod -R 755 /var/www/holos.backend/bootstrap/cache
|
|
||||||
|
|
||||||
EXPOSE 9000
|
EXPOSE 9000
|
||||||
|
|
||||||
CMD ["php-fpm"]
|
CMD ["php-fpm"]
|
||||||
|
|||||||
33
dockerfile.dev
Normal file
33
dockerfile.dev
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
FROM php:8.3-fpm
|
||||||
|
|
||||||
|
RUN mkdir -p /var/www/holos.backend
|
||||||
|
|
||||||
|
WORKDIR /var/www/holos.backend
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install -y\
|
||||||
|
git \
|
||||||
|
curl \
|
||||||
|
libpng-dev \
|
||||||
|
libonig-dev \
|
||||||
|
libxml2-dev \
|
||||||
|
zip \
|
||||||
|
unzip \
|
||||||
|
libzip-dev\
|
||||||
|
nano
|
||||||
|
|
||||||
|
RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd zip
|
||||||
|
|
||||||
|
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
||||||
|
|
||||||
|
COPY composer.json composer.lock ./
|
||||||
|
|
||||||
|
RUN composer install --optimize-autoloader --no-interaction --no-scripts
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Ejecutar los scripts de Laravel después de copiar el código
|
||||||
|
RUN composer run-script post-autoload-dump
|
||||||
|
|
||||||
|
EXPOSE 9000
|
||||||
|
|
||||||
|
CMD ["php-fpm"]
|
||||||
Loading…
x
Reference in New Issue
Block a user