Add supervisor to docker for dev/demo

Allows us to run cron process and the server in
one container.
This commit is contained in:
Paul McLanahan 2016-03-24 14:04:23 -04:00
Родитель 47720aac5c
Коммит 6ee727152d
7 изменённых файлов: 51 добавлений и 5 удалений

Просмотреть файл

@ -1,13 +1,16 @@
from mozorg/bedrock_base
RUN apt-get install -y --no-install-recommends npm
COPY . /app
COPY ./node_modules ./
COPY package.json ./
RUN npm install --production
COPY ./requirements/ ./requirements/
RUN pip install --no-cache-dir -r requirements/dev.txt
RUN pip install --no-cache-dir -r requirements/prod.txt
RUN pip install --no-cache-dir -r requirements/docker.txt
RUN pip install --no-cache-dir -r requirements/docker-dev.txt
COPY . ./
RUN ./manage.py collectstatic -l --noinput
@ -18,5 +21,7 @@ RUN ./docker/bin/softlinkstatic.py
RUN bash -c "if [[ ! -e locale ]]; then git clone --depth 1 https://github.com/mozilla-l10n/bedrock-l10n locale; fi"
# Change User
# No USER directive since supervisor is set to run processes as webdev
RUN chown webdev.webdev -R .
USER webdev
CMD ["docker/run-supervisor.sh"]

14
docker/run-supervisor.sh Executable file
Просмотреть файл

@ -0,0 +1,14 @@
#!/bin/bash
set -xe
enable_proc() {
cp "etc/supervisor_available/$1.conf" "etc/supervisor_enabled/$1.conf"
}
DEV=$(echo "$DEV" | tr '[:upper:]' '[:lower:]')
enable_proc bedrock
[[ "$DEV" == "true" ]] && enable_proc cron || true
exec supervisord -c etc/supervisord.conf

Просмотреть файл

@ -0,0 +1,8 @@
[program:bedrock]
command = /app/docker/run-prod.sh
numprocs = 1
autostart = true
user = webdev
redirect_stderr = true
stdout_logfile = /dev/stdout
stdout_logfile_maxbytes = 0

Просмотреть файл

@ -0,0 +1,8 @@
[program:cron]
command = /app/bin/cron.py
numprocs = 1
autostart = true
user = webdev
redirect_stderr = true
stdout_logfile = /dev/stdout
stdout_logfile_maxbytes = 0

1
etc/supervisor_enabled/.gitignore поставляемый Normal file
Просмотреть файл

@ -0,0 +1 @@
*.conf

5
etc/supervisord.conf Normal file
Просмотреть файл

@ -0,0 +1,5 @@
[supervisord]
nodaemon = true
[include]
files = supervisor_enabled/*.conf

Просмотреть файл

@ -0,0 +1,5 @@
supervisor==3.2.3 \
--hash=sha256:3d6f0304c8ce74ab2100dfc4ab0f70050568504216f9508a81b8ed269aec9705
meld3==1.0.2 \
--hash=sha256:b28a9bfac342aadb4557aa144bea9f8e6208bfb0596190570d10a892d35ff7dc \
--hash=sha256:f7b754a0fde7a4429b2ebe49409db240b5699385a572501bb0d5627d299f9558