From 42e3eecf80540a4963c25bd1ddae36c1bb38b7cf Mon Sep 17 00:00:00 2001 From: Asherslab Date: Thu, 17 May 2018 22:53:17 -0400 Subject: [PATCH 01/18] Add docker files --- .gitignore | 2 +- Dockerfile | 26 ++++++++++++++++++++++++++ default.conf | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ entrypoint.sh | 27 +++++++++++++++++++++++++++ 4 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 Dockerfile create mode 100644 default.conf create mode 100644 entrypoint.sh diff --git a/.gitignore b/.gitignore index 8c2fb9405..33e412c01 100644 --- a/.gitignore +++ b/.gitignore @@ -20,7 +20,7 @@ sami.phar # For local development with docker # Remove if we ever put the Dockerfile in the repo .dockerignore -Dockerfile +#Dockerfile docker-compose.yml # for image related files misc diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..90d18594c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,26 @@ +FROM alpine:3.7 + +WORKDIR /app + +RUN apk add --no-cache wget ca-certificates && \ + wget -O /etc/apk/keys/phpearth.rsa.pub https://repos.php.earth/alpine/phpearth.rsa.pub && \ + echo "https://repos.php.earth/alpine/v3.7" >> /etc/apk/repositories && \ + apk add --no-cache --update certbot nginx dcron curl tini php7.2 php7.2-bcmath php7.2-common php7.2-dom php7.2-fpm php7.2-gd php7.2-mbstring php7.2-openssl php7.2-zip php7.2-pdo php7.2-phar php7.2-json php7.2-pdo_mysql php7.2-session php7.2-ctype php7.2-tokenizer php7.2-zlib php7.2-simplexml && \ + curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer + +COPY . ./ + +COPY default.conf /etc/nginx/conf.d/default.conf + +RUN cp .env.example .env +RUN composer install --no-dev + + +EXPOSE 80 +EXPOSE 443 + +RUN chown -R www-data:www-data . +RUN chmod -R 777 storage/* bootstrap/cache /var/run/php + +ENTRYPOINT ["ash", "entrypoint.sh"] + diff --git a/default.conf b/default.conf new file mode 100644 index 000000000..0944bf799 --- /dev/null +++ b/default.conf @@ -0,0 +1,51 @@ +# If using Ubuntu this file should be placed in: +# /etc/nginx/sites-available/ +# +# If using CentOS this file should be placed in: +# /etc/nginx/conf.d/ +# +server { + listen 80; + server_name _; + + root /app/public; + index index.html index.htm index.php; + charset utf-8; + + location / { + try_files $uri $uri/ /index.php?$query_string; + } + + location = /favicon.ico { access_log off; log_not_found off; } + location = /robots.txt { access_log off; log_not_found off; } + + access_log off; + error_log /var/log/nginx/pterodactyl.app-error.log error; + + # allow larger file uploads and longer script runtimes + client_max_body_size 100m; + client_body_timeout 120s; + + sendfile off; + + location ~ \.php$ { + fastcgi_split_path_info ^(.+\.php)(/.+)$; + # the fastcgi_pass path needs to be changed accordingly when using CentOS + fastcgi_pass unix:/var/run/php/php-fpm7.2.sock; + fastcgi_index index.php; + include fastcgi_params; + fastcgi_param PHP_VALUE "upload_max_filesize = 100M \n post_max_size=100M"; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param HTTP_PROXY ""; + fastcgi_intercept_errors off; + fastcgi_buffer_size 16k; + fastcgi_buffers 4 16k; + fastcgi_connect_timeout 300; + fastcgi_send_timeout 300; + fastcgi_read_timeout 300; + } + + location ~ /\.ht { + deny all; + } +} diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 000000000..495581c37 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,27 @@ +#!/bin/ash +tini -- php-fpm + +until nc -z -v -w30 $DB_HOST 3306 +do + echo "Waiting for database connection..." + # wait for 5 seconds before check again + sleep 5 +done + +sed -i s/DB_HOST=127.0.0.1/DB_HOST=$DB_HOST/g /app/.env +sed -i s/DB_DATABASE=panel/DB_DATABASE=$DB_DATABASE/g /app/.env +sed -i s/DB_USERNAME=pterodactyl/DB_USERNAME=$DB_USERNAME/g /app/.env +sed -i s/DB_PASSWORD=/DB_PASSWORD=$DB_PASSWORD/g /app/.env + +#echo "1" +#chown -R www-data:www-data . +#echo "2" +#chmod -R 777 storage/* bootstrap/cache /var/run/php +echo "3" +php artisan key:generate --force +echo "4" +php artisan migrate --force +echo "5" +php artisan db:seed --force +echo "Done" +nginx -g 'pid /tmp/nginx.pid; daemon off;' From 737bae300c7aec69a1fba812a044ff3f6cd0d6a6 Mon Sep 17 00:00:00 2001 From: Asherslab Date: Fri, 18 May 2018 08:55:12 -0400 Subject: [PATCH 02/18] Some Additions --- Dockerfile | 1 - entrypoint.sh | 21 +++++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 90d18594c..ef05f6da5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,7 +15,6 @@ COPY default.conf /etc/nginx/conf.d/default.conf RUN cp .env.example .env RUN composer install --no-dev - EXPOSE 80 EXPOSE 443 diff --git a/entrypoint.sh b/entrypoint.sh index 495581c37..8a42015e0 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -8,17 +8,26 @@ do sleep 5 done -sed -i s/DB_HOST=127.0.0.1/DB_HOST=$DB_HOST/g /app/.env -sed -i s/DB_DATABASE=panel/DB_DATABASE=$DB_DATABASE/g /app/.env -sed -i s/DB_USERNAME=pterodactyl/DB_USERNAME=$DB_USERNAME/g /app/.env -sed -i s/DB_PASSWORD=/DB_PASSWORD=$DB_PASSWORD/g /app/.env +#sed -i s/DB_HOST=127.0.0.1/DB_HOST=$DB_HOST/g /app/.env +#sed -i s/DB_DATABASE=panel/DB_DATABASE=$DB_DATABASE/g /app/.env +#sed -i s/DB_USERNAME=pterodactyl/DB_USERNAME=$DB_USERNAME/g /app/.env +#sed -i s/DB_PASSWORD=/DB_PASSWORD=$DB_PASSWORD/g /app/.env #echo "1" #chown -R www-data:www-data . #echo "2" -#chmod -R 777 storage/* bootstrap/cache /var/run/php +chmod -R 777 storage/* bootstrap/cache /var/run/php /app/.env echo "3" -php artisan key:generate --force + +if [ "$(cat .env)" == "" ]; then + cat /app/.env.example > /app/.env +fi + +if [ "$(cat .env | grep APP_KEY)" == "APP_KEY=" ]; then + echo "Generating New Key" + php artisan key:generate --force +fi + echo "4" php artisan migrate --force echo "5" From a93a73ef4dea7382ac43d3bac21f75f1e544cbb0 Mon Sep 17 00:00:00 2001 From: Asherslab Date: Fri, 18 May 2018 09:11:33 -0400 Subject: [PATCH 03/18] Moved files --- default.conf => .dev/default.conf | 0 entrypoint.sh => .dev/entrypoint.sh | 2 ++ Dockerfile | 4 ++-- 3 files changed, 4 insertions(+), 2 deletions(-) rename default.conf => .dev/default.conf (100%) rename entrypoint.sh => .dev/entrypoint.sh (98%) diff --git a/default.conf b/.dev/default.conf similarity index 100% rename from default.conf rename to .dev/default.conf diff --git a/entrypoint.sh b/.dev/entrypoint.sh similarity index 98% rename from entrypoint.sh rename to .dev/entrypoint.sh index 8a42015e0..eeb416ce0 100644 --- a/entrypoint.sh +++ b/.dev/entrypoint.sh @@ -1,4 +1,6 @@ #!/bin/ash +cd /app + tini -- php-fpm until nc -z -v -w30 $DB_HOST 3306 diff --git a/Dockerfile b/Dockerfile index ef05f6da5..94817bdb4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,7 +10,7 @@ RUN apk add --no-cache wget ca-certificates && \ COPY . ./ -COPY default.conf /etc/nginx/conf.d/default.conf +COPY .dev/default.conf /etc/nginx/conf.d/default.conf RUN cp .env.example .env RUN composer install --no-dev @@ -21,5 +21,5 @@ EXPOSE 443 RUN chown -R www-data:www-data . RUN chmod -R 777 storage/* bootstrap/cache /var/run/php -ENTRYPOINT ["ash", "entrypoint.sh"] +ENTRYPOINT ["ash", ".dev/entrypoint.sh"] From 0667b61abf6135a993b498251684a42f25e52b98 Mon Sep 17 00:00:00 2001 From: Lance Pioch Date: Sun, 8 Jul 2018 11:11:47 -0400 Subject: [PATCH 04/18] Combine and consolidate --- .dev/entrypoint.sh | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.dev/entrypoint.sh b/.dev/entrypoint.sh index eeb416ce0..9cfcd0d53 100644 --- a/.dev/entrypoint.sh +++ b/.dev/entrypoint.sh @@ -15,11 +15,8 @@ done #sed -i s/DB_USERNAME=pterodactyl/DB_USERNAME=$DB_USERNAME/g /app/.env #sed -i s/DB_PASSWORD=/DB_PASSWORD=$DB_PASSWORD/g /app/.env -#echo "1" #chown -R www-data:www-data . -#echo "2" chmod -R 777 storage/* bootstrap/cache /var/run/php /app/.env -echo "3" if [ "$(cat .env)" == "" ]; then cat /app/.env.example > /app/.env @@ -30,9 +27,6 @@ if [ "$(cat .env | grep APP_KEY)" == "APP_KEY=" ]; then php artisan key:generate --force fi -echo "4" -php artisan migrate --force -echo "5" -php artisan db:seed --force +php artisan migrate --seed --force echo "Done" nginx -g 'pid /tmp/nginx.pid; daemon off;' From 925f28b29cd0ba25e08a32150d4e1560c945f93c Mon Sep 17 00:00:00 2001 From: Lance Pioch Date: Sun, 8 Jul 2018 11:13:18 -0400 Subject: [PATCH 05/18] Update alpine version --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 94817bdb4..675c8a79c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM alpine:3.7 +FROM alpine:3.8 WORKDIR /app From 7ef3b76499ba2bf8070fc8fe2b5311173044eae6 Mon Sep 17 00:00:00 2001 From: Lance Pioch Date: Sun, 8 Jul 2018 11:14:20 -0400 Subject: [PATCH 06/18] Consolidate commands --- Dockerfile | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 675c8a79c..43366e02c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,14 +12,11 @@ COPY . ./ COPY .dev/default.conf /etc/nginx/conf.d/default.conf -RUN cp .env.example .env -RUN composer install --no-dev +RUN cp .env.example .env && composer install --no-dev -EXPOSE 80 -EXPOSE 443 +EXPOSE 80 443 -RUN chown -R www-data:www-data . -RUN chmod -R 777 storage/* bootstrap/cache /var/run/php +RUN chown -R www-data:www-data . && chmod -R 777 storage/* bootstrap/cache /var/run/php ENTRYPOINT ["ash", ".dev/entrypoint.sh"] From 44a65b4b3c947894331709a2a7e84bd65b020dfb Mon Sep 17 00:00:00 2001 From: Lance Pioch Date: Sun, 8 Jul 2018 11:28:26 -0400 Subject: [PATCH 07/18] Move to its own dir --- .dev/{ => docker}/default.conf | 0 Dockerfile | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename .dev/{ => docker}/default.conf (100%) diff --git a/.dev/default.conf b/.dev/docker/default.conf similarity index 100% rename from .dev/default.conf rename to .dev/docker/default.conf diff --git a/Dockerfile b/Dockerfile index 43366e02c..335c021a5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,7 +10,7 @@ RUN apk add --no-cache wget ca-certificates && \ COPY . ./ -COPY .dev/default.conf /etc/nginx/conf.d/default.conf +COPY .dev/docker/default.conf /etc/nginx/conf.d/default.conf RUN cp .env.example .env && composer install --no-dev From 5427b7e1723f31e5747057cbc145b08c24f459a8 Mon Sep 17 00:00:00 2001 From: "Michael (Parker) Parker" Date: Wed, 18 Jul 2018 12:15:33 -0400 Subject: [PATCH 08/18] dockerfile changes --- Dockerfile | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 335c021a5..00842cf60 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,11 +2,8 @@ FROM alpine:3.8 WORKDIR /app -RUN apk add --no-cache wget ca-certificates && \ - wget -O /etc/apk/keys/phpearth.rsa.pub https://repos.php.earth/alpine/phpearth.rsa.pub && \ - echo "https://repos.php.earth/alpine/v3.7" >> /etc/apk/repositories && \ - apk add --no-cache --update certbot nginx dcron curl tini php7.2 php7.2-bcmath php7.2-common php7.2-dom php7.2-fpm php7.2-gd php7.2-mbstring php7.2-openssl php7.2-zip php7.2-pdo php7.2-phar php7.2-json php7.2-pdo_mysql php7.2-session php7.2-ctype php7.2-tokenizer php7.2-zlib php7.2-simplexml && \ - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer +RUN apk add --no-cache --update ca-certificates certbot nginx dcron curl tini php7 php7-bcmath php7-common php7-dom php7-fpm php7-gd php7-mbstring php7-openssl php7-zip php7-pdo php7-phar php7-json php7-pdo_mysql php7-session php7-ctype php7-tokenizer php7-zlib \ + && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer COPY . ./ From b7da8532ba7c4ab5bc823c70d2413082d78079ca Mon Sep 17 00:00:00 2001 From: "Michael (Parker) Parker" Date: Wed, 18 Jul 2018 15:31:35 -0400 Subject: [PATCH 09/18] Fixing install Adding php fpm conf and fixing dockerfile --- .dev/docker/www.conf | 14 ++++++++++++++ Dockerfile | 14 +++++++------- 2 files changed, 21 insertions(+), 7 deletions(-) create mode 100644 .dev/docker/www.conf diff --git a/.dev/docker/www.conf b/.dev/docker/www.conf new file mode 100644 index 000000000..808180b9c --- /dev/null +++ b/.dev/docker/www.conf @@ -0,0 +1,14 @@ +[pterodactyl] + +user = nginx +group = nginx + +listen = /var/run/php/php-fpm7.2.sock +listen.owner = nginx +listen.group = nginx +listen.mode = 0750 + +pm = ondemand +pm.max_children = 9 +pm.process_idle_timeout = 10s +pm.max_requests = 200 \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 00842cf60..7901e66bc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,18 +2,18 @@ FROM alpine:3.8 WORKDIR /app -RUN apk add --no-cache --update ca-certificates certbot nginx dcron curl tini php7 php7-bcmath php7-common php7-dom php7-fpm php7-gd php7-mbstring php7-openssl php7-zip php7-pdo php7-phar php7-json php7-pdo_mysql php7-session php7-ctype php7-tokenizer php7-zlib \ +RUN apk add --no-cache --update ca-certificates certbot nginx dcron curl tini php7 php7-bcmath php7-common php7-dom php7-fpm php7-gd php7-mbstring php7-openssl php7-zip php7-pdo php7-phar php7-json php7-pdo_mysql php7-session php7-ctype php7-tokenizer php7-zlib php7-simplexml \ && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer COPY . ./ -COPY .dev/docker/default.conf /etc/nginx/conf.d/default.conf - -RUN cp .env.example .env && composer install --no-dev +RUN cp .dev/docker/default.conf /etc/nginx/conf.d/default.conf \ + && cp .dev/docker/www.conf /etc/php7/php-fpm.d/www.conf \ + && cp .env.example .env \ + && composer install --no-dev EXPOSE 80 443 -RUN chown -R www-data:www-data . && chmod -R 777 storage/* bootstrap/cache /var/run/php - -ENTRYPOINT ["ash", ".dev/entrypoint.sh"] +RUN chown -R nginx:nginx . && chmod -R 777 storage/* bootstrap/cache +ENTRYPOINT ["ash", ".dev/entrypoint.sh"] \ No newline at end of file From 1ac13c82fa6c4daf588f0b067cd95818dcaf8cd6 Mon Sep 17 00:00:00 2001 From: "Michael (Parker) Parker" Date: Wed, 18 Jul 2018 17:15:28 -0400 Subject: [PATCH 10/18] more docker changes --- .dev/docker/README.md | 69 +++++++++++++++++++++++++++++++++ .dev/{ => docker}/entrypoint.sh | 8 ---- Dockerfile | 2 +- 3 files changed, 70 insertions(+), 9 deletions(-) create mode 100644 .dev/docker/README.md rename .dev/{ => docker}/entrypoint.sh (57%) diff --git a/.dev/docker/README.md b/.dev/docker/README.md new file mode 100644 index 000000000..b4d97ca36 --- /dev/null +++ b/.dev/docker/README.md @@ -0,0 +1,69 @@ +# Pterodactyl Panel - Docker Image +This is a ready to use docker image for the panel. + +## Requirements +This docker image requires some additional software to function. The software can either be provided in other containers (see the [docker-compose.yml](docker-compose.yml) as an example) or as existing instances. + +A mysql database is required. We recommend [this](quay.io/parkervcp/mariadb-alpine) image if you prefer to run it in a docker container. As a non-containerized option we recommend mariadb. + +A caching software is required as well. You can choose any of the [supported options](#cache-drivers). + +You can provide additional settings using a custom `.env` file or by setting the appropriate environment variables. + +## Setup + +Start the docker container and the required dependencies (either provide existing ones or start containers as well, see the [docker-compose.yml](docker-compose.yml) file as an example). + +After the startup is complete you'll need to create a user. +If you are running the docker container without docker-compose, use: +``` +docker exec -it php artisan pterodactyl:user +``` +If you are using docker compose use +``` +docker-compose exec panel php artisan pterodactyl:user +``` + +## Environment Variables +There are multiple environment variables to configure the panel when not providing your own `.env` file, see the following table for details on each available option. + +Note: If your `APP_URL` starts with `https://` you need to provide an `LETSENCRYPT_EMAIL` as well so Certificates can be generated. + +| Variable | Description | Required | +| ------------------- | ------------------------------------------------------------------------------ | -------- | +| `APP_URL` | The URL the panel will be reachable with (including protocol) | yes | +| `LETSENCRYPT_EMAIL` | The email used for letsencrypt certificate generation | yes | +| `DB_HOST` | The host of the mysql instance | yes | +| `DB_PORT` | The port of the mysql instance | yes | +| `DB_DATABASE` | The name of the mysql database | yes | +| `DB_USERNAME` | The mysql user | yes | +| `DB_PASSWORD` | The mysql password for the specified user | yes | +| `CACHE_DRIVER` | The cache driver (see [Cache drivers](#cache-drivers) for detais) | yes | +| `MAIL_DRIVER` | The email driver (see [Mail drivers](#mail-drivers) for details) | yes | +| `MAIL_FROM` | The email that should be used as the sender email | yes | +| `MAIL_HOST` | The host of your mail driver instance | maybe | +| `MAIL_PORT` | The port of your mail driver instance | maybe | +| `MAIL_USERNAME` | The username for your mail driver | maybe | +| `MAIL_PASSWORD` | The password for your mail driver | maybe | +| `APP_TIMEZONE` | The timezone to use for the panel | yes | + + +### Cache drivers +You can choose between different cache drivers depending on what you prefer. +We recommend redis when using docker as it can be started in a container easily. + +| Driver | Description | Required variables | +| -------- | ------------------------------------ | ------------------------------------------------------ | +| redis | | `REDIS_HOST` | + +### Mail drivers +You can choose between different mail drivers according to your needs. +Every driver requires `MAIL_FROM` to be set. + +| Driver | Description | Required variables | +| -------- | ------------------------------------ | ------------------------------------------------------------- | +| mail | uses the installed php mail | | +| mandrill | [Mandrill](http://www.mandrill.com/) | `MAIL_USERNAME` | +| postmark | [Postmark](https://postmarkapp.com/) | `MAIL_USERNAME` | +| mailgun | [Mailgun](https://www.mailgun.com/) | `MAIL_USERNAME`, `MAIL_HOST` | +| smtp | Any SMTP server can be configured | `MAIL_USERNAME`, `MAIL_HOST`, `MAIL_PASSWORD`, `MAIL_PORT` | diff --git a/.dev/entrypoint.sh b/.dev/docker/entrypoint.sh similarity index 57% rename from .dev/entrypoint.sh rename to .dev/docker/entrypoint.sh index 9cfcd0d53..ac4d8efb4 100644 --- a/.dev/entrypoint.sh +++ b/.dev/docker/entrypoint.sh @@ -10,14 +10,6 @@ do sleep 5 done -#sed -i s/DB_HOST=127.0.0.1/DB_HOST=$DB_HOST/g /app/.env -#sed -i s/DB_DATABASE=panel/DB_DATABASE=$DB_DATABASE/g /app/.env -#sed -i s/DB_USERNAME=pterodactyl/DB_USERNAME=$DB_USERNAME/g /app/.env -#sed -i s/DB_PASSWORD=/DB_PASSWORD=$DB_PASSWORD/g /app/.env - -#chown -R www-data:www-data . -chmod -R 777 storage/* bootstrap/cache /var/run/php /app/.env - if [ "$(cat .env)" == "" ]; then cat /app/.env.example > /app/.env fi diff --git a/Dockerfile b/Dockerfile index 7901e66bc..fa0afd7b9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,4 +16,4 @@ EXPOSE 80 443 RUN chown -R nginx:nginx . && chmod -R 777 storage/* bootstrap/cache -ENTRYPOINT ["ash", ".dev/entrypoint.sh"] \ No newline at end of file +ENTRYPOINT ["ash", ".dev/app/entrypoint.sh"] \ No newline at end of file From 63b76c60fbf44e6a2294f99e017e8fb40e002615 Mon Sep 17 00:00:00 2001 From: "Michael (Parker) Parker" Date: Sat, 4 Aug 2018 19:21:51 -0400 Subject: [PATCH 11/18] dockerfile changes --- .dev/docker/default_ssl.conf | 70 ++++++++++++++++++++++++++++++++++++ .dev/docker/entrypoint.sh | 39 +++++++++++++------- .gitignore | 3 +- Dockerfile | 6 ++-- docker-compose.yml | 62 ++++++++++++++++++++++++++++++++ 5 files changed, 164 insertions(+), 16 deletions(-) create mode 100644 .dev/docker/default_ssl.conf create mode 100644 docker-compose.yml diff --git a/.dev/docker/default_ssl.conf b/.dev/docker/default_ssl.conf new file mode 100644 index 000000000..b102d5723 --- /dev/null +++ b/.dev/docker/default_ssl.conf @@ -0,0 +1,70 @@ +# If using Ubuntu this file should be placed in: +# /etc/nginx/sites-available/ +# +server { + listen 80; + server_name ; + return 301 https://$server_name$request_uri; +} + +server { + listen 443 ssl http2; + server_name ; + + root /var/www/pterodactyl/public; + index index.php; + + access_log /var/log/nginx/pterodactyl.app-access.log; + error_log /var/log/nginx/pterodactyl.app-error.log error; + + # allow larger file uploads and longer script runtimes + client_max_body_size 100m; + client_body_timeout 120s; + + sendfile off; + + # strengthen ssl security + ssl_certificate /etc/letsencrypt/live//fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live//privkey.pem; + ssl_protocols TLSv1 TLSv1.1 TLSv1.2; + ssl_prefer_server_ciphers on; + ssl_session_cache shared:SSL:10m; + ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:ECDHE-RSA-AES128-GCM-SHA256:AES256+EECDH:DHE-RSA-AES128-GCM-SHA256:AES256+EDH:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4"; + + # See the link below for more SSL information: + # https://raymii.org/s/tutorials/Strong_SSL_Security_On_nginx.html + # + # ssl_dhparam /etc/ssl/certs/dhparam.pem; + + # Add headers to serve security related headers + add_header Strict-Transport-Security "max-age=15768000; preload;"; + add_header X-Content-Type-Options nosniff; + add_header X-XSS-Protection "1; mode=block"; + add_header X-Robots-Tag none; + add_header Content-Security-Policy "frame-ancestors 'self'"; + + location / { + try_files $uri $uri/ /index.php?$query_string; + } + + location ~ \.php$ { + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_pass unix:/run/php/pterodactyl.sock; + fastcgi_index index.php; + include fastcgi_params; + fastcgi_param PHP_VALUE "upload_max_filesize = 100M \n post_max_size=100M"; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param HTTP_PROXY ""; + fastcgi_intercept_errors off; + fastcgi_buffer_size 16k; + fastcgi_buffers 4 16k; + fastcgi_connect_timeout 300; + fastcgi_send_timeout 300; + fastcgi_read_timeout 300; + include /etc/nginx/fastcgi_params; + } + + location ~ /\.ht { + deny all; + } +} \ No newline at end of file diff --git a/.dev/docker/entrypoint.sh b/.dev/docker/entrypoint.sh index ac4d8efb4..454c1a2e3 100644 --- a/.dev/docker/entrypoint.sh +++ b/.dev/docker/entrypoint.sh @@ -1,24 +1,39 @@ #!/bin/ash +## Ensure we are in /app + cd /app -tini -- php-fpm +## check for .env file and generate app keys if missing +if [ -f /app/var/.env ]; then + echo "external vars exist" + rm /app/.env + ln -s /app/var/.env /app/ +else + echo "external vars don't exist" + php artisan key:generate --force + cp /app/.env /app/var/ +fi +## check for DB up before starting the panel +echo "Checking database status." until nc -z -v -w30 $DB_HOST 3306 + do echo "Waiting for database connection..." # wait for 5 seconds before check again sleep 5 done -if [ "$(cat .env)" == "" ]; then - cat /app/.env.example > /app/.env -fi - -if [ "$(cat .env | grep APP_KEY)" == "APP_KEY=" ]; then - echo "Generating New Key" - php artisan key:generate --force -fi - +## make sure the db is set up php artisan migrate --seed --force -echo "Done" -nginx -g 'pid /tmp/nginx.pid; daemon off;' + +echo -e "Done\n" + +## start php-fpm in the background +echo -e "Starting php-fpm in the background. \n" +php-fpm7 -D +echo -e "php-fpm starte.d \n" + +## start webserver +echo -e "Starting nginx in the foreground. \n" +nginx -g 'pid /tmp/nginx.pid; daemon off;' \ No newline at end of file diff --git a/.gitignore b/.gitignore index 33e412c01..36f2ddc95 100644 --- a/.gitignore +++ b/.gitignore @@ -20,8 +20,7 @@ sami.phar # For local development with docker # Remove if we ever put the Dockerfile in the repo .dockerignore -#Dockerfile -docker-compose.yml + # for image related files misc .phpstorm.meta.php diff --git a/Dockerfile b/Dockerfile index fa0afd7b9..56a6cad35 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,11 +9,13 @@ COPY . ./ RUN cp .dev/docker/default.conf /etc/nginx/conf.d/default.conf \ && cp .dev/docker/www.conf /etc/php7/php-fpm.d/www.conf \ - && cp .env.example .env \ + && echo "APP_ENVIRONMENT_ONLY=false" > /app/.env \ + && echo "APP_KEY=" >> /app/.env \ + && mkdir /var/run/php \ && composer install --no-dev EXPOSE 80 443 RUN chown -R nginx:nginx . && chmod -R 777 storage/* bootstrap/cache -ENTRYPOINT ["ash", ".dev/app/entrypoint.sh"] \ No newline at end of file +ENTRYPOINT ["ash", ".dev/docker/entrypoint.sh"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..96c3ead32 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,62 @@ +version: '2' +services: + database: + image: mariadb + volumes: + - "/srv/pterodactyl/database:/var/lib/mysql" + environment: + - "MYSQL_ROOT_PASSWORD=apassword" + - "MYSQL_DATABASE=pterodb" + - "MYSQL_USER=ptero" + - "MYSQL_PASSWORD=pterodbpass" + + cache: + image: redis:alpine + + panel: + image: quay.io/pterodactyl/panel:latest + ports: + - "80:80" + - "443:443" + links: + - database + - cache + volumes: + - "/srv/pterodactyl/var/:/app/var/" + environment: + ## These are defaults and should be left alone + - "APP_ENV=production" + - "APP_DEBUG=false" + - "APP_THEME=pterodactyl" + - "APP_CLEAR_TASKLOG=720" + - "APP_DELETE_MINUTES=10" + - "APP_ENVIRONMENT_ONLY=false" + - "QUEUE_HIGH=high" + - "QUEUE_STANDARD=standard" + - "QUEUE_LOW=low" + - "CACHE_DRIVER=redis" + - "SESSION_DRIVER=redis" + - "QUEUE_DRIVER=redis" + - "REDIS_HOST=cache_1" + - "REDIS_PASSWORD=null" + - "REDIS_PORT=6379" + ## Domain settings + - "APP_URL=https://your.domain.here" + ## Timezone settings + - "APP_TIMEZONE=America/New_York" + ## Service egg settings + - "APP_SERVICE_AUTHOR=noreply@your.domain.here" + ## Database settings + - "DB_HOST=database" + - "DB_PORT=3306" + - "DB_DATABASE=pterodb" + - "DB_USERNAME=ptero" + - "DB_PASSWORD=pterodbpass" + ## Email settings + - "MAIL_FROM=noreply@your.domain.here" + - "MAIL_DRIVER=smtp" + - "MAIL_HOST=mail" + - "MAIL_PORT=1025" + - "MAIL_USERNAME=''" + - "MAIL_PASSWORD=''" + - "MAIL_ENCRYPTION=true" \ No newline at end of file From 87e125ddadb9eda2bcd483879aa2b1cde9cc57bd Mon Sep 17 00:00:00 2001 From: "Michael (Parker) Parker" Date: Mon, 13 Aug 2018 23:33:15 -0400 Subject: [PATCH 12/18] key:generate is f'd --- .dev/docker/entrypoint.sh | 17 +++++++++++++---- Dockerfile | 6 +++--- docker-compose.yml | 2 ++ 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/.dev/docker/entrypoint.sh b/.dev/docker/entrypoint.sh index 454c1a2e3..f05d621a3 100644 --- a/.dev/docker/entrypoint.sh +++ b/.dev/docker/entrypoint.sh @@ -7,15 +7,24 @@ cd /app if [ -f /app/var/.env ]; then echo "external vars exist" rm /app/.env + ln -s /app/var/.env /app/ else echo "external vars don't exist" - php artisan key:generate --force - cp /app/.env /app/var/ + rm /app/.env + touch /app/var/.env + + ## manually generate a key because key generate --force fails + echo -e "Generating key" + APP_KEY=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1) + echo -e "Generated app key: $APP_KEY" + echo -e "APP_KEY=$APP_KEY" > /app/var/.env + + ln -s /app/var/.env /app/ fi ## check for DB up before starting the panel -echo "Checking database status." +zshoecho "Checking database status." until nc -z -v -w30 $DB_HOST 3306 do @@ -32,7 +41,7 @@ echo -e "Done\n" ## start php-fpm in the background echo -e "Starting php-fpm in the background. \n" php-fpm7 -D -echo -e "php-fpm starte.d \n" +echo -e "php-fpm started \n" ## start webserver echo -e "Starting nginx in the foreground. \n" diff --git a/Dockerfile b/Dockerfile index 56a6cad35..f9de52baa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,10 +9,10 @@ COPY . ./ RUN cp .dev/docker/default.conf /etc/nginx/conf.d/default.conf \ && cp .dev/docker/www.conf /etc/php7/php-fpm.d/www.conf \ - && echo "APP_ENVIRONMENT_ONLY=false" > /app/.env \ - && echo "APP_KEY=" >> /app/.env \ && mkdir /var/run/php \ - && composer install --no-dev + && cp .env.example .env \ + && composer install --no-dev --optimize-autoloader \ + && rm .env EXPOSE 80 443 diff --git a/docker-compose.yml b/docker-compose.yml index 96c3ead32..4ba268368 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -23,6 +23,7 @@ services: - cache volumes: - "/srv/pterodactyl/var/:/app/var/" + - "/srv/pterodactyl/certs/:/" environment: ## These are defaults and should be left alone - "APP_ENV=production" @@ -34,6 +35,7 @@ services: - "QUEUE_HIGH=high" - "QUEUE_STANDARD=standard" - "QUEUE_LOW=low" + ## Cache settings - "CACHE_DRIVER=redis" - "SESSION_DRIVER=redis" - "QUEUE_DRIVER=redis" From 47c100de2f1270f980aaf3cbba59c4cd4d4b9503 Mon Sep 17 00:00:00 2001 From: "Michael (Parker) Parker" Date: Tue, 14 Aug 2018 00:01:25 -0400 Subject: [PATCH 13/18] latest changes --- .dev/docker/README.md | 4 ++-- .dev/docker/www.conf | 4 +++- docker-compose.yml | 11 +++++++++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/.dev/docker/README.md b/.dev/docker/README.md index b4d97ca36..db10d5315 100644 --- a/.dev/docker/README.md +++ b/.dev/docker/README.md @@ -17,11 +17,11 @@ Start the docker container and the required dependencies (either provide existin After the startup is complete you'll need to create a user. If you are running the docker container without docker-compose, use: ``` -docker exec -it php artisan pterodactyl:user +docker exec -it php artisan p:user:make ``` If you are using docker compose use ``` -docker-compose exec panel php artisan pterodactyl:user +docker-compose exec panel php artisan p:user:make ``` ## Environment Variables diff --git a/.dev/docker/www.conf b/.dev/docker/www.conf index 808180b9c..88142564c 100644 --- a/.dev/docker/www.conf +++ b/.dev/docker/www.conf @@ -11,4 +11,6 @@ listen.mode = 0750 pm = ondemand pm.max_children = 9 pm.process_idle_timeout = 10s -pm.max_requests = 200 \ No newline at end of file +pm.max_requests = 200 + +clear_env = no \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 4ba268368..aaf27562b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,7 @@ version: '2' services: database: + hostname: database image: mariadb volumes: - "/srv/pterodactyl/database:/var/lib/mysql" @@ -11,6 +12,7 @@ services: - "MYSQL_PASSWORD=pterodbpass" cache: + hostname: redis image: redis:alpine panel: @@ -23,7 +25,6 @@ services: - cache volumes: - "/srv/pterodactyl/var/:/app/var/" - - "/srv/pterodactyl/certs/:/" environment: ## These are defaults and should be left alone - "APP_ENV=production" @@ -61,4 +62,10 @@ services: - "MAIL_PORT=1025" - "MAIL_USERNAME=''" - "MAIL_PASSWORD=''" - - "MAIL_ENCRYPTION=true" \ No newline at end of file + - "MAIL_ENCRYPTION=true" + +networks: + default: + ipam: + config: + - subnet: 172.20.0.0/16 From a4c54c4e47fd6d4f08ca0d694e7ad8d887eeb85f Mon Sep 17 00:00:00 2001 From: "Michael (Parker) Parker" Date: Tue, 14 Aug 2018 00:12:04 -0400 Subject: [PATCH 14/18] updated docker-compose updated docker-compose --- docker-compose.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index aaf27562b..02799382d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,18 +1,18 @@ version: '2' services: database: - hostname: database image: mariadb volumes: - "/srv/pterodactyl/database:/var/lib/mysql" environment: + ## Database settings + ## change if you want it to be more secure. - "MYSQL_ROOT_PASSWORD=apassword" - "MYSQL_DATABASE=pterodb" - "MYSQL_USER=ptero" - "MYSQL_PASSWORD=pterodbpass" cache: - hostname: redis image: redis:alpine panel: @@ -40,7 +40,7 @@ services: - "CACHE_DRIVER=redis" - "SESSION_DRIVER=redis" - "QUEUE_DRIVER=redis" - - "REDIS_HOST=cache_1" + - "REDIS_HOST=cache" - "REDIS_PASSWORD=null" - "REDIS_PORT=6379" ## Domain settings @@ -50,6 +50,7 @@ services: ## Service egg settings - "APP_SERVICE_AUTHOR=noreply@your.domain.here" ## Database settings + ## change if you want it to be more secure. - "DB_HOST=database" - "DB_PORT=3306" - "DB_DATABASE=pterodb" From 77dfd9815f83a39b107bbf761b081a0cdfeac593 Mon Sep 17 00:00:00 2001 From: "Michael (Parker) Parker" Date: Tue, 14 Aug 2018 00:14:13 -0400 Subject: [PATCH 15/18] moved compose to example moved the docker-compose script to an example and ignore docker-compose.yml --- .gitignore | 2 ++ docker-compose.yml => docker-compose.example.yml | 0 2 files changed, 2 insertions(+) rename docker-compose.yml => docker-compose.example.yml (100%) diff --git a/.gitignore b/.gitignore index 36f2ddc95..ab5175905 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,8 @@ sami.phar # For local development with docker # Remove if we ever put the Dockerfile in the repo .dockerignore +#Dockerfile +docker-compose.yml # for image related files misc diff --git a/docker-compose.yml b/docker-compose.example.yml similarity index 100% rename from docker-compose.yml rename to docker-compose.example.yml From e24abe9626b3ae6903279c4a332409e27a0ec7cd Mon Sep 17 00:00:00 2001 From: "Michael (Parker) Parker" Date: Sat, 18 Aug 2018 07:32:01 -0400 Subject: [PATCH 16/18] changes per schrej's request Lists the stock MariaDB Link instead of my old personal one. Corrects an echo command in the entrypoint. --- .dev/docker/README.md | 2 +- .dev/docker/entrypoint.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.dev/docker/README.md b/.dev/docker/README.md index db10d5315..6e877d8d3 100644 --- a/.dev/docker/README.md +++ b/.dev/docker/README.md @@ -4,7 +4,7 @@ This is a ready to use docker image for the panel. ## Requirements This docker image requires some additional software to function. The software can either be provided in other containers (see the [docker-compose.yml](docker-compose.yml) as an example) or as existing instances. -A mysql database is required. We recommend [this](quay.io/parkervcp/mariadb-alpine) image if you prefer to run it in a docker container. As a non-containerized option we recommend mariadb. +A mysql database is required. We recommend [this](https://hub.docker.com/_/mariadb/) image if you prefer to run it in a docker container. As a non-containerized option we recommend mariadb. A caching software is required as well. You can choose any of the [supported options](#cache-drivers). diff --git a/.dev/docker/entrypoint.sh b/.dev/docker/entrypoint.sh index f05d621a3..23ea4cda4 100644 --- a/.dev/docker/entrypoint.sh +++ b/.dev/docker/entrypoint.sh @@ -24,7 +24,7 @@ else fi ## check for DB up before starting the panel -zshoecho "Checking database status." +echo "Checking database status." until nc -z -v -w30 $DB_HOST 3306 do From d5f166d12104a201dce25808a83ec06109968add Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Mon, 3 Sep 2018 16:23:59 -0700 Subject: [PATCH 17/18] bump for release --- config/app.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/app.php b/config/app.php index a7c196b3c..a92ab0362 100644 --- a/config/app.php +++ b/config/app.php @@ -9,7 +9,7 @@ return [ | change this value if you are not maintaining your own internal versions. */ - 'version' => 'canary', + 'version' => '0.7.10', /* |-------------------------------------------------------------------------- From b370b2cb910f46bb3c6bb01486ad44bd5da4cade Mon Sep 17 00:00:00 2001 From: "Michael (Parker) Parker" Date: Sat, 15 Sep 2018 21:22:13 -0400 Subject: [PATCH 18/18] adding supervisord for queue workers Added supervisord to run the queue worker,. moved php-fpm and nginx to supervisord as well. --- .dev/docker/README.md | 19 ++++++++++++------ .dev/docker/entrypoint.sh | 18 ++++++++--------- .dev/docker/supervisord.conf | 39 ++++++++++++++++++++++++++++++++++++ Dockerfile | 19 +++++++++++------- 4 files changed, 72 insertions(+), 23 deletions(-) create mode 100644 .dev/docker/supervisord.conf diff --git a/.dev/docker/README.md b/.dev/docker/README.md index 6e877d8d3..c5c2991c7 100644 --- a/.dev/docker/README.md +++ b/.dev/docker/README.md @@ -4,11 +4,11 @@ This is a ready to use docker image for the panel. ## Requirements This docker image requires some additional software to function. The software can either be provided in other containers (see the [docker-compose.yml](docker-compose.yml) as an example) or as existing instances. -A mysql database is required. We recommend [this](https://hub.docker.com/_/mariadb/) image if you prefer to run it in a docker container. As a non-containerized option we recommend mariadb. +A mysql database is required. We recommend the stock [MariaDB Image](https://hub.docker.com/_/mariadb/) image if you prefer to run it in a docker container. As a non-containerized option we recommend mariadb. -A caching software is required as well. You can choose any of the [supported options](#cache-drivers). +A caching software is required as well. We recommend the stock [Redis Image](https://hub.docker.com/_/redis/) image. You can choose any of the [supported options](#cache-drivers). -You can provide additional settings using a custom `.env` file or by setting the appropriate environment variables. +You can provide additional settings using a custom `.env` file or by setting the appropriate environment variables in the docker-compose file. ## Setup @@ -32,6 +32,7 @@ Note: If your `APP_URL` starts with `https://` you need to provide an `LETSENCRY | Variable | Description | Required | | ------------------- | ------------------------------------------------------------------------------ | -------- | | `APP_URL` | The URL the panel will be reachable with (including protocol) | yes | +| `APP_TIMEZONE` | The timezone to use for the panel | yes | | `LETSENCRYPT_EMAIL` | The email used for letsencrypt certificate generation | yes | | `DB_HOST` | The host of the mysql instance | yes | | `DB_PORT` | The port of the mysql instance | yes | @@ -39,13 +40,17 @@ Note: If your `APP_URL` starts with `https://` you need to provide an `LETSENCRY | `DB_USERNAME` | The mysql user | yes | | `DB_PASSWORD` | The mysql password for the specified user | yes | | `CACHE_DRIVER` | The cache driver (see [Cache drivers](#cache-drivers) for detais) | yes | +| `SESSION_DRIVER` | | yes | +| `QUEUE_DRIVER` | | yes | +| `REDIS_HOST` | The hostname or IP address of the redis database | yes | +| `REDIS_PASSWORD` | The password used to secure the redis database | maybe | +| `REDIS_PORT` | The port the redis database is using on the host | maybe | | `MAIL_DRIVER` | The email driver (see [Mail drivers](#mail-drivers) for details) | yes | | `MAIL_FROM` | The email that should be used as the sender email | yes | | `MAIL_HOST` | The host of your mail driver instance | maybe | | `MAIL_PORT` | The port of your mail driver instance | maybe | | `MAIL_USERNAME` | The username for your mail driver | maybe | | `MAIL_PASSWORD` | The password for your mail driver | maybe | -| `APP_TIMEZONE` | The timezone to use for the panel | yes | ### Cache drivers @@ -54,7 +59,9 @@ We recommend redis when using docker as it can be started in a container easily. | Driver | Description | Required variables | | -------- | ------------------------------------ | ------------------------------------------------------ | -| redis | | `REDIS_HOST` | +| redis | host where redis is running | `REDIS_HOST` | +| redis | port redis is running on | `REDIS_PORT` | +| redis | redis database password | `REDIS_PASSWORD` | ### Mail drivers You can choose between different mail drivers according to your needs. @@ -66,4 +73,4 @@ Every driver requires `MAIL_FROM` to be set. | mandrill | [Mandrill](http://www.mandrill.com/) | `MAIL_USERNAME` | | postmark | [Postmark](https://postmarkapp.com/) | `MAIL_USERNAME` | | mailgun | [Mailgun](https://www.mailgun.com/) | `MAIL_USERNAME`, `MAIL_HOST` | -| smtp | Any SMTP server can be configured | `MAIL_USERNAME`, `MAIL_HOST`, `MAIL_PASSWORD`, `MAIL_PORT` | +| smtp | Any SMTP server can be configured | `MAIL_USERNAME`, `MAIL_HOST`, `MAIL_PASSWORD`, `MAIL_PORT` | \ No newline at end of file diff --git a/.dev/docker/entrypoint.sh b/.dev/docker/entrypoint.sh index 23ea4cda4..772645f62 100644 --- a/.dev/docker/entrypoint.sh +++ b/.dev/docker/entrypoint.sh @@ -34,15 +34,13 @@ do done ## make sure the db is set up -php artisan migrate --seed --force +echo -e "Migrating and Seeding DB" +php artisan migrate --force +php artisan db:seed --force -echo -e "Done\n" +## start cronjobs for the queue +echo -e "Starting cron jobs" +crond -## start php-fpm in the background -echo -e "Starting php-fpm in the background. \n" -php-fpm7 -D -echo -e "php-fpm started \n" - -## start webserver -echo -e "Starting nginx in the foreground. \n" -nginx -g 'pid /tmp/nginx.pid; daemon off;' \ No newline at end of file +echo -e "Starting supervisord" +exec "$@" \ No newline at end of file diff --git a/.dev/docker/supervisord.conf b/.dev/docker/supervisord.conf new file mode 100644 index 000000000..f2fd3a1b5 --- /dev/null +++ b/.dev/docker/supervisord.conf @@ -0,0 +1,39 @@ +[unix_http_server] +file=/tmp/supervisor.sock ; path to your socket file + +[supervisord] +logfile=/var/log/supervisord/supervisord.log ; supervisord log file +logfile_maxbytes=50MB ; maximum size of logfile before rotation +logfile_backups=2 ; number of backed up logfiles +loglevel=error ; info, debug, warn, trace +pidfile=/var/run/supervisord.pid ; pidfile location +nodaemon=false ; run supervisord as a daemon +minfds=1024 ; number of startup file descriptors +minprocs=200 ; number of process descriptors +user=root ; default user +childlogdir=/var/log/supervisord/ ; where child log files will live + +[rpcinterface:supervisor] +supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface + +[supervisorctl] +serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL for a unix socket + +[program:php-fpm] +command=/usr/sbin/php-fpm7 -F +autostart=true +autorestart=true + +[program:queue-worker] +command=/usr/bin/php /app/artisan queue:work --queue=high,standard,low --sleep=3 --tries=3 +user=nginx +autostart=true +autorestart=true + +[program:nginx] +command=/usr/sbin/nginx -g 'daemon off;' +autostart=true +autorestart=true +priority=10 +stdout_events_enabled=true +stderr_events_enabled=true \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index f9de52baa..ae96a60cd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,20 +2,25 @@ FROM alpine:3.8 WORKDIR /app -RUN apk add --no-cache --update ca-certificates certbot nginx dcron curl tini php7 php7-bcmath php7-common php7-dom php7-fpm php7-gd php7-mbstring php7-openssl php7-zip php7-pdo php7-phar php7-json php7-pdo_mysql php7-session php7-ctype php7-tokenizer php7-zlib php7-simplexml \ +RUN apk add --no-cache --update ca-certificates certbot nginx dcron curl tini php7 php7-bcmath php7-common php7-dom php7-fpm php7-gd php7-mbstring php7-openssl php7-zip php7-pdo php7-phar php7-json php7-pdo_mysql php7-session php7-ctype php7-tokenizer php7-zlib php7-simplexml supervisor \ && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer COPY . ./ +RUN cp .env.example .env \ + && composer install --no-dev --optimize-autoloader \ + && rm .env \ + && chown -R nginx:nginx . && chmod -R 777 storage/* bootstrap/cache + RUN cp .dev/docker/default.conf /etc/nginx/conf.d/default.conf \ && cp .dev/docker/www.conf /etc/php7/php-fpm.d/www.conf \ - && mkdir /var/run/php \ - && cp .env.example .env \ - && composer install --no-dev --optimize-autoloader \ - && rm .env + && cat .dev/docker/supervisord.conf > /etc/supervisord.conf \ + && echo "* * * * * /usr/bin/php /app/pterodactyl/artisan schedule:run >> /dev/null 2>&1" >> /var/spool/cron/crontabs/root \ + && mkdir -p /var/run/php /var/run/nginx \ + && mkdir -p /var/log/supervisord/ EXPOSE 80 443 -RUN chown -R nginx:nginx . && chmod -R 777 storage/* bootstrap/cache +ENTRYPOINT ["/bin/ash", ".dev/docker/entrypoint.sh"] -ENTRYPOINT ["ash", ".dev/docker/entrypoint.sh"] \ No newline at end of file +CMD [ "supervisord", "-n", "-c", "/etc/supervisord.conf" ] \ No newline at end of file