Merge lp:~ricardokirkner/isitdeployable/docker into lp:isitdeployable

Proposed by Ricardo Kirkner
Status: Merged
Approved by: Ricardo Kirkner
Approved revision: 225
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: lp:~ricardokirkner/isitdeployable/docker
Merge into: lp:isitdeployable
Diff against target: 1016 lines (+609/-176)
19 files modified
.bzrignore (+1/-1)
.dockerignore (+2/-0)
Dockerfile (+26/-0)
Dockerfile.test (+4/-0)
Makefile (+24/-21)
Makefile.docker (+62/-0)
README.docker (+35/-0)
branches/wait-for-it/LICENSE (+20/-0)
branches/wait-for-it/README.md (+69/-0)
branches/wait-for-it/wait-for-it.sh (+161/-0)
django_project/settings_base.py (+98/-149)
django_project/settings_build.py (+12/-0)
django_project/settings_devel.py (+17/-5)
docker-compose.dev.yml (+24/-0)
docker-compose.secrets.yml (+5/-0)
docker-compose.test.yml (+9/-0)
docker-compose.yml (+19/-0)
requirements-docker.txt (+19/-0)
requirements.txt (+2/-0)
To merge this branch: bzr merge lp:~ricardokirkner/isitdeployable/docker
Reviewer Review Type Date Requested Status
Guillermo Gonzalez Approve
Review via email: mp+327809@code.launchpad.net

Commit message

added tooling to build and run application using docker

To post a comment you must log in.
Revision history for this message
Guillermo Gonzalez (verterok) wrote :

besides the weird missing modules errors, it worked!

review: Approve
Revision history for this message
Otto Co-Pilot (otto-copilot) wrote :
Revision history for this message
Otto Co-Pilot (otto-copilot) wrote :
Revision history for this message
Otto Co-Pilot (otto-copilot) wrote :
Revision history for this message
Otto Co-Pilot (otto-copilot) wrote :
Revision history for this message
Otto Co-Pilot (otto-copilot) wrote :
Revision history for this message
Otto Co-Pilot (otto-copilot) wrote :
Revision history for this message
Otto Co-Pilot (otto-copilot) wrote :
225. By Ricardo Kirkner

do not override default $(ENV) target in docker Makefile

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '.bzrignore'
--- .bzrignore 2016-07-14 21:54:18 +0000
+++ .bzrignore 2017-08-01 11:41:20 +0000
@@ -15,7 +15,7 @@
15./tmp/supervisor-childlogs/*15./tmp/supervisor-childlogs/*
16./.sass-cache16./.sass-cache
17./revtracker/static/css/*17./revtracker/static/css/*
18./virtualenv18./env
19./lib/versioninfo.py19./lib/versioninfo.py
20./static20./static
21./logs/*21./logs/*
2222
=== added file '.dockerignore'
--- .dockerignore 1970-01-01 00:00:00 +0000
+++ .dockerignore 2017-08-01 11:41:20 +0000
@@ -0,0 +1,2 @@
1.bzr
2env
03
=== added file 'Dockerfile'
--- Dockerfile 1970-01-01 00:00:00 +0000
+++ Dockerfile 2017-08-01 11:41:20 +0000
@@ -0,0 +1,26 @@
1FROM ubuntu:trusty
2
3RUN mkdir -p /usr/src/app
4WORKDIR /usr/src/app
5
6# install system dependencies (debs)
7COPY dependencies.txt dependencies-devel.txt /usr/src/app/
8RUN apt-get update && apt-get upgrade -y \
9 && apt-get install -y software-properties-common \
10 && apt-add-repository --yes ppa:mojo-maintainers \
11 && apt-add-repository --yes ppa:ubuntuone/isitdeployable-dependencies \
12 && apt-get update \
13 && cat dependencies.txt dependencies-devel.txt | xargs apt-get install -y --no-install-recommends \
14 && apt-get install -y python-pip \
15 && rm -rf /var/lib/apt/lists/*
16
17# install python dependencies (wheels)
18COPY branches/wheels branches/wheels
19COPY requirements.txt /usr/src/app
20RUN pip install --find-links=branches/wheels --no-index -r requirements.txt
21
22# add app source code
23COPY . /usr/src/app
24
25# start container
26CMD ["make", "app-start"]
027
=== added file 'Dockerfile.test'
--- Dockerfile.test 1970-01-01 00:00:00 +0000
+++ Dockerfile.test 2017-08-01 11:41:20 +0000
@@ -0,0 +1,4 @@
1FROM deployable:dev
2
3COPY requirements-devel.txt /usr/src/app
4RUN pip install --find-links=branches/wheels --no-index -r requirements-devel.txt
05
=== modified file 'Makefile'
--- Makefile 2016-07-27 14:51:28 +0000
+++ Makefile 2017-08-01 11:41:20 +0000
@@ -17,28 +17,20 @@
17LOCAL_SETTINGS_DIR ?= ../local_config17LOCAL_SETTINGS_DIR ?= ../local_config
18LOCAL_SETTINGS_PATH = $(LOCAL_SETTINGS_DIR)/settings.py18LOCAL_SETTINGS_PATH = $(LOCAL_SETTINGS_DIR)/settings.py
1919
20HERE := $(shell pwd)20ENV = $(CURDIR)/env
21VIRTUALENV_DIR ?= ${HERE}/virtualenv
22VIRTUALENV_BIN := ${VIRTUALENV_DIR}/bin
23PYTHONPATH := ${HERE}/revtracker:${HERE}/lib:${HERE}:${PYTHONPATH}21PYTHONPATH := ${HERE}/revtracker:${HERE}/lib:${HERE}:${PYTHONPATH}
2422
25CM ?= /usr/lib/config-manager/cm.py23CM ?= /usr/lib/config-manager/cm.py
26CONFIGMANAGER = config-manager.txt24CONFIGMANAGER = config-manager.txt
27PYTHON = $(VIRTUALENV_DIR)/bin/python25GUNICORN ?= $(ENV)/bin/gunicorn
28# use env's python to run pip in order to overcome shebang's max line length limitation26PYTHON ?= $(ENV)/bin/python
29PIP = $(PYTHON) $(VIRTUALENV_DIR)/bin/pip27PIP ?= $(ENV)/bin/pip
3028
31# Several targets assume (wrongly) that $(ENV) already exists. As a stop-gap29# Several targets assume (wrongly) that $(ENV) already exists. As a stop-gap
32# we ifdef them with ENV_CREATED to avoid spurious30# we ifdef them with ENV_CREATED to avoid spurious
33# '/bin/sh: 1: /.../env/bin/python: not found' errors31# '/bin/sh: 1: /.../env/bin/python: not found' errors
34ENV_CREATED = $(shell test -e $(PYTHON) && echo "yes" || echo "no")32ENV_CREATED = $(shell test -e $(PYTHON) && echo "yes" || echo "no")
3533
36include makefiles/css.mk
37include makefiles/gem.mk
38include makefiles/js.mk
39ifeq (yes,$(ENV_CREATED))
40include Makefile.db
41endif
42WHEELS_BRANCH_URL ?= lp:isitdeployable-dependencies34WHEELS_BRANCH_URL ?= lp:isitdeployable-dependencies
43WHEELS_DIR = branches/wheels35WHEELS_DIR = branches/wheels
4436
@@ -78,13 +70,13 @@
78 cp django_project/settings.py.example $(LOCAL_SETTINGS_PATH)70 cp django_project/settings.py.example $(LOCAL_SETTINGS_PATH)
7971
8072
81$(VIRTUALENV_DIR):73$(ENV):
82 echo 'creating new virtualenv...'74 echo 'creating new virtualenv...'
83 virtualenv --clear --system-site-packages $(VIRTUALENV_DIR)75 virtualenv --clear --system-site-packages $(ENV)
8476
85clean-virtualenv:77clean-virtualenv:
86 echo 'cleaning virtualenv...'78 echo 'cleaning virtualenv...'
87 rm -rf $(VIRTUALENV_DIR)79 rm -rf $(ENV)
8880
89version:81version:
90 bzr version-info --format=python > lib/versioninfo.py82 bzr version-info --format=python > lib/versioninfo.py
@@ -101,7 +93,7 @@
10193
102sourcedeps: fetch-sourcedeps install-wheels94sourcedeps: fetch-sourcedeps install-wheels
10395
104bootstrap: $(LOCAL_SETTINGS_PATH) $(VIRTUALENV_DIR) sourcedeps install-wheels-dev96bootstrap: $(LOCAL_SETTINGS_PATH) $(ENV) sourcedeps install-wheels-dev
10597
10698
107# Management99# Management
@@ -115,7 +107,7 @@
115run: ARGS=0.0.0.0:8000107run: ARGS=0.0.0.0:8000
116run: collectstatic108run: collectstatic
117 $(MAKE) manage ARGS="loaddata fixtures/group.json"109 $(MAKE) manage ARGS="loaddata fixtures/group.json"
118 $(VIRTUALENV_DIR)/bin/gunicorn django_project.wsgi:application --workers=2 --reload --pid=logs/gunicorn.pid --bind=$(ARGS) --timeout=99999110 $(GUNICORN) django_project.wsgi:application --workers=2 --reload --pid=logs/gunicorn.pid --bind=$(ARGS) --timeout=99999
119111
120start-supervisor: logs112start-supervisor: logs
121 @echo Starting supervised processes113 @echo Starting supervised processes
@@ -141,14 +133,14 @@
141 [ -d $(WHEELS_DIR) ] && (cd $(WHEELS_DIR) && bzr pull) || (bzr branch $(WHEELS_BRANCH_URL) $(WHEELS_DIR))133 [ -d $(WHEELS_DIR) ] && (cd $(WHEELS_DIR) && bzr pull) || (bzr branch $(WHEELS_BRANCH_URL) $(WHEELS_DIR))
142134
143update-wheels: ARGS=-r requirements-devel.txt135update-wheels: ARGS=-r requirements-devel.txt
144update-wheels: $(VIRTUALENV_DIR)136update-wheels: $(ENV)
145 $(PIP) wheel -w $(WHEELS_DIR) -f $(WHEELS_DIR) $(ARGS)137 $(PIP) wheel -w $(WHEELS_DIR) -f $(WHEELS_DIR) $(ARGS)
146138
147install-wheels: ARGS=-r requirements.txt139install-wheels: ARGS=-r requirements.txt
148install-wheels: $(VIRTUALENV_DIR)140install-wheels: $(ENV)
149 $(PIP) install --find-links=$(WHEELS_DIR) --no-index $(ARGS)141 $(PIP) install --find-links=$(WHEELS_DIR) --no-index $(ARGS)
150142
151install-wheels-dev: $(VIRTUALENV_DIR) install-wheels143install-wheels-dev: $(ENV) install-wheels
152 $(MAKE) install-wheels ARGS="-r requirements-devel.txt --pre"144 $(MAKE) install-wheels ARGS="-r requirements-devel.txt --pre"
153145
154146
@@ -162,7 +154,7 @@
162REV_DIR=$(STATIC_ROOT)/combo/rev-r$$(cat $(STATIC_ROOT)/combo/revno)154REV_DIR=$(STATIC_ROOT)/combo/rev-r$$(cat $(STATIC_ROOT)/combo/revno)
163155
164collectstatic: js css156collectstatic: js css
165 DJANGO_SETTINGS_MODULE=django_project.settings_base $(DJANGO_MANAGE) collectstatic --noinput \157 DJANGO_SETTINGS_MODULE=django_project.settings_build $(DJANGO_MANAGE) collectstatic --noinput \
166 > logs/collectstatic.log 2>&1 || (cat logs/collectstatic.log && false)158 > logs/collectstatic.log 2>&1 || (cat logs/collectstatic.log && false)
167 cd $(STATIC_ROOT)/combo159 cd $(STATIC_ROOT)/combo
168 [ -L $(REV_DIR) ] && (echo 'existing rev symbolink, removing' && rm $(REV_DIR)) \160 [ -L $(REV_DIR) ] && (echo 'existing rev symbolink, removing' && rm $(REV_DIR)) \
@@ -187,4 +179,15 @@
187 conn-check $(CONN_CHECK_CONFIG_PATH)179 conn-check $(CONN_CHECK_CONFIG_PATH)
188180
189181
182# static assets related targets
183include makefiles/css.mk
184include makefiles/gem.mk
185include makefiles/js.mk
186# database related targets
187ifeq (yes,$(ENV_CREATED))
188include Makefile.db
189endif
190# deployment related targets
191include Makefile.docker
192
190.PHONY: build-tarball install-wheels193.PHONY: build-tarball install-wheels
191194
=== added file 'Makefile.docker'
--- Makefile.docker 1970-01-01 00:00:00 +0000
+++ Makefile.docker 2017-08-01 11:41:20 +0000
@@ -0,0 +1,62 @@
1
2PROJECT_NAME = django_project
3
4# define docker related variables
5DOCKER_COMPOSE_FILES ?= -f docker-compose.yml -f docker-compose.dev.yml
6DOCKER_COMPOSE ?= $(ENV)/bin/docker-compose
7TAG ?= deployable:dev
8
9# pre-process arguments
10# if the first argument is "special" (docker-compose, docker-test)...
11ifneq (,$(filter $(firstword $(MAKECMDGOALS)),docker-compose docker-test))
12# use the rest as sub-arguments
13ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
14# ...and turn them into do-nothing targets
15$(eval $(ARGS):;@:)
16endif
17
18
19docker-bootstrap: $(ENV) fetch-sourcedeps
20 $(ENV)/bin/pip install --find-links=$(WHEELS_DIR) --no-index -r requirements-docker.txt
21
22docker-build: version ## Build images
23 $(MAKE) docker-compose ARGS="build"
24
25docker-run: ## Run stack in foreground
26 DOCKER_COMPOSE_FILES="$(DOCKER_COMPOSE_FILES) -f docker-compose.secrets.yml" $(MAKE) docker-compose ARGS="up"
27
28docker-start: ## Run stack in background
29 DOCKER_COMPOSE_FILES="$(DOCKER_COMPOSE_FILES) -f docker-compose.secrets.yml" $(MAKE) docker-compose ARGS="up -d"
30
31docker-stop: ## Stop containers
32 DOCKER_COMPOSE_FILES="$(DOCKER_COMPOSE_FILES) -f docker-compose.secrets.yml" $(MAKE) docker-compose ARGS="down"
33
34docker-clean: docker-stop ## Remove images
35 docker rmi $(TAG)
36
37docker-compose: $(ENV)
38 $(DOCKER_COMPOSE) $(DOCKER_COMPOSE_FILES) $(ARGS)
39
40docker-test: ## Run tests using containers
41 DOCKER_COMPOSE_FILES='-f docker-compose.yml -f docker-compose.test.yml' $(MAKE) docker-compose ARGS="up --build -d"
42 DOCKER_COMPOSE_FILES='-f docker-compose.yml -f docker-compose.test.yml' $(MAKE) docker-compose ARGS="run app make test $(ARGS)"
43 DOCKER_COMPOSE_FILES='-f docker-compose.yml -f docker-compose.test.yml' $(MAKE) docker-compose ARGS="down"
44 docker rmi deployable:test
45
46### targets for in-container use
47
48app-update-db:
49 $(MAKE) manage ARGS='syncdb --noinput' PYTHON=python
50 $(MAKE) manage ARGS='migrate --noinput' PYTHON=python
51
52app-start: BIND=0.0.0.0:8000
53app-start: WORKERS=3
54app-start: app-update-db collectstatic
55 $(MAKE) manage ARGS="loaddata fixtures/group.json"
56 gunicorn --workers=$(WORKERS) --bind=$(BIND) $(PROJECT_NAME).wsgi:application
57
58worker-worker:
59 python $(PROJECT_NAME)/celeryapp.py worker
60
61worker-beat:
62 python $(PROJECT_NAME)/celeryapp.py beat
063
=== added file 'README.docker'
--- README.docker 1970-01-01 00:00:00 +0000
+++ README.docker 2017-08-01 11:41:20 +0000
@@ -0,0 +1,35 @@
1------
2Docker
3------
4
5It's as simple as:
6
7 $ sudo apt install docker.io config-manager
8 $ make docker-bootstrap
9 $ make docker-build
10 $ make docker-run
11
12.. important:
13
14 Notice that docker.io can't be run inside a container easily, thus the suggested way to run it is to
15 install it on your host and run it from there directly (or run everything inside a virtual machine like VirtualBox or KVM).
16
17.. important:
18
19 Before running any docker commands you'll need to add yourself to the `docker` group. Otherwise all docker commands will
20 have to be run as root.
21
22 sudo groupadd -a -G docker $USER
23 sg docker bash
24
25.. note:
26
27 You only need to run the `sg` command in the current terminal. The next time you login with your user, you should
28 already be a part of the docker group.
29
30You can now interact with the service by opening http://localhost:8000 in your browser of choice.
31
32To run the tests simply do:
33
34 $ make docker-test
35
036
=== added directory 'branches/wait-for-it'
=== added file 'branches/wait-for-it/LICENSE'
--- branches/wait-for-it/LICENSE 1970-01-01 00:00:00 +0000
+++ branches/wait-for-it/LICENSE 2017-08-01 11:41:20 +0000
@@ -0,0 +1,20 @@
1The MIT License (MIT)
2Copyright (c) 2016 Giles Hall
3
4Permission is hereby granted, free of charge, to any person obtaining a copy of
5this software and associated documentation files (the "Software"), to deal in
6the Software without restriction, including without limitation the rights to
7use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
8of the Software, and to permit persons to whom the Software is furnished to do
9so, subject to the following conditions:
10
11The above copyright notice and this permission notice shall be included in all
12copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20SOFTWARE.
021
=== added file 'branches/wait-for-it/README.md'
--- branches/wait-for-it/README.md 1970-01-01 00:00:00 +0000
+++ branches/wait-for-it/README.md 2017-08-01 11:41:20 +0000
@@ -0,0 +1,69 @@
1# HELP NEEDED
2
3Hi there! I wrote `wait-for-it` in order to help me orchestrate containers I operate at my day job. I thought it was a neat little script, so I published it. I assumed I would be its only user, but that's not what happened! `wait-for-it` has received more stars then all of my other public repositories put together. I had no idea this tool would solicit such an audience, and I was equally unprepared to carve out the time required to address my user's issues and patches. I would like to solicit a volunteer from the community who would be willing to be a co-maintainer of this repository. If this is something you might be interested in, please email me at `waitforit@polymerase.org`. Thanks!
4
5## wait-for-it
6
7`wait-for-it.sh` is a pure bash script that will wait on the availability of a host and TCP port. It is useful for synchronizing the spin-up of interdependent services, such as linked docker containers. Since it is a pure bash script, it does not have any external dependencies.
8
9## Usage
10
11```
12wait-for-it.sh host:port [-s] [-t timeout] [-- command args]
13-h HOST | --host=HOST Host or IP under test
14-p PORT | --port=PORT TCP port under test
15 Alternatively, you specify the host and port as host:port
16-s | --strict Only execute subcommand if the test succeeds
17-q | --quiet Don't output any status messages
18-t TIMEOUT | --timeout=TIMEOUT
19 Timeout in seconds, zero for no timeout
20-- COMMAND ARGS Execute command with args after the test finishes
21```
22
23## Examples
24
25For example, let's test to see if we can access port 80 on www.google.com, and if it is available, echo the message `google is up`.
26
27```
28$ ./wait-for-it.sh www.google.com:80 -- echo "google is up"
29wait-for-it.sh: waiting 15 seconds for www.google.com:80
30wait-for-it.sh: www.google.com:80 is available after 0 seconds
31google is up
32```
33
34You can set your own timeout with the `-t` or `--timeout=` option. Setting the timeout value to 0 will disable the timeout:
35
36```
37$ ./wait-for-it.sh -t 0 www.google.com:80 -- echo "google is up"
38wait-for-it.sh: waiting for www.google.com:80 without a timeout
39wait-for-it.sh: www.google.com:80 is available after 0 seconds
40google is up
41```
42
43The subcommand will be executed regardless if the service is up or not. If you wish to execute the subcommand only if the service is up, add the `--strict` argument. In this example, we will test port 81 on www.google.com which will fail:
44
45```
46$ ./wait-for-it.sh www.google.com:81 --timeout=1 --strict -- echo "google is up"
47wait-for-it.sh: waiting 1 seconds for www.google.com:81
48wait-for-it.sh: timeout occurred after waiting 1 seconds for www.google.com:81
49wait-for-it.sh: strict mode, refusing to execute subprocess
50```
51
52If you don't want to execute a subcommand, leave off the `--` argument. This way, you can test the exit condition of `wait-for-it.sh` in your own scripts, and determine how to proceed:
53
54```
55$ ./wait-for-it.sh www.google.com:80
56wait-for-it.sh: waiting 15 seconds for www.google.com:80
57wait-for-it.sh: www.google.com:80 is available after 0 seconds
58$ echo $?
590
60$ ./wait-for-it.sh www.google.com:81
61wait-for-it.sh: waiting 15 seconds for www.google.com:81
62wait-for-it.sh: timeout occurred after waiting 15 seconds for www.google.com:81
63$ echo $?
64124
65```
66
67## Thanks
68
69I wrote this script for my employer, [Ginkgo Bioworks](http://www.ginkgobioworks.com/), who was kind enough to let me release it as an open source tool. We are always looking to [hire](https://jobs.lever.co/ginkgobioworks) talented folks who are interested in working in the field of synthetic biology.
070
=== added file 'branches/wait-for-it/wait-for-it.sh'
--- branches/wait-for-it/wait-for-it.sh 1970-01-01 00:00:00 +0000
+++ branches/wait-for-it/wait-for-it.sh 2017-08-01 11:41:20 +0000
@@ -0,0 +1,161 @@
1#!/usr/bin/env bash
2# Use this script to test if a given TCP host/port are available
3
4cmdname=$(basename $0)
5
6echoerr() { if [[ $QUIET -ne 1 ]]; then echo "$@" 1>&2; fi }
7
8usage()
9{
10 cat << USAGE >&2
11Usage:
12 $cmdname host:port [-s] [-t timeout] [-- command args]
13 -h HOST | --host=HOST Host or IP under test
14 -p PORT | --port=PORT TCP port under test
15 Alternatively, you specify the host and port as host:port
16 -s | --strict Only execute subcommand if the test succeeds
17 -q | --quiet Don't output any status messages
18 -t TIMEOUT | --timeout=TIMEOUT
19 Timeout in seconds, zero for no timeout
20 -- COMMAND ARGS Execute command with args after the test finishes
21USAGE
22 exit 1
23}
24
25wait_for()
26{
27 if [[ $TIMEOUT -gt 0 ]]; then
28 echoerr "$cmdname: waiting $TIMEOUT seconds for $HOST:$PORT"
29 else
30 echoerr "$cmdname: waiting for $HOST:$PORT without a timeout"
31 fi
32 start_ts=$(date +%s)
33 while :
34 do
35 (echo > /dev/tcp/$HOST/$PORT) >/dev/null 2>&1
36 result=$?
37 if [[ $result -eq 0 ]]; then
38 end_ts=$(date +%s)
39 echoerr "$cmdname: $HOST:$PORT is available after $((end_ts - start_ts)) seconds"
40 break
41 fi
42 sleep 1
43 done
44 return $result
45}
46
47wait_for_wrapper()
48{
49 # In order to support SIGINT during timeout: http://unix.stackexchange.com/a/57692
50 if [[ $QUIET -eq 1 ]]; then
51 timeout $TIMEOUT $0 --quiet --child --host=$HOST --port=$PORT --timeout=$TIMEOUT &
52 else
53 timeout $TIMEOUT $0 --child --host=$HOST --port=$PORT --timeout=$TIMEOUT &
54 fi
55 PID=$!
56 trap "kill -INT -$PID" INT
57 wait $PID
58 RESULT=$?
59 if [[ $RESULT -ne 0 ]]; then
60 echoerr "$cmdname: timeout occurred after waiting $TIMEOUT seconds for $HOST:$PORT"
61 fi
62 return $RESULT
63}
64
65# process arguments
66while [[ $# -gt 0 ]]
67do
68 case "$1" in
69 *:* )
70 hostport=(${1//:/ })
71 HOST=${hostport[0]}
72 PORT=${hostport[1]}
73 shift 1
74 ;;
75 --child)
76 CHILD=1
77 shift 1
78 ;;
79 -q | --quiet)
80 QUIET=1
81 shift 1
82 ;;
83 -s | --strict)
84 STRICT=1
85 shift 1
86 ;;
87 -h)
88 HOST="$2"
89 if [[ $HOST == "" ]]; then break; fi
90 shift 2
91 ;;
92 --host=*)
93 HOST="${1#*=}"
94 shift 1
95 ;;
96 -p)
97 PORT="$2"
98 if [[ $PORT == "" ]]; then break; fi
99 shift 2
100 ;;
101 --port=*)
102 PORT="${1#*=}"
103 shift 1
104 ;;
105 -t)
106 TIMEOUT="$2"
107 if [[ $TIMEOUT == "" ]]; then break; fi
108 shift 2
109 ;;
110 --timeout=*)
111 TIMEOUT="${1#*=}"
112 shift 1
113 ;;
114 --)
115 shift
116 CLI="$@"
117 break
118 ;;
119 --help)
120 usage
121 ;;
122 *)
123 echoerr "Unknown argument: $1"
124 usage
125 ;;
126 esac
127done
128
129if [[ "$HOST" == "" || "$PORT" == "" ]]; then
130 echoerr "Error: you need to provide a host and port to test."
131 usage
132fi
133
134TIMEOUT=${TIMEOUT:-15}
135STRICT=${STRICT:-0}
136CHILD=${CHILD:-0}
137QUIET=${QUIET:-0}
138
139if [[ $CHILD -gt 0 ]]; then
140 wait_for
141 RESULT=$?
142 exit $RESULT
143else
144 if [[ $TIMEOUT -gt 0 ]]; then
145 wait_for_wrapper
146 RESULT=$?
147 else
148 wait_for
149 RESULT=$?
150 fi
151fi
152
153if [[ $CLI != "" ]]; then
154 if [[ $RESULT -ne 0 && $STRICT -eq 1 ]]; then
155 echoerr "$cmdname: strict mode, refusing to execute subprocess"
156 exit $RESULT
157 fi
158 exec $CLI
159else
160 exit $RESULT
161fi
0162
=== modified file 'django_project/settings_base.py'
--- django_project/settings_base.py 2016-11-03 21:48:25 +0000
+++ django_project/settings_base.py 2017-08-01 11:41:20 +0000
@@ -2,120 +2,47 @@
22
3import os3import os
4import pwd4import pwd
5import sys5from datetime import timedelta
6
7import dj_database_url
8import djcelery
9from getenv import env
610
7# Needed to have celery work from management commands11# Needed to have celery work from management commands
8import djcelery
9djcelery.setup_loader()12djcelery.setup_loader()
1013
11from datetime import timedelta14
1215# base directories
13DEBUG = True16
14TEMPLATE_DEBUG = DEBUG17BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
1518_LOGS_DIR = os.path.abspath(
1619 os.path.join(BASE_DIR, os.pardir, os.pardir, 'logs'))
17BASE_DIR = os.path.dirname(os.path.dirname(__file__))20LOGS_DIR = os.path.abspath(os.getenv('DPA_LOGS_DIR', _LOGS_DIR))
18SRC_DIR = os.path.join(BASE_DIR, 'revtracker')
19HOST_DIR = os.path.abspath(21HOST_DIR = os.path.abspath(
20 os.getenv('DPA_LP_CACHE_HOST_DIR', os.path.abspath(22 os.getenv('DPA_LP_CACHE_HOST_DIR', os.path.abspath(
21 os.path.join(BASE_DIR, os.path.pardir, os.path.pardir))))23 os.path.join(BASE_DIR, os.path.pardir, os.path.pardir))))
22LOGS_DIR = os.path.abspath(
23 os.getenv('DPA_LOGS_DIR', os.path.join(BASE_DIR, 'logs')))
24OOPS_DIR = os.path.join(LOGS_DIR, 'www-oops')24OOPS_DIR = os.path.join(LOGS_DIR, 'www-oops')
2525SRC_DIR = os.path.join(BASE_DIR, 'revtracker')
2626
27ADMINS = (27# django settings
28 # ('Your Name', 'your_email@example.com'),28
29ADMIN_MEDIA_PREFIX = '/static/admin/'
30ALLOWED_HOSTS = env('ALLOWED_HOSTS', '[]')
31AUTHENTICATION_BACKENDS = (
32 'django_openid_auth.auth.OpenIDBackend',
33 'django.contrib.auth.backends.ModelBackend',
29)34)
3035CSRF_COOKIE_DOMAIN = None
31MANAGERS = ADMINS36CSRF_COOKIE_HTTPONLY = False
3237CSRF_COOKIE_NAME = 'csrftoken'
38CSRF_COOKIE_PATH = '/'
39CSRF_COOKIE_SECURE = False
40CSRF_FAILURE_VIEW = 'django.views.csrf.csrf_failure'
33DATABASES = {41DATABASES = {
34 'default': {42 'default': dj_database_url.config(
35 'ENGINE': 'django.db.backends.postgresql_psycopg2',43 default='postgres://postgres@localhost/revtracker')
36 'ATOMIC_REQUESTS': False,
37 'AUTOCOMMIT': True,
38 'CONN_MAX_AGE': 600,
39 'HOST': 'localhost',
40 'NAME': 'revtracker',
41 'OPTIONS': {},
42 'PORT': '',
43 'TEST': {
44 'NAME': None,
45 'MIRROR': None,
46 'CHARSET': None,
47 'COLLATION': None,
48 },
49 'TIME_ZONE': 'UTC',
50 'USER': 'postgres',
51 },
52}44}
5345DEBUG = env('DEBUG', '').lower() == 'true'
54TIME_ZONE = 'UTC'
55
56LANGUAGE_CODE = 'en-us'
57
58SITE_ID = 1
59
60USE_I18N = True
61
62USE_L10N = True
63
64MEDIA_ROOT = ''
65
66MEDIA_URL = ''
67
68STATIC_ROOT = 'static'
69
70STATIC_URL = '/static/'
71
72ADMIN_MEDIA_PREFIX = '/static/admin/'
73
74STATICFILES_DIRS = (
75 os.path.join(BASE_DIR, 'build/revtracker/js'),
76)
77
78STATICFILES_FINDERS = (
79 'django.contrib.staticfiles.finders.FileSystemFinder',
80 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
81# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
82)
83
84SECRET_KEY = '6s!*-&#t8mks^8+7_2w%!oh8wh9uzzm-vzh5)l+7r2403+tm^!'
85
86TEMPLATE_LOADERS = (
87 'django.template.loaders.filesystem.Loader',
88 'django.template.loaders.app_directories.Loader',
89 'django.template.loaders.eggs.Loader',
90)
91
92MIDDLEWARE_CLASSES = (
93 'django.middleware.common.CommonMiddleware',
94 'django.contrib.sessions.middleware.SessionMiddleware',
95 'django.middleware.csrf.CsrfViewMiddleware',
96 'django.contrib.auth.middleware.AuthenticationMiddleware',
97 'django.contrib.messages.middleware.MessageMiddleware',
98 'waffle.middleware.WaffleMiddleware',
99 #'debug_toolbar.middleware.DebugToolbarMiddleware',
100)
101
102INTERNAL_IPS = ('127.0.0.1',)
103
104ROOT_URLCONF = 'django_project.urls'
105
106TEMPLATE_DIRS = (
107 # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
108 # Always use forward slashes, even on Windows.
109 # Don't forget to use absolute paths, not relative paths.
110)
111
112TEMPLATE_CONTEXT_PROCESSORS = (
113 "django.contrib.auth.context_processors.auth",
114 "django.core.context_processors.csrf",
115 "django.core.context_processors.static",
116 "django.core.context_processors.request",
117)
118
119INSTALLED_APPS = (46INSTALLED_APPS = (
120 'django.contrib.auth',47 'django.contrib.auth',
121 'django.contrib.contenttypes',48 'django.contrib.contenttypes',
@@ -135,7 +62,8 @@
135 'pgtools',62 'pgtools',
136 #'debug_toolbar',63 #'debug_toolbar',
137)64)
13865INTERNAL_IPS = ('127.0.0.1',)
66LANGUAGE_CODE = 'en-us'
139LOGGING = {67LOGGING = {
140 'version': 1,68 'version': 1,
141 'disable_existing_loggers': False,69 'disable_existing_loggers': False,
@@ -174,13 +102,57 @@
174 },102 },
175 }103 }
176}104}
105LOGIN_URL = '/openid/login'
106LOGIN_REDIRECT_URL = '/'
107MIDDLEWARE_CLASSES = (
108 'django.middleware.common.CommonMiddleware',
109 'django.contrib.sessions.middleware.SessionMiddleware',
110 'django.middleware.csrf.CsrfViewMiddleware',
111 'django.contrib.auth.middleware.AuthenticationMiddleware',
112 'django.contrib.messages.middleware.MessageMiddleware',
113 'waffle.middleware.WaffleMiddleware',
114 #'debug_toolbar.middleware.DebugToolbarMiddleware',
115)
116ROOT_URLCONF = 'django_project.urls'
117SECRET_KEY = env('SECRET_KEY', '')
118SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'
119STATIC_ROOT = 'static'
120STATIC_URL = '/static/'
121STATICFILES_DIRS = (
122 os.path.join(BASE_DIR, 'build/revtracker/js'),
123)
124STATICFILES_FINDERS = (
125 'django.contrib.staticfiles.finders.FileSystemFinder',
126 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
127)
128TEMPLATE_CONTEXT_PROCESSORS = (
129 "django.contrib.auth.context_processors.auth",
130 "django.core.context_processors.csrf",
131 "django.core.context_processors.static",
132 "django.core.context_processors.request",
133)
134TEMPLATE_LOADERS = (
135 'django.template.loaders.filesystem.Loader',
136 'django.template.loaders.app_directories.Loader',
137 'django.template.loaders.eggs.Loader',
138)
139TEST_RUNNER = 'django.test.runner.DiscoverRunner'
140TIME_ZONE = 'UTC'
141USE_I18N = True
142USE_L10N = True
143
144# debug-toolbar settings
177145
178DEBUG_TOOLBAR_CONFIG = {146DEBUG_TOOLBAR_CONFIG = {
179 'INTERCEPT_REDIRECTS': False,147 'INTERCEPT_REDIRECTS': False,
180}148}
181149
182BRANCH_CACHE_DIR = "branches"150# celery settings
183151
152CELERY_BROKER_URL = os.getenv('CELERY_BROKER_URL', 'amqp://')
153CELERY_ACCEPT_CONTENT = ['json']
154CELERY_TASK_SERIALIZER = 'json'
155CELERY_RESULT_SERIALIZER = 'json'
184CELERYBEAT_SCHEDULE = {156CELERYBEAT_SCHEDULE = {
185 "update_all_projects": {157 "update_all_projects": {
186 "task": "revtracker.tasks.update_all_projects",158 "task": "revtracker.tasks.update_all_projects",
@@ -192,14 +164,25 @@
192CELERYD_PREFETCH_MULTIPLIER = 1164CELERYD_PREFETCH_MULTIPLIER = 1
193CELERYBEAT_SCHEDULE_FILENAME = 'tmp/celerybeat-schedule'165CELERYBEAT_SCHEDULE_FILENAME = 'tmp/celerybeat-schedule'
194166
195LOGIN_URL = '/openid/login'167# django-openid-auth settings
196LOGIN_REDIRECT_URL = '/'168
197169OPENID_CREATE_USERS = True
198AUTHENTICATION_BACKENDS = (170OPENID_LAUNCHPAD_TEAMS_MAPPING_AUTO = True
199 'django_openid_auth.auth.OpenIDBackend',171OPENID_UPDATE_DETAILS_FROM_SREG = True
200 'django.contrib.auth.backends.ModelBackend',172OPENID_SREG_REQUIRED_FIELDS = ['nickname']
201 )173OPENID_SSO_SERVER_URL = 'https://login.ubuntu.com/'
202174
175# revtracker settings
176
177BRANCH_CACHE_DIR = "branches"
178COMBO_URL = env('COMBO_URL', 'http://127.0.0.1:8001/')
179CONVOY_ROOT = os.path.join(STATIC_ROOT, 'combo')
180GIT_SSH_DEFAULT_USERNAME = pwd.getpwuid(os.getuid()).pw_name
181GIT_SSH_DEFAULT_PORT = None
182GIT_SSH_PRIVATE_KEY = os.path.expanduser('~/.ssh/id_rsa')
183GIT_SSH_PUBLIC_KEY = os.path.expanduser('~/.ssh/id_rsa.pub')
184LP_INSTANCE = 'production'
185MULTILANG_OP_ENDPOINTS = False
203OOPSES = {186OOPSES = {
204 'publishers': [{187 'publishers': [{
205 'inherit_id': False,188 'inherit_id': False,
@@ -209,40 +192,6 @@
209 }],192 }],
210 'template': {'reporter': 'DEFAULT'},193 'template': {'reporter': 'DEFAULT'},
211}194}
212195SOFT_TIMEOUT_MILLISECONDS = 10000
213USE_HTTPS = True196USE_HTTPS = env('USE_HTTPS', 'true').lower() == 'true'
214
215OPENID_SSO_SERVER_URL = 'https://login.ubuntu.com/'
216OPENID_CREATE_USERS = True
217OPENID_UPDATE_DETAILS_FROM_SREG = True
218OPENID_SREG_REQUIRED_FIELDS = ['nickname']
219OPENID_LAUNCHPAD_TEAMS_MAPPING_AUTO = True
220
221MULTILANG_OP_ENDPOINTS = False
222
223COMBO_URL = 'http://127.0.0.1:8001/'
224
225CONVOY_ROOT = os.path.join(STATIC_ROOT, 'combo')
226
227WAFFLE_OVERRIDE = True197WAFFLE_OVERRIDE = True
228SOFT_TIMEOUT_MILLISECONDS = 10000
229
230CSRF_COOKIE_DOMAIN = None
231CSRF_COOKIE_HTTPONLY = False
232CSRF_COOKIE_NAME = 'csrftoken'
233CSRF_COOKIE_PATH = '/'
234CSRF_COOKIE_SECURE = False
235CSRF_FAILURE_VIEW = 'django.views.csrf.csrf_failure'
236
237TEST_RUNNER = 'django.test.runner.DiscoverRunner'
238SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'
239
240LP_INSTANCE = 'production'
241
242GIT_SSH_DEFAULT_USERNAME = pwd.getpwuid(os.getuid()).pw_name
243GIT_SSH_DEFAULT_PORT = None
244GIT_SSH_PRIVATE_KEY = os.path.expanduser('~/.ssh/id_rsa')
245GIT_SSH_PUBLIC_KEY = os.path.expanduser('~/.ssh/id_rsa.pub')
246
247
248sys.path.insert(0, os.path.dirname(__file__))
249198
=== added file 'django_project/settings_build.py'
--- django_project/settings_build.py 1970-01-01 00:00:00 +0000
+++ django_project/settings_build.py 2017-08-01 11:41:20 +0000
@@ -0,0 +1,12 @@
1import os
2
3BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
4
5os.environ.setdefault(
6 'DPA_LOGS_DIR',
7 os.path.abspath(os.path.join(BASE_DIR, 'logs')))
8
9from django_project.settings_base import * # noqa
10
11DATABASES = {}
12SECRET_KEY = 'build-secret-key'
013
=== modified file 'django_project/settings_devel.py'
--- django_project/settings_devel.py 2016-07-25 20:52:24 +0000
+++ django_project/settings_devel.py 2017-08-01 11:41:20 +0000
@@ -1,8 +1,20 @@
1from django_project.settings_base import * # noqa1import os
22
3DATABASES['default']['HOST'] = '/dev/shm/pg_deployable'3BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
4USE_HTTPS = False4
5os.environ.setdefault('ALLOWED_HOSTS', "['*']")
5# Serve combo data from a relative url - served by project's gunicorn6# Serve combo data from a relative url - served by project's gunicorn
6# directly.7# directly.
7COMBO_URL = '/combo/'8os.environ.setdefault('COMBO_URL', '/combo/')
9os.environ.setdefault(
10 'DATABASE_URL',
11 'postgres://postgres@%2Fdev%2Fshm%2Fpg_deployable/revtracker')
12os.environ.setdefault('DEBUG', 'true')
13os.environ.setdefault(
14 'DPA_LOGS_DIR',
15 os.path.abspath(os.path.join(BASE_DIR, 'logs')))
16os.environ.setdefault(
17 'SECRET_KEY', '6s!*-&#t8mks^8+7_2w%!oh8wh9uzzm-vzh5)l+7r2403+tm^!')
18os.environ.setdefault('USE_HTTPS', 'false')
819
20from django_project.settings_base import * # noqa
921
=== added file 'docker-compose.dev.yml'
--- docker-compose.dev.yml 1970-01-01 00:00:00 +0000
+++ docker-compose.dev.yml 2017-08-01 11:41:20 +0000
@@ -0,0 +1,24 @@
1version: '2'
2services:
3 app:
4 restart: always
5 build: .
6 image: deployable:dev
7 command: ["./branches/wait-for-it/wait-for-it.sh", "db:5432", "--", "make", "app-start"]
8 volumes:
9 - .:/usr/src/app
10 ports:
11 - "8000:8000"
12 environment:
13 CELERY_BROKER_URL: amqp://amqp
14 DATABASE_URL: postgres://postgres@db/postgres
15 DJANGO_SETTINGS_MODULE: "django_project.settings_devel"
16 worker:
17 restart: always
18 image: deployable:dev
19 volumes:
20 - .:/usr/src/app
21 environment:
22 CELERY_BROKER_URL: amqp://amqp
23 DATABASE_URL: postgres://postgres@db/postgres
24 DJANGO_SETTINGS_MODULE: "django_project.settings_devel"
025
=== added file 'docker-compose.secrets.yml'
--- docker-compose.secrets.yml 1970-01-01 00:00:00 +0000
+++ docker-compose.secrets.yml 2017-08-01 11:41:20 +0000
@@ -0,0 +1,5 @@
1version: '2'
2services:
3 app:
4# environment:
5# SECRET_KEY: 'changeme'
06
=== added file 'docker-compose.test.yml'
--- docker-compose.test.yml 1970-01-01 00:00:00 +0000
+++ docker-compose.test.yml 2017-08-01 11:41:20 +0000
@@ -0,0 +1,9 @@
1version: '2'
2services:
3 app:
4 extends:
5 file: docker-compose.dev.yml
6 service: app
7 build:
8 dockerfile: Dockerfile.test
9 image: deployable:test
010
=== added file 'docker-compose.yml'
--- docker-compose.yml 1970-01-01 00:00:00 +0000
+++ docker-compose.yml 2017-08-01 11:41:20 +0000
@@ -0,0 +1,19 @@
1version: '2'
2services:
3 db:
4 image: postgres
5 expose:
6 - "5432"
7 amqp:
8 image: rabbitmq
9 app:
10 build: .
11 image: deployable
12 expose:
13 - "8000"
14 depends_on:
15 - db
16 - amqp
17 worker:
18 image: deployable
19 command: ["make", "worker-worker", "worker-beat"]
020
=== added file 'requirements-docker.txt'
--- requirements-docker.txt 1970-01-01 00:00:00 +0000
+++ requirements-docker.txt 2017-08-01 11:41:20 +0000
@@ -0,0 +1,19 @@
1# direct dependencies
2docker_compose==1.14.0
3
4# indirect dependencies
5PyYAML==3.12
6backports.ssl_match_hostname==3.5.0.1
7cached_property==1.3.0
8colorama==0.3.9
9docker==2.4.2
10docker_pycreds==0.2.1
11dockerpty==0.4.1
12docopt==0.6.2
13enum34==1.1.6
14functools32==3.2.3-2
15ipaddress==1.0.18
16jsonschema==2.6.0
17requests==2.11.1
18texttable==0.8.8
19websocket_client==0.44.0
020
=== modified file 'requirements.txt'
--- requirements.txt 2016-09-02 22:32:27 +0000
+++ requirements.txt 2017-08-01 11:41:20 +0000
@@ -11,6 +11,7 @@
11django-debug-toolbar==0.10.011django-debug-toolbar==0.10.0
12django-devserver==0.7.012django-devserver==0.7.0
13django-factory==0.1013django-factory==0.10
14django-getenv==1.3.1
14django-kombu==0.9.415django-kombu==0.9.4
15django-openid-auth==0.916django-openid-auth==0.9
16# A checkout of https://github.com/bfirsh/django-ordered-model at 2998740eeda348473d8a8965b40b2292c31efd8517# A checkout of https://github.com/bfirsh/django-ordered-model at 2998740eeda348473d8a8965b40b2292c31efd85
@@ -18,6 +19,7 @@
18django-picklefield==0.2.119django-picklefield==0.2.1
19django-pgtools==0.220django-pgtools==0.2
20django-waffle==0.10.121django-waffle==0.10.1
22dj-database-url==0.4.2
21gorun==1.723gorun==1.7
22gunicorn==19.3.024gunicorn==19.3.0
23html5lib==0.999999925html5lib==0.9999999

Subscribers

People subscribed via source and target branches