Skip to content

Commit fe72539

Browse files
committed
Code cleanup and improvement
1 parent a07e6bd commit fe72539

File tree

8 files changed

+81
-94
lines changed

8 files changed

+81
-94
lines changed
File renamed without changes.
Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
#!/bin/ash
2-
## Ensure we are in /app
3-
42
cd /app
53

64
mkdir -p /var/log/panel/logs/ /var/log/supervisord/ /var/log/nginx/ /var/log/php7/ \
7-
&& rm -rf /app/storage/logs/ \
8-
&& chmod 777 /var/log/panel/logs/ \
9-
&& ln -s /var/log/panel/logs/ /app/storage/
5+
&& chmod 777 /var/log/panel/logs/ \
6+
&& ln -s /var/log/panel/logs/ /app/storage/
107

118
## check for .env file and generate app keys if missing
129
if [ -f /app/var/.env ]; then
1310
echo "external vars exist."
1411
rm -rf /app/.env
15-
1612
ln -s /app/var/.env /app/
1713
else
1814
echo "external vars don't exist."
@@ -60,7 +56,6 @@ fi
6056
## check for DB up before starting the panel
6157
echo "Checking database status."
6258
until nc -z -v -w30 $DB_HOST 3306
63-
6459
do
6560
echo "Waiting for database connection..."
6661
# wait for 5 seconds before check again
@@ -69,17 +64,11 @@ done
6964

7065
## make sure the db is set up
7166
echo -e "Migrating and Seeding D.B"
72-
php artisan migrate --force
73-
php artisan db:seed --force
67+
php artisan migrate --seed --force
7468

7569
## start cronjobs for the queue
7670
echo -e "Starting cron jobs."
7771
crond -L /var/log/crond -l 5
7872

79-
## install yarn stuff
80-
yarn install --production
81-
yarn add cross-env
82-
yarn run build:production
83-
8473
echo -e "Starting supervisord."
8574
exec "$@"
File renamed without changes.

Dockerfile

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,40 @@
1-
FROM php:7.4-fpm-alpine
2-
1+
# Stage 0:
2+
# Build the assets that are needed for the frontend. This build stage is then discarded
3+
# since we won't need NodeJS anymore in the future. This Docker image ships a final production
4+
# level distribution of Pterodactyl.
5+
FROM mhart/alpine-node:14
36
WORKDIR /app
4-
5-
RUN apk add --no-cache --update ca-certificates dcron curl git supervisor tar unzip nginx libpng-dev libxml2-dev libzip-dev certbot yarn; \
6-
docker-php-ext-install bcmath; \
7-
docker-php-ext-install gd; \
8-
docker-php-ext-install mbstring; \
9-
docker-php-ext-install pdo; \
10-
docker-php-ext-install pdo_mysql; \
11-
docker-php-ext-install tokenizer; \
12-
docker-php-ext-install xml; \
13-
docker-php-ext-configure zip --with-libzip=/usr/include; \
14-
docker-php-ext-install zip; \
15-
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
16-
177
COPY . ./
8+
RUN yarn install --frozen-lockfile \
9+
&& yarn run build:production
1810

19-
RUN cp .env.example .env \
20-
&& composer install --no-dev --optimize-autoloader \
21-
&& rm .env \
22-
&& chown -R nginx:nginx . && chmod -R 777 storage/* bootstrap/cache
23-
24-
RUN cp docker/default.conf /etc/nginx/conf.d/default.conf \
25-
&& cat docker/www.conf > /usr/local/etc/php-fpm.d/www.conf \
26-
&& rm /usr/local/etc/php-fpm.d/www.conf.default \
27-
&& cat docker/supervisord.conf > /etc/supervisord.conf \
28-
&& echo "* * * * * /usr/local/bin/php /app/artisan schedule:run >> /dev/null 2>&1" >> /var/spool/cron/crontabs/root \
29-
&& sed -i s/ssl_session_cache/#ssl_session_cache/g /etc/nginx/nginx.conf \
30-
&& mkdir -p /var/run/php /var/run/nginx
11+
# Stage 1:
12+
# Build the actual container with all of the needed PHP dependencies that will run the application.
13+
FROM php:7.4-fpm-alpine
14+
WORKDIR /app
15+
COPY . ./
16+
COPY --from=0 /app/public/assets ./public/assets
17+
RUN apk add --no-cache --update ca-certificates dcron curl git supervisor tar unzip nginx libpng-dev libxml2-dev libzip-dev certbot \
18+
&& docker-php-ext-configure zip \
19+
&& docker-php-ext-install bcmath gd pdo_mysql zip \
20+
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
21+
&& cp .env.example .env \
22+
&& mkdir -p bootstrap/cache/ storage/framework/sessions storage/framework/views storage/framework/cache \
23+
&& chmod 777 -R bootstrap storage \
24+
&& composer install --no-dev --optimize-autoloader \
25+
&& rm -rf .env bootstrap/cache/*.php storage \
26+
&& chown -R nginx:nginx .
27+
28+
RUN rm /usr/local/etc/php-fpm.d/www.conf.default \
29+
&& echo "* * * * * /usr/local/bin/php /app/artisan schedule:run >> /dev/null 2>&1" >> /var/spool/cron/crontabs/root \
30+
&& sed -i s/ssl_session_cache/#ssl_session_cache/g /etc/nginx/nginx.conf \
31+
&& mkdir -p /var/run/php /var/run/nginx \
32+
&& apk del --no-cache libpng-dev libxml2-dev libzip-dev
33+
34+
COPY .github/docker/default.conf /etc/nginx/conf.d/default.conf
35+
COPY .github/docker/www.conf /usr/local/etc/php-fpm.d/www.conf
36+
COPY .github/docker/supervisord.conf /etc/supervisord.conf
3137

3238
EXPOSE 80 443
33-
34-
ENTRYPOINT ["/bin/ash", "docker/entrypoint.sh"]
35-
39+
ENTRYPOINT ["/bin/ash", ".github/docker/entrypoint.sh"]
3640
CMD [ "supervisord", "-n", "-c", "/etc/supervisord.conf" ]

docker-compose.example.yml

Lines changed: 44 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,47 @@
1-
version: '2'
1+
version: '3.8'
2+
x-common:
3+
database: &db-environment
4+
# Do not remove the "&db-password" from the end of the line below, it is important
5+
# for Panel functionality.
6+
MYSQL_PASSWORD: "CHANGE_ME" &db-password
7+
MYSQL_ROOT_PASSWORD: "CHANGE_ME_TOO"
8+
panel: &panel-environment
9+
APP_URL: "https://your.domain.here"
10+
# A list of valid timezones can be found here: http://php.net/manual/en/timezones.php
11+
APP_TIMEZONE: "UTC"
12+
APP_SERVICE_AUTHOR: "noreply@example.com"
13+
# Uncomment the line below and set to a non-empty value if you want to use Let's Encrypt
14+
# to generate an SSL certificate for the Panel.
15+
# LE_EMAIL: ""
16+
mail: &mail-environment
17+
MAIL_FROM: "noreply@example.com"
18+
MAIL_DRIVER: "smtp"
19+
MAIL_HOST: "mail"
20+
MAIL_PORT: "1025"
21+
MAIL_USERNAME: ""
22+
MAIL_PASSWORD: ""
23+
MAIL_ENCRYPTION: "true"
24+
25+
#
26+
# ------------------------------------------------------------------------------------------
27+
# DANGER ZONE BELOW
28+
#
29+
# The remainder of this file likely does not need to be changed. Please only make modifications
30+
# below if you understand what you are doing.
31+
#
232
services:
333
database:
434
image: mariadb:10.4
535
restart: always
636
volumes:
737
- "/srv/pterodactyl/database:/var/lib/mysql"
838
environment:
9-
## Database settings
10-
## change if you want it to be more secure.
11-
- "MYSQL_ROOT_PASSWORD=apassword"
12-
- "MYSQL_DATABASE=pterodb"
13-
- "MYSQL_USER=ptero"
14-
- "MYSQL_PASSWORD=pterodbpass"
15-
39+
<<: *db-environment
40+
MYSQL_DATABASE: "panel"
41+
MYSQL_USER: "pterodactyl"
1642
cache:
1743
image: redis:alpine
1844
restart: always
19-
2045
panel:
2146
image: quay.io/pterodactyl/panel:latest
2247
restart: always
@@ -32,47 +57,16 @@ services:
3257
- "/srv/pterodactyl/certs/:/etc/letsencrypt/"
3358
- "/srv/pterodactyl/logs/:/var/log/"
3459
environment:
35-
## These are defaults and should be left alone
36-
- "APP_ENV=production"
37-
- "APP_DEBUG=false"
38-
- "APP_THEME=pterodactyl"
39-
- "APP_CLEAR_TASKLOG=720"
40-
- "APP_DELETE_MINUTES=10"
41-
- "APP_ENVIRONMENT_ONLY=false"
42-
- "QUEUE_HIGH=high"
43-
- "QUEUE_STANDARD=standard"
44-
- "QUEUE_LOW=low"
45-
## Cache settings
46-
- "CACHE_DRIVER=redis"
47-
- "SESSION_DRIVER=redis"
48-
- "QUEUE_DRIVER=redis"
49-
- "REDIS_HOST=cache"
50-
- "REDIS_PASSWORD=null"
51-
- "REDIS_PORT=6379"
52-
## Domain settings
53-
- "APP_URL=https://your.domain.here" ## if you are running this behind a reverse proxy with ssl app_url needs to be https still.
54-
## Timezone settings
55-
- "APP_TIMEZONE=UTC" ## http://php.net/manual/en/timezones.php
56-
## Service egg settings
57-
- "APP_SERVICE_AUTHOR=noreply@your.domain.here" ## this is the email that gets put on eggs you create
58-
## Database settings
59-
## These can be left alone. Only change if you know what you are doing.
60-
- "DB_HOST=database"
61-
- "DB_PORT=3306"
62-
- "DB_DATABASE=pterodb"
63-
- "DB_USERNAME=ptero"
64-
- "DB_PASSWORD=pterodbpass"
65-
## Email settings
66-
- "MAIL_FROM=noreply@your.domain.here"
67-
- "MAIL_DRIVER=smtp"
68-
- "MAIL_HOST=mail"
69-
- "MAIL_PORT=1025"
70-
- "MAIL_USERNAME=''"
71-
- "MAIL_PASSWORD=''"
72-
- "MAIL_ENCRYPTION=true"
73-
## certbot settings - Used to automatically generate ssl certs and
74-
# - "LE_EMAIL=" ## uncomment if you are using ssl
75-
60+
<<: *panel-environment
61+
<<: *mail-environment
62+
DB_PASSWORD: *db-password
63+
APP_ENV: "production"
64+
APP_ENVIRONMENT_ONLY: "false"
65+
CACHE_DRIVER: "redis"
66+
SESSION_DRIVER: "redis"
67+
QUEUE_DRIVER: "redis"
68+
REDIS_HOST: "cache"
69+
DB_HOST: "database"
7670
networks:
7771
default:
7872
ipam:

0 commit comments

Comments
 (0)