Skip to content

Commit

Permalink
Merge pull request #86 from metabrainz/docker-nginx
Browse files Browse the repository at this point in the history
Docker nginx
  • Loading branch information
mayhem committed Jul 15, 2016
2 parents aac58f7 + 6917d6c commit 3938a83
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends build-essential
git \
redis-tools \
wget

RUN mkdir /code
RUN pip install uWSGI==2.0.13.1

# PostgreSQL client
RUN apt-key adv --keyserver ha.pool.sks-keyservers.net --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8
Expand Down Expand Up @@ -38,3 +40,5 @@ RUN pip install -r requirements.txt

# Now install our code, which may change frequently
COPY . /code/listenbrainz/

USER daemon
13 changes: 11 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ services:
- ./data/redis:/data
web:
build: .
command: python manage.py runserver -h 0.0.0.0 -p 8000
command: uwsgi /code/listenbrainz-server/docker/uwsgi.ini
volumes:
- .:/code/listenbrainz-server
- ./data/app:/data
ports:
- "8000:8000"
- "3031:3031"
links:
- redis
- db
Expand All @@ -40,3 +40,12 @@ services:
depends_on:
- db
- redis
nginx:
restart: always
build:
context: ./docker/nginx/
dockerfile: Dockerfile
links:
- web:web
ports:
- "80:80"
3 changes: 3 additions & 0 deletions docker/nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM nginx:1.10.1

COPY nginx.conf /etc/nginx/nginx.conf
24 changes: 24 additions & 0 deletions docker/nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
worker_processes 4;

events { worker_connections 1024; }

http {
access_log /dev/stdout;
error_log /dev/stdout info;

server {
listen 80;

location / {
include uwsgi_params;
uwsgi_pass web:3031;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_cache_bypass $http_upgrade;
}
}

}
7 changes: 7 additions & 0 deletions docker/uwsgi.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[uwsgi]
socket = 0.0.0.0:3031
module = manage
callable = application
chdir = /code/listenbrainz-server
processes = 5
enable-threads = true
3 changes: 3 additions & 0 deletions manage.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
from __future__ import print_function
import db
from webserver import create_app, schedule_jobs
from werkzeug.wsgi import DispatcherMiddleware
import subprocess
import os
import click
import config
from urlparse import urlsplit

application = DispatcherMiddleware(create_app())

cli = click.Group()

ADMIN_SQL_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'admin', 'sql')
Expand Down

0 comments on commit 3938a83

Please sign in to comment.