Skip to content

Commit

Permalink
Add supervisor to docker for dev/demo
Browse files Browse the repository at this point in the history
Allows us to run cron process and the server in
one container.
  • Loading branch information
pmac committed Mar 24, 2016
1 parent 47720aa commit 6ee7271
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 5 deletions.
15 changes: 10 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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 changes: 14 additions & 0 deletions docker/run-supervisor.sh
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions etc/supervisor_available/bedrock.conf
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions etc/supervisor_available/cron.conf
Original file line number Diff line number Diff line change
@@ -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 change: 1 addition & 0 deletions etc/supervisor_enabled/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.conf
5 changes: 5 additions & 0 deletions etc/supervisord.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[supervisord]
nodaemon = true

[include]
files = supervisor_enabled/*.conf
5 changes: 5 additions & 0 deletions requirements/docker-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
supervisor==3.2.3 \
--hash=sha256:3d6f0304c8ce74ab2100dfc4ab0f70050568504216f9508a81b8ed269aec9705
meld3==1.0.2 \
--hash=sha256:b28a9bfac342aadb4557aa144bea9f8e6208bfb0596190570d10a892d35ff7dc \
--hash=sha256:f7b754a0fde7a4429b2ebe49409db240b5699385a572501bb0d5627d299f9558

0 comments on commit 6ee7271

Please sign in to comment.