From e9084d432f4c93f1c9cc4d03881de3aa72ccb4a7 Mon Sep 17 00:00:00 2001 From: "Michael (Parker) Parker" Date: Sat, 10 Nov 2018 18:57:49 -0500 Subject: [PATCH] update image for 0.7.11 --- .dev/docker/default_ssl.conf | 4 ++-- .dev/docker/entrypoint.sh | 38 +++++++++++++++++++++++++++++------- Dockerfile | 6 +++--- docker-compose.example.yml | 15 +++++++++----- 4 files changed, 46 insertions(+), 17 deletions(-) diff --git a/.dev/docker/default_ssl.conf b/.dev/docker/default_ssl.conf index b102d5723..c2c2b6df0 100644 --- a/.dev/docker/default_ssl.conf +++ b/.dev/docker/default_ssl.conf @@ -11,7 +11,7 @@ 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; @@ -49,7 +49,7 @@ server { location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; - fastcgi_pass unix:/run/php/pterodactyl.sock; + 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"; diff --git a/.dev/docker/entrypoint.sh b/.dev/docker/entrypoint.sh index 772645f62..c2b58375a 100644 --- a/.dev/docker/entrypoint.sh +++ b/.dev/docker/entrypoint.sh @@ -3,19 +3,24 @@ cd /app +mkdir -p /var/log/panel/logs/ /var/log/supervisord/ /var/log/nginx/ /var/log/php7/ \ +&& rmdir /app/storage/logs/ \ +&& chmod 777 /var/log/panel/logs/ \ +&& ln -s /var/log/panel/logs/ /app/storage/ + ## check for .env file and generate app keys if missing if [ -f /app/var/.env ]; then - echo "external vars exist" + echo "external vars exist." rm /app/.env ln -s /app/var/.env /app/ else - echo "external vars don't exist" + echo "external vars don't exist." rm /app/.env touch /app/var/.env ## manually generate a key because key generate --force fails - echo -e "Generating key" + 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 @@ -23,6 +28,25 @@ else ln -s /app/var/.env /app/ fi +echo "Checking if https is required." +if [ -f /etc/nginx/conf.d/default.conf ]; then + echo "Using nginx config already in place." +else + echo "Checking if letsencrypt email is set." + if [ -z $LE_EMAIL ]; then + echo "No letsencrypt email is set Failing to http." + cp .dev/docker/default.conf /etc/nginx/conf.d/default.conf + + else + echo "writing ssl config" + cp .dev/docker/default_ssl.conf /etc/nginx/conf.d/default.conf + echo "updating ssl config for domain" + sed -i "s||$(echo $APP_URL | sed 's~http[s]*://~~g')|g" /etc/nginx/conf.d/default.conf + echo "generating certs" + certbot certonly -d $(echo $APP_URL | sed 's~http[s]*://~~g') --standalone -m $LE_EMAIL --agree-tos -n + fi +fi + ## check for DB up before starting the panel echo "Checking database status." until nc -z -v -w30 $DB_HOST 3306 @@ -34,13 +58,13 @@ do done ## make sure the db is set up -echo -e "Migrating and Seeding DB" +echo -e "Migrating and Seeding D.B" php artisan migrate --force php artisan db:seed --force ## start cronjobs for the queue -echo -e "Starting cron jobs" -crond +echo -e "Starting cron jobs." +crond -L /var/log/crond -l 5 -echo -e "Starting supervisord" +echo -e "Starting supervisord." exec "$@" \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index ed4ede4ff..22c151b35 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,9 +15,9 @@ RUN cp .env.example .env \ RUN cp .dev/docker/default.conf /etc/nginx/conf.d/default.conf \ && cp .dev/docker/www.conf /etc/php7/php-fpm.d/www.conf \ && 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/ + && echo "* * * * * /usr/bin/php /app/artisan schedule:run >> /dev/null 2>&1" >> /var/spool/cron/crontabs/root \ + && sed -i s/ssl_session_cache/#ssl_session_cache/g /etc/nginx/nginx.conf \ + && mkdir -p /var/run/php /var/run/nginx EXPOSE 80 443 diff --git a/docker-compose.example.yml b/docker-compose.example.yml index 02799382d..eb1bfaddf 100644 --- a/docker-compose.example.yml +++ b/docker-compose.example.yml @@ -25,6 +25,9 @@ services: - cache volumes: - "/srv/pterodactyl/var/:/app/var/" + - "/srv/pterodactyl/nginx/:/etc/nginx/conf.d/" + - "/srv/pterodactyl/certs/:/etc/letsencrypt/" + - "/srv/pterodactyl/logs/:/var/log/" environment: ## These are defaults and should be left alone - "APP_ENV=production" @@ -44,14 +47,14 @@ services: - "REDIS_PASSWORD=null" - "REDIS_PORT=6379" ## Domain settings - - "APP_URL=https://your.domain.here" + - "APP_URL=https://your.domain.here" ## if you are running this behind a reverse proxy with ssl app_url needs to be https still. ## Timezone settings - - "APP_TIMEZONE=America/New_York" + - "APP_TIMEZONE=UTC" ## http://php.net/manual/en/timezones.php ## Service egg settings - - "APP_SERVICE_AUTHOR=noreply@your.domain.here" + - "APP_SERVICE_AUTHOR=noreply@your.domain.here" ## this is the email that gets put on eggs you create ## Database settings - ## change if you want it to be more secure. - - "DB_HOST=database" + ## These can be left alone. Only change if you know what you are doing. + - "DB_HOST=database" - "DB_PORT=3306" - "DB_DATABASE=pterodb" - "DB_USERNAME=ptero" @@ -64,6 +67,8 @@ services: - "MAIL_USERNAME=''" - "MAIL_PASSWORD=''" - "MAIL_ENCRYPTION=true" + ## certbot settings - Used to automatically generate ssl certs and + - "LE_EMAIL=''" ## leave blank unless you aree generating certs. networks: default: