Skip to content

Commit

Permalink
Updated docker to use wait-for-it.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas Metzener committed Nov 14, 2016
1 parent a61ab6a commit a8a8cbb
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 21 deletions.
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ indent_size = 2
[*.html]
indent_style = space
indent_size = 4

[*.yml,*.yaml]
indent_style = space
indent_size = 2
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ FROM python:2.7
ENV PYTHONUNBUFFERED 1
RUN mkdir -p /usr/src/app
RUN apt-get update && apt-get install -y gettext postgresql-client
RUN wget https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh -P /usr/bin
RUN chmod +x /usr/bin/wait-for-it.sh
WORKDIR /usr/src/app
ADD requirements.txt /usr/src/app/
RUN pip install --upgrade pip
RUN pip install -r requirements.txt
ADD . /usr/src/app/
14 changes: 8 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
DJANGO_ADMIN_USER=admin
.PHONY: sass sass-watch dev-env docker docker-clean docker-init docker-makemigrations docker-migrate docker-makemessages docker-compilemessages docker-pw

.DEFAULT_GOAL := help

DJANGO_ADMIN_USER=admin
PGPASSWORD=freedomvote
DB_PORT=5432

help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort -k 1,1 | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
Expand All @@ -22,11 +26,9 @@ docker-clean: ## Remove the docker environment
@docker-compose rm -f

docker-init: ## Initialize the docker environment
@docker-compose up --no-recreate -d db
@sleep 5
@docker-compose up --no-recreate -d web
@PGPASSWORD=$(PGPASSWORD) psql -h localhost -U postgres freedomvote < tools/docker/cache_table.sql
@make docker-migrate
@docker-compose up -d --no-recreate
@PGPASSWORD=$(PGPASSWORD) psql -h localhost -p $(DB_PORT) -U postgres freedomvote < tools/docker/cache_table.sql
@docker exec -it freedomvote_web_1 python app/manage.py migrate
@docker exec -it freedomvote_web_1 app/manage.py loaddata tools/docker/user.json
@docker-compose stop

Expand Down
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,19 @@ Requirements:

Run `pip install -r requirements.txt` to install all requirements.

Configure your DB settings in `app/freedomvote/settings.py` and then run:
Configure your DB settings in `app/settings.ini`:

```ini
[DB]
NAME = freedomvote
USER = freedomvote
PASS = ***********
PORT = 5432
HOST = 127.0.0.1
```

and then run:

```bash
$ psql -h <db_host> -U <db_user> <db_name> < tools/docker/cache_table.sql
$ python app/manage.py migrate
Expand Down
29 changes: 15 additions & 14 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
db:
image: postgres
ports:
- "5432:5432"
environment:
- POSTGRES_DB=freedomvote
- POSTGRES_PASSWORD=freedomvote

web:
version: "2"
services:
web:
build: .
command: python app/manage.py runserver 0.0.0.0:8000
ports:
- "8000:8000"
volumes:
- .:/usr/src/app
- .:/usr/src/app
depends_on:
- db
command: wait-for-it.sh db:5432 -- python app/manage.py runserver 0.0.0.0:8000
db:
image: postgres
ports:
- "8000:8000"
links:
- db
- "5432:5432"
environment:
- POSTGRES_DB=freedomvote
- POSTGRES_PASSWORD=freedomvote

0 comments on commit a8a8cbb

Please sign in to comment.