adding supervisord for queue workers
Added supervisord to run the queue worker,. moved php-fpm and nginx to supervisord as well.
This commit is contained in:
parent
e24abe9626
commit
b370b2cb91
4 changed files with 72 additions and 23 deletions
|
@ -4,11 +4,11 @@ This is a ready to use docker image for the panel.
|
||||||
## Requirements
|
## 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.
|
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
|
## Setup
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@ Note: If your `APP_URL` starts with `https://` you need to provide an `LETSENCRY
|
||||||
| Variable | Description | Required |
|
| Variable | Description | Required |
|
||||||
| ------------------- | ------------------------------------------------------------------------------ | -------- |
|
| ------------------- | ------------------------------------------------------------------------------ | -------- |
|
||||||
| `APP_URL` | The URL the panel will be reachable with (including protocol) | yes |
|
| `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 |
|
| `LETSENCRYPT_EMAIL` | The email used for letsencrypt certificate generation | yes |
|
||||||
| `DB_HOST` | The host of the mysql instance | yes |
|
| `DB_HOST` | The host of the mysql instance | yes |
|
||||||
| `DB_PORT` | The port 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_USERNAME` | The mysql user | yes |
|
||||||
| `DB_PASSWORD` | The mysql password for the specified 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 |
|
| `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_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_FROM` | The email that should be used as the sender email | yes |
|
||||||
| `MAIL_HOST` | The host of your mail driver instance | maybe |
|
| `MAIL_HOST` | The host of your mail driver instance | maybe |
|
||||||
| `MAIL_PORT` | The port 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_USERNAME` | The username for your mail driver | maybe |
|
||||||
| `MAIL_PASSWORD` | The password 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
|
### 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 |
|
| 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
|
### Mail drivers
|
||||||
You can choose between different mail drivers according to your needs.
|
You can choose between different mail drivers according to your needs.
|
||||||
|
|
|
@ -34,15 +34,13 @@ do
|
||||||
done
|
done
|
||||||
|
|
||||||
## make sure the db is set up
|
## 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 supervisord"
|
||||||
echo -e "Starting php-fpm in the background. \n"
|
exec "$@"
|
||||||
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;'
|
|
39
.dev/docker/supervisord.conf
Normal file
39
.dev/docker/supervisord.conf
Normal file
|
@ -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
|
19
Dockerfile
19
Dockerfile
|
@ -2,20 +2,25 @@ FROM alpine:3.8
|
||||||
|
|
||||||
WORKDIR /app
|
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
|
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
||||||
|
|
||||||
COPY . ./
|
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 \
|
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 .dev/docker/www.conf /etc/php7/php-fpm.d/www.conf \
|
||||||
&& mkdir /var/run/php \
|
&& cat .dev/docker/supervisord.conf > /etc/supervisord.conf \
|
||||||
&& cp .env.example .env \
|
&& echo "* * * * * /usr/bin/php /app/pterodactyl/artisan schedule:run >> /dev/null 2>&1" >> /var/spool/cron/crontabs/root \
|
||||||
&& composer install --no-dev --optimize-autoloader \
|
&& mkdir -p /var/run/php /var/run/nginx \
|
||||||
&& rm .env
|
&& mkdir -p /var/log/supervisord/
|
||||||
|
|
||||||
EXPOSE 80 443
|
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"]
|
CMD [ "supervisord", "-n", "-c", "/etc/supervisord.conf" ]
|
Loading…
Reference in a new issue