Skip to content
This repository was archived by the owner on Feb 21, 2019. It is now read-only.
Open
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
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*.dump
*.sql
*_cache
.git
data/*
site/*
static_root
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ GoogleV3_cache

# Private files
.env
env-*
example_project/local_settings.py


Expand Down
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM texastribune/gunicorn
MAINTAINER cchang@texastribune.org

RUN sed -i "s/wsgi:application/example_project.wsgi:application/" /etc/supervisor/conf.d/gunicorn.supervisor.conf

ADD . /app
ENV PYTHONPATH /app
RUN pip install --quiet -r requirements.txt
# needed to keep manage.py from trying to import too much
ENV DEBUG 0
RUN python example_project/manage.py collectstatic --noinput
21 changes: 21 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,24 @@ serve:


.PHONY: help test resetdb scrape pushdb site upload serve

# DOCKER #
build:
docker build -t texastribune/elevators .

shell:
docker run --rm --name elevators -i -t --link pgplus:postgis \
--volumes-from elevators-wsgi \
--env-file env-docker --entrypoint /bin/bash texastribune/elevators

gunicorn:
docker run --detach --name elevators-wsgi --link pgplus:postgis \
--env-file env-docker -p 8000:8000 texastribune/elevators

# download script doesn't need concurrency so only use -c 1
benchmark: gunicorn
sleep 5
docker run --rm --link elevators-wsgi:wsgi -t \
zz ab -n 10 http://wsgi:8000/
docker logs elevators-wsgi
docker rm -f elevators-wsgi
25 changes: 6 additions & 19 deletions bin/download_site.sh
Original file line number Diff line number Diff line change
@@ -1,28 +1,15 @@
#!/usr/bin/env bash

# Instructions:
#
# run from project root directory

set +e
MANAGE="python ./example_project/manage.py"
PORT=8008


DEBUG=0 $MANAGE runserver --nothreading --noreload $PORT &
pid=$!
echo "runserver pid: $pid"

# make sure to kill the server if terminated early
trap "kill $pid; echo bye $pid" EXIT
# Make sure the docker image is up to date
make build gunicorn
PORT=$(docker port elevators-site 8000 | cut -d : -f 2)

# give time for the servers to get up
sleep 1

$MANAGE collectstatic --noinput
sleep 3

mkdir -p site
cd site && wget -r localhost:$PORT --force-html -e robots=off -nH -nv --max-redirect 0

# kill server, run in a subprocess so we can suppress "Terminated" message
(kill $pid 2>&1) > /dev/null

echo "bye"
10 changes: 5 additions & 5 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Django==1.6.5
Django==1.6.6

dj-database-url>=0.2.1
project_runpy
psycopg2>=2.4.5
gunicorn==0.17.2
dj-database-url==0.3.0
project_runpy==0.3.1
psycopg2==2.5.4
gunicorn==19.1.1