diff --git a/Dockerfile b/Dockerfile index 4e08996..538431f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -40,12 +40,12 @@ RUN npm install -g bun || npm update -g bun RUN sed -i '/^;zend_extension=opcache/s/^;//' /etc/php/php.ini \ && sed -i '/^;extension=iconv/s/^;//' /etc/php/php.ini \ && sed -i '/^;extension=bcmath/s/^;//' /etc/php/php.ini \ - && sed -i '/^;extension=redis/s/^;//' /etc/php/php.ini \ - && sed -i '/^extension=redis.so/s/^;//' /etc/php/php.ini \ && sed -i '/^;extension=intl/s/^;//' /etc/php/php.ini \ && sed -i '/^;extension=mysqli/s/^;//' /etc/php/php.ini \ && sed -i '/^;extension=pdo_mysql/s/^;//' /etc/php/php.ini \ - && sed -i '/^;extension=intl/s/^;//' /etc/php/php.ini + && sed -i '/^;extension=intl/s/^;//' /etc/php/php.ini \ + && sed -i '/^;extension=redis/s/^;//' /etc/php/conf.d/redis.ini \ + && sed -i '/^;extension=igbinary/s/^;//' /etc/php/conf.d/igbinary.ini # Expose necessary ports diff --git a/docker-compose.yaml b/docker-compose.yaml index 29adcb0..6e905fc 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -4,13 +4,13 @@ services: ports: - "80:80" - "443:443" - - "3306:3306" - - "6379:6379" restart: unless-stopped volumes: - ./UNIT3D:/var/www/html - ./unit3d.conf:/etc/nginx/conf.d/unit3d.conf - env_file: + - ./mysql:/var/lib/mysql + - ./entrypoint.sh:/entrypoint.sh + env_file: - .env entrypoint: /entrypoint.sh @@ -30,6 +30,7 @@ services: image: unit3d:latest volumes: - ./UNIT3D:/var/www/html + - ./entrypoint.sh:/entrypoint.sh env_file: - .env entrypoint: /entrypoint.sh debug @@ -39,7 +40,7 @@ services: volumes: - ./backup:/backup - ./mysql:/var/lib/mysql:ro - - ./UNIT3D:/var/www/html:ro + - ./UNIT3D:/var/www/html:ro env_file: - .env entrypoint: /entrypoint.sh backup-mysql diff --git a/entrypoint.sh b/entrypoint.sh index bf42a10..0b3df71 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -35,6 +35,7 @@ if [[ "$1" == "setup" ]]; then bun run build php artisan set:all_cache + redis-server --daemonize yes php artisan queue:restart fi if [[ "$1" == "debug" ]]; then @@ -58,6 +59,16 @@ if [[ "$1" == "backup-mysql" ]]; then fi if [[ -z "$1" ]]; then - echo "Starting Nginx with /etc/nginx/conf.d/unit3d.conf..." - nginx -c /etc/nginx/conf.d/unit3d.conf + echo "Starting PHP Artisan server..." + redis-server --daemonize yes + sudo chown -R mysql:mysql /var/lib/mysql + sudo chmod -R 750 /var/lib/mysql + sudo chage -E -1 mysql + su -s /bin/bash mysql -c "mysqld &" + # Wait for MariaDB to be ready + until mysqladmin ping -h "localhost" --silent; do + echo "Waiting for MariaDB to be available..." + sleep 2 + done + /usr/bin/php -d variables_order=EGPCS /var/www/html/artisan serve --host=0.0.0.0 --port=80 fi \ No newline at end of file diff --git a/unit3d.conf b/unit3d.conf index 7ad4459..de6a5c0 100644 --- a/unit3d.conf +++ b/unit3d.conf @@ -1,27 +1,35 @@ -server { - listen 80; - server_name localhost; +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; - root /var/www/html/public; - index index.php index.html index.htm; + # Increase types_hash_max_size to avoid "could not build optimal types_hash" warning + types_hash_max_size 2048; + # Optionally increase types_hash_bucket_size (ignored in some cases) + types_hash_bucket_size 128; - location / { - try_files $uri $uri/ /index.php?$query_string; - } + server { + listen 80; + server_name localhost; + root /var/www/html/public; - location ~ \.php$ { - fastcgi_pass unit:9000; - fastcgi_index index.php; - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - include fastcgi_params; - } + index index.php index.html index.htm; - location ~* \.(jpg|jpeg|png|gif|ico|css|js|svg)$ { - expires 30d; - access_log off; - } + location / { + try_files $uri $uri/ /index.php?$query_string; + } - location ~ /\.ht { - deny all; - } + location ~ \.php$ { + include fastcgi_params; + fastcgi_pass unix:/run/php-fpm/php-fpm.sock; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + } + + location ~ /\.ht { + deny all; + } + + error_log /var/log/nginx/unit3d_error.log; + access_log /var/log/nginx/unit3d_access.log; + } } \ No newline at end of file