From 87e125ddadb9eda2bcd483879aa2b1cde9cc57bd Mon Sep 17 00:00:00 2001
From: "Michael (Parker) Parker" <parkervcp@gmail.com>
Date: Mon, 13 Aug 2018 23:33:15 -0400
Subject: [PATCH] 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"