diff --git a/Dockerfile b/Dockerfile index f002b62..87ef6b5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -31,18 +31,16 @@ RUN apk --no-cache add \ ${PHP_VER}-xmlwriter \ ${PHP_VER}-zip \ ${PHP_VER}-zlib && \ - rm -rf /var/www/localhost && \ mkdir -p \ - /var/www/pterodactyl \ + /app \ /run/nginx \ /run/php-fpm && \ ln -s /etc/${PHP_VER} /etc/php && \ ln -s /usr/bin/${PHP_VER} /usr/bin/php && \ - ln -s /usr/sbin/${PHPFPM_VER} /usr/sbin/php-fpm && \ - ln -s /var/log/${PHP_VER} /var/log/php + ln -s /usr/sbin/${PHPFPM_VER} /usr/sbin/php-fpm FROM base AS build -WORKDIR /var/www/pterodactyl +WORKDIR /app # Download latest Panel build from project repository: https://github.com/pterodactyl/panel ADD https://github.com/pterodactyl/panel/releases/latest/download/panel.tar.gz panel.tar.gz @@ -63,11 +61,11 @@ RUN apk --no-cache add yarn && \ rm -rf node_modules .env ./storage FROM base AS release -WORKDIR /var/www/pterodactyl +WORKDIR /app ENV S6_BEHAVIOUR_IF_STAGE2_FAILS="2" # Copy built Panel from Build stage -COPY --from=build --chown=nginx:nginx /var/www /var/www +COPY --from=build --chown=nginx:nginx /app /app COPY root/ / # Download latest S6-Overlay components from project repository: https://github.com/just-containers/s6-overlay diff --git a/root/defaults/nginx/http.conf b/root/defaults/nginx/http.conf index fdabe7f..e5962e5 100644 --- a/root/defaults/nginx/http.conf +++ b/root/defaults/nginx/http.conf @@ -7,7 +7,7 @@ server { server_name _; - root /var/www/pterodactyl/public; + root /app/public; index index.php; charset utf-8; @@ -19,7 +19,7 @@ server { location = /robots.txt { access_log off; log_not_found off; } access_log off; - error_log /var/log/nginx/pterodactyl.app-error.log error; + error_log /config/logs/nginx/pterodactyl.app-error.log error; # allow larger file uploads and longer script runtimes client_max_body_size 100m; diff --git a/root/defaults/nginx/https.conf b/root/defaults/nginx/https.conf index 86929ab..f53bf62 100644 --- a/root/defaults/nginx/https.conf +++ b/root/defaults/nginx/https.conf @@ -13,11 +13,11 @@ server { listen 443 ssl http2; server_name _; - root /var/www/pterodactyl/public; + root /app/public; index index.php; - access_log /var/log/nginx/pterodactyl.app-access.log; - error_log /var/log/nginx/pterodactyl.app-error.log error; + access_log /config/logs/nginx/pterodactyl.app-access.log; + error_log /config/logs/nginx/pterodactyl.app-error.log error; # allow larger file uploads and longer script runtimes client_max_body_size 100m; diff --git a/root/etc/crontabs/nginx b/root/etc/crontabs/nginx index 5989cc8..3c0c10f 100644 --- a/root/etc/crontabs/nginx +++ b/root/etc/crontabs/nginx @@ -1 +1 @@ -* * * * * php /var/www/pterodactyl/artisan schedule:run >> /dev/null 2>&1 \ No newline at end of file +* * * * * php /app/artisan schedule:run >> /dev/null 2>&1 \ No newline at end of file diff --git a/root/etc/nginx/nginx.conf b/root/etc/nginx/nginx.conf index b02bb21..a7dfccf 100644 --- a/root/etc/nginx/nginx.conf +++ b/root/etc/nginx/nginx.conf @@ -1,7 +1,7 @@ user nginx; worker_processes auto; pcre_jit on; -error_log /var/log/nginx/error.log warn; +error_log /config/logs/nginx/error.log warn; include /etc/nginx/modules/*.conf; events { @@ -39,6 +39,6 @@ http { '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; - access_log /var/log/nginx/access.log main; + access_log /config/logs/nginx/access.log main; include /etc/nginx/http.d/*.conf; } \ No newline at end of file diff --git a/root/etc/php81/php-fpm.conf b/root/etc/php81/php-fpm.conf index 33f30cb..1e939b3 100644 --- a/root/etc/php81/php-fpm.conf +++ b/root/etc/php81/php-fpm.conf @@ -1,5 +1,5 @@ [global] pid = /run/php-fpm/php-fpm.pid -error_log = /var/log/php/error.log +error_log = /config/logs/php/error.log log_level = warning include=/etc/php/php-fpm.d/*.conf \ No newline at end of file diff --git a/root/etc/s6-overlay/s6-rc.d/pteroq/run b/root/etc/s6-overlay/s6-rc.d/pteroq/run index 86617dc..7afe6e5 100644 --- a/root/etc/s6-overlay/s6-rc.d/pteroq/run +++ b/root/etc/s6-overlay/s6-rc.d/pteroq/run @@ -1,4 +1,4 @@ #!/command/with-contenv bash s6-setuidgid nginx -/usr/bin/php /var/www/pterodactyl/artisan queue:work --queue=high,standard,low --sleep=3 --tries=3 \ No newline at end of file +/usr/bin/php /app/artisan queue:work --queue=high,standard,low --sleep=3 --tries=3 \ No newline at end of file diff --git a/root/etc/s6-overlay/scripts/initializer b/root/etc/s6-overlay/scripts/initializer index 0d118b2..72306ca 100644 --- a/root/etc/s6-overlay/scripts/initializer +++ b/root/etc/s6-overlay/scripts/initializer @@ -2,7 +2,7 @@ source ContainerTools SNAME=${0##*/} -WORKDIR="/var/www/pterodactyl" +WORKDIR="/app" # If DBHOST value is present, pause boot until target container is up. if [ -n "$DBHOST" ]; then @@ -34,10 +34,16 @@ if [ ! -d "/config/storage" ]; then done fi -# Check for persistent logging directory, create file path if not present. -if [ ! -d "/config/log/nginx" ]; then - log "Creating log directory." - mkdir -p "/config/log/nginx" +# Check for persistent Nginx logging directory, create file path if not present. +if [ ! -d "/config/logs/nginx" ]; then + log "Creating Nginx log directory." + mkdir -p "/config/logs/nginx" +fi + +# Check for persistent PHP logging directory, create file path if not present. +if [ ! -d "/config/logs/php" ]; then + log "Creating PHP log directory." + mkdir -p "/config/logs/php" fi # Check for config file, create template if not present. @@ -62,11 +68,15 @@ if [ "$HTTPS" == "true" ]; then if [ ! -e "/etc/nginx/http.d/pterodactyl.conf" ]; then log "Symlinking Nginx config file for HTTPS" ln -s /defaults/nginx/https.conf /etc/nginx/http.d/pterodactyl.conf + else + log "HTTPS Nginx config is already in place" fi else if [ ! -e "/etc/nginx/http.d/pterodactyl.conf" ]; then log "Symlinking Nginx config file for HTTP" ln -s /defaults/nginx/http.conf /etc/nginx/http.d/pterodactyl.conf + else + log "HTTP Nginx config file is already in place" fi fi log "Initialization complete"