Skip to content

Commit

Permalink
One giant commit with basic compose working
Browse files Browse the repository at this point in the history
  • Loading branch information
hndrewaall committed Jan 3, 2017
1 parent 5729aa2 commit a1a2ffd
Show file tree
Hide file tree
Showing 271 changed files with 104 additions and 11 deletions.
9 changes: 3 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,9 @@ docs/_build

.webassets-cache

# Virtualenvs
env/

# SQLite DB
dev.db
app/dev.db

# Generated CSS/JS
league/static/public/css/common.css
league/static/public/js/common.js
app/league/static/public/css/common.css
app/league/static/public/js/common.js
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ language: python
python:
- 3.4.5
env:
- FLASK_APP=autoapp.py
install: pip install -r requirements/dev.txt
- FLASK_APP=app/autoapp.py
install: pip install -r app/requirements/dev.txt
before_script: flask lint
script: flask test
1 change: 0 additions & 1 deletion Procfile

This file was deleted.

2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ add the following to ``.bashrc`` or ``.bash_profile``.
Before running shell commands, set the ``FLASK_APP`` and ``FLASK_DEBUG``
environment variables ::

export FLASK_APP=/path/to/autoapp.py
export FLASK_APP=app/autoapp.py
export FLASK_DEBUG=1

Then run the following commands to bootstrap your environment ::
Expand Down
File renamed without changes.
File renamed without changes.
28 changes: 28 additions & 0 deletions app/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM alpine:3.5

COPY requirements/prod.txt requirements.txt

# Stolen from https://nickjanetakis.com/blog/alpine-based-docker-images-make-a-difference-in-real-world-apps
RUN apk add --no-cache --virtual .build-deps \
build-base postgresql-dev libffi-dev python3 python3-dev uwsgi uwsgi-python3 \
&& pip3 install -r requirements.txt \
&& find /usr/local \
\( -type d -a -name test -o -name tests \) \
-o \( -type f -a -name '*.pyc' -o -name '*.pyo' \) \
-exec rm -rf '{}' + \
&& runDeps="uwsgi uwsgi-python3 python3 libpq $( \
scanelf --needed --nobanner --recursive /usr/local \
| awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \
| sort -u \
| xargs -r apk info --installed \
| sort -u \
)" \
&& apk add --virtual .rundeps $runDeps \
&& apk del .build-deps

COPY . /app
WORKDIR /app

VOLUME /tmp/uwsgi

CMD ["./migrate_and_run.sh"]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 8 additions & 1 deletion league/settings.py → app/league/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@ class ProdConfig(Config):

ENV = 'prod'
DEBUG = False
SQLALCHEMY_DATABASE_URI = 'postgresql://localhost/example'
POSTGRES_DB = os.environ.get('POSTGRES_DB', 'postgresql')
POSTGRES_USER = os.environ.get('POSTGRES_USER', 'postgresql')
POSTGRES_PASSWORD = os.environ.get('POSTGRES_PASSWORD', '')
SQLALCHEMY_DATABASE_URI = ('postgresql://{}:{}@db/{}').format(
POSTGRES_USER,
POSTGRES_PASSWORD,
POSTGRES_DB
)
DEBUG_TB_ENABLED = False # Disable Debug toolbar


Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 11 additions & 0 deletions app/migrate_and_run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#! /bin/sh

export FLASK_APP=autoapp.py

while true
do
rm -rf migrations && flask db init && flask db migrate && flask db upgrade && break
sleep 1
done

uwsgi -s /tmp/uwsgi/uwsgi.sock --plugin python3 --manage-script-name --mount /=autoapp:app
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions db/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM kiasaki/alpine-postgres
28 changes: 28 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
version: '2'
services:
app:
build: ./app
volumes:
- ./tmp/uwsgi:/tmp/uwsgi
environment:
- POSTGRES_DB
- POSTGRES_USER
- POSTGRES_PASSWORD
depends_on:
- db

webserver:
build: ./webserver
volumes_from:
- app:rw
ports:
- '8080:80'
depends_on:
- app

db:
build: ./db
environment:
- POSTGRES_DB
- POSTGRES_USER
- POSTGRES_PASSWORD
3 changes: 3 additions & 0 deletions webserver/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM nginx:1.11-alpine

COPY nginx.conf /etc/nginx/nginx.conf
19 changes: 19 additions & 0 deletions webserver/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
events {
worker_connections 1024;
}

error_log /dev/stdout info;

http {

access_log /dev/stdout;

server {
listen 80;

location / {
include uwsgi_params;
uwsgi_pass unix:///tmp/uwsgi/uwsgi.sock;
}
}
}

0 comments on commit a1a2ffd

Please sign in to comment.