Add docker container files

ticket-769
Nicolas Arenas 2024-09-16 16:23:29 +02:00
parent 8674c36223
commit a92f99c4a2
5 changed files with 143 additions and 24 deletions

25
.env
View File

@ -15,29 +15,6 @@
# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration
###> symfony/framework-bundle ###
APP_ENV=${APP_ENV:-dev}
APP_ENV=${APP_ENV:-prod}
APP_SECRET=31180fc3aa11818328106d014be0108c
#OGGIT_URL=${OGGIT_URL}
#OGGIT_URL=env(OGGIT_URL)
OGGIT_URL=(echo $OGGIT_URL)
#OGGIT_URL=http://127.0.0.1:5000
###< symfony/framework-bundle ###
###> doctrine/doctrine-bundle ###
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
#
# DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
# DATABASE_URL="mysql://app:!ChangeMe!@127.0.0.1:3306/app?serverVersion=8&charset=utf8mb4"
DATABASE_URL="postgresql://app:!ChangeMe!@127.0.0.1:5432/app?serverVersion=16&charset=utf8"
###< doctrine/doctrine-bundle ###
###> symfony/messenger ###
# Choose one of the transports below
# MESSENGER_TRANSPORT_DSN=amqp://guest:guest@localhost:5672/%2f/messages
# MESSENGER_TRANSPORT_DSN=redis://localhost:6379/messages
MESSENGER_TRANSPORT_DSN=doctrine://default?auto_setup=0
###< symfony/messenger ###
###> symfony/mailer ###
# MAILER_DSN=null://null
###< symfony/mailer ###

67
Dockerfile 100644
View File

@ -0,0 +1,67 @@
FROM ubuntu:22.04
# Instalar Nginx
RUN apt-get update && apt-get install -y nginx software-properties-common curl unzip supervisor
RUN add-apt-repository ppa:ondrej/php && apt-get update
# Exponer el puerto 80 y 443 para HTTP
EXPOSE 80
EXPOSE 443
RUN ln -sf /dev/stdout /var/log/nginx/access.log \
&& ln -sf /dev/stderr /var/log/nginx/error.log \
&& ln -sf /dev/stderr /var/log/php8.2-fpm.log
# Copia la configuración personalizada de Nginx al contenedor
COPY ./docker/nginx/default.conf /etc/nginx/sites-available/oggit
# Borrar default.conf en nginx en caso de que exista
RUN rm /etc/nginx/sites-enabled/default
# Crear un enlace simbólico a sites-enabled
RUN ln -s /etc/nginx/sites-available/oggit /etc/nginx/sites-enabled/oggit
# Install php 8.2 and php-fpm
RUN apt-get install -y php8.2 php8.2-cli php8.2-fpm php8.2-xml php8.2-curl
# Install composer
RUN curl -sS https://getcomposer.org/installer -o composer-setup.php && php composer-setup.php --install-dir=/usr/local/bin --filename=composer
# Crear directorio de trabajo
RUN mkdir /opt/oggit
RUN mkdir -p /var/www/.composer && chown -R www-data:www-data /var/www
WORKDIR /opt/oggit
# Copy the project to /opt/oggit
COPY src/ src/
COPY config/ config/
COPY composer.json .
# Install dependencies
RUN composer install
COPY .env .env
RUN chown -R www-data:www-data /opt/oggit
# Configure Supervisor
COPY docker/supervisord/supervisor.conf /etc/supervisor/conf.d/supervisor.conf
# Iniciar Nginx
COPY docker/entrypoint/entrypoint.sh /entrypoint.sh
# Cambiar los permisos de entrypoint.sh
RUN chmod +x /entrypoint.sh
RUN mkdir -p /run/php && chown -R www-data:www-data /run/php
# Set entrypoint
CMD ["/entrypoint.sh"]

View File

@ -0,0 +1,12 @@
#!/bin/bash
echo OGGIT_URL=$OGGIT_URL >> /opt/oggit/.env
# mkdir -p /run/php && chown -R www-data:www-data /run/php
# printf "\n\nStarting PHP 8.2 daemon...\n\n"
# php-fpm8.2 --daemonize
# printf "Starting Nginx...\n\n"
# set -e
# nginx -g 'daemon off;'
/usr/bin/supervisord

View File

@ -0,0 +1,42 @@
server {
listen 80;
server_name localhost; # Reemplaza 'localhost' por la IP del servidor si es necesario
# Raíz del documento para el proyecto Symfony
root /opt/oggit/public;
# Bloque para manejar las solicitudes a /oggit
location /oggit {
try_files $uri $uri/ /index.php?$query_string;
# Aumentar el tiempo de espera por el install oglive
proxy_read_timeout 600;
proxy_connect_timeout 600;
proxy_send_timeout 600;
send_timeout 600;
}
# Bloque para manejar las solicitudes a index.php
location ~ ^/index.php(/|$) {
include fastcgi_params;
fastcgi_pass unix:/run/php/php8.2-fpm.sock; # Asegúrate de que esto sea correcto
fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param DOCUMENT_ROOT $document_root;
internal;
}
# Bloque para devolver 404 en cualquier solicitud a archivos PHP que no sean index.php
location ~ \.php$ {
return 404;
}
# Logs de error y acceso para el proyecto Symfony
error_log /dev/stdout info;
access_log /dev/stdout;
location /api/doc {
try_files $uri /index.php?$query_string;
}
}

View File

@ -0,0 +1,21 @@
[supervisord]
nodaemon=true
[program:nginx]
command=nginx -g 'daemon off;'
process_name=%(program_name)s_%(process_num)02d
numprocs=1
autostart=true
autorestart=false
startsecs=0
redirect_stderr=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
[program:php-fpm]
command=php-fpm8.2 -F
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
environment=PATH=/opt/mypath:%(ENV_PATH)s,OGGIT_URL=%(ENV_OGGIT_URL)s