Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
FROM php:7.0-alpine
FROM php:7.1-alpine

MAINTAINER ipunkt Business Solutions <info@ipunkt.biz>
LABEL maintainer="ipunkt Business Solutions <info@ipunkt.biz>"
LABEL version="php7.1-v2.0"
LABEL description="A supervisor configured to run with laravel artisan queue:work or artisan horizon command"

ENV PYTHON_VERSION=2.7.12-r0
ENV PY_PIP_VERSION=8.1.2-r0
ENV SUPERVISOR_VERSION=3.3.1
ENV SUPERVISOR_VERSION=3.3.3

ENV QUEUE_CONNECTION=redis
ENV QUEUE_NAME=default
ENV LARAVEL_HORIZON=false

# Install pdo if you want to use database queue
RUN docker-php-ext-install pdo pdo_mysql
RUN docker-php-ext-install pdo pdo_mysql pcntl posix

# Install supervisor
RUN apk update && apk add -u python=$PYTHON_VERSION py-pip=$PY_PIP_VERSION
Expand All @@ -21,6 +24,7 @@ WORKDIR /etc/supervisor/conf.d

# Use local configuration
COPY laravel-worker.conf.tpl /etc/supervisor/conf.d/laravel-worker.conf.tpl
COPY laravel-horizon.conf.tpl /etc/supervisor/conf.d/laravel-horizon.conf.tpl

# Copy scripts
COPY init.sh /usr/local/bin/init.sh
Expand Down
18 changes: 15 additions & 3 deletions init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,20 @@ if [ -z "$QUEUE_NAME" ]; then
QUEUE_NAME="default"
fi

sed -e "s~%%QUEUE_CONNECTION%%~$QUEUE_CONNECTION~" \
-e "s~%%QUEUE_NAME%%~$QUEUE_NAME~" \
/etc/supervisor/conf.d/laravel-worker.conf.tpl > /etc/supervisor/supervisord.conf
if [ -z "$LARAVEL_HORIZON" ]; then
LARAVEL_HORIZON=false
fi

if [ "$LARAVEL_HORIZON" = false ]; then
sed -e "s~%%QUEUE_CONNECTION%%~$QUEUE_CONNECTION~" \
-e "s~%%QUEUE_NAME%%~$QUEUE_NAME~" \
/etc/supervisor/conf.d/laravel-worker.conf.tpl > /etc/supervisor/supervisord.conf
fi

if [ "$LARAVEL_HORIZON" = true ]; then
sed -e "s~%%QUEUE_CONNECTION%%~$QUEUE_CONNECTION~" \
-e "s~%%QUEUE_NAME%%~$QUEUE_NAME~" \
/etc/supervisor/conf.d/laravel-horizon.conf.tpl > /etc/supervisor/supervisord.conf
fi

supervisord --nodaemon --configuration /etc/supervisor/supervisord.conf
11 changes: 11 additions & 0 deletions laravel-horizon.conf.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[supervisord]
nodaemon=true

[program:laravel-horizon]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/app/artisan horizon
autostart=true
autorestart=true
numprocs=1
startretries=10
stdout_events_enabled=1