forked from rehabstudio/docker-gunicorn-nginx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial commit of multiple dockerfile experiment
- Loading branch information
Patrick Carey
committed
Aug 7, 2014
1 parent
d6833a5
commit e31065d
Showing
20 changed files
with
164 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
ops/logs/ | ||
*.pyc |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
ENV=live | ||
TAG=rehabstudio/pythonproject | ||
|
||
help: | ||
@echo "\nall - Build & run a fresh Container" | ||
@echo "build-container - Build Container" | ||
@echo "run-container - Run Container" | ||
@echo "remove-container - Remove Container" | ||
@echo "\nGLOBAL ARGS (ENV=local, TAG=rehabstudio/pythonproject)" | ||
@echo "\neg. make all ENV=live TAG=myapp\n" | ||
@echo "build-local - Build container for local development" | ||
@echo "build-deploy - Build container in production mode" | ||
@echo "run-local - Run container for local development" | ||
@echo "run-deploy - Run container for in production mode" | ||
@echo "$(CURDIR)" | ||
|
||
build-base: | ||
cd ops/base/; docker build -t="rehabstudio/python-base" . | ||
|
||
all: build run | ||
build-local: build-base | ||
cd ops/local/; docker build -t="rehabstudio/python-local" . | ||
|
||
build: | ||
@docker build -t="$(TAG)" . | ||
build-deploy: build-base | ||
cd ops/deploy/; docker build -t="rehabstudio/python-deploy" . | ||
|
||
run: | ||
@docker run -P -v=$(CURDIR)/app/:/var/app:rw -d -e ENV=$(ENV) $(TAG) | ||
run-local: build-local | ||
docker run -P -t -i -v $(CURDIR)/app:/opt/app rehabstudio/python-local | ||
|
||
remove: | ||
-@docker rmi $(TAG) | ||
run-deploy: build-deploy | ||
docker run -P -v $(CURDIR)/app:/opt/app rehabstudio/python-deploy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from flask import Flask | ||
app = Flask(__name__) | ||
|
||
|
||
@app.route("/") | ||
def hello(): | ||
return "Hello World!" | ||
|
||
|
||
if __name__ == "__main__": | ||
app.run(debug=True, host='0.0.0.0') |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
FROM ubuntu:14.04 | ||
MAINTAINER Peter McConnell <[email protected]> | ||
|
||
# keep upstart quiet | ||
RUN dpkg-divert --local --rename --add /sbin/initctl | ||
RUN ln -sf /bin/true /sbin/initctl | ||
|
||
# no tty | ||
ENV DEBIAN_FRONTEND noninteractive | ||
|
||
# get up to date | ||
RUN apt-get update --fix-missing | ||
|
||
# global installs [applies to all envs!] | ||
RUN apt-get install -y build-essential git | ||
RUN apt-get install -y python python-dev python-setuptools | ||
RUN apt-get install -y python-pip python-virtualenv | ||
RUN apt-get install -y nginx supervisor | ||
|
||
# stop supervisor service as we'll run it manually | ||
RUN service supervisor stop | ||
|
||
# build dependencies for postgres and image bindings | ||
RUN apt-get build-dep -y python-imaging python-psycopg2 | ||
|
||
# create a virtual environment and install all depsendecies from pypi | ||
RUN virtualenv /opt/venv | ||
ADD ./requirements.txt /opt/venv/requirements.txt | ||
RUN /opt/venv/bin/pip install -r /opt/venv/requirements.txt | ||
|
||
# expose port(s) | ||
EXPOSE 80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Flask | ||
gunicorn | ||
requests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
FROM rehabstudio/python-base | ||
MAINTAINER Peter McConnell <[email protected]> | ||
|
||
RUN pip install supervisor-stdout | ||
|
||
# file management, everything after an ADD is uncached, so we do it as late as | ||
# possible in the process. | ||
ADD ./supervisord.conf /etc/supervisord.conf | ||
ADD ./nginx.conf /etc/nginx/nginx.conf | ||
|
||
# restart nginx to load the config | ||
RUN service nginx stop | ||
|
||
# start supervisor to run our wsgi server | ||
CMD supervisord -c /etc/supervisord.conf -n |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
daemon off; | ||
worker_processes 1; | ||
|
||
# user nobody nogroup; | ||
pid /tmp/nginx.pid; | ||
error_log /tmp/nginx.error.log; | ||
|
||
events { | ||
worker_connections 1024; | ||
accept_mutex off; | ||
} | ||
|
||
http { | ||
include mime.types; | ||
default_type application/octet-stream; | ||
access_log /tmp/nginx.access.log combined; | ||
sendfile on; | ||
|
||
upstream app_server { | ||
# For a TCP configuration: | ||
server 127.0.0.1:5000 fail_timeout=0; | ||
} | ||
|
||
server { | ||
listen 80 default; | ||
client_max_body_size 4G; | ||
server_name _; | ||
|
||
keepalive_timeout 5; | ||
|
||
# path for static files | ||
root /opt/app/static; | ||
|
||
location / { | ||
# checks for static file, if not found proxy to app | ||
try_files $uri @proxy_to_app; | ||
} | ||
|
||
location @proxy_to_app { | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header Host $http_host; | ||
proxy_redirect off; | ||
|
||
proxy_pass http://app_server; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[supervisord] | ||
nodaemon = true | ||
|
||
[program:nginx] | ||
command = /usr/sbin/nginx | ||
startsecs = 5 | ||
stdout_events_enabled = true | ||
stderr_events_enabled = true | ||
|
||
[program:app-gunicorn] | ||
command = /opt/venv/bin/gunicorn app:app -w 4 -b 127.0.0.1:5000 --log-level=debug --chdir=/opt/app | ||
stdout_events_enabled = true | ||
stderr_events_enabled = true | ||
|
||
[eventlistener:stdout] | ||
command = supervisor_stdout | ||
buffer_size = 100 | ||
events = PROCESS_LOG | ||
result_handler = supervisor_stdout:event_handler |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM rehabstudio/python-base | ||
MAINTAINER Peter McConnell <[email protected]> | ||
|
||
# start supervisor to run our wsgi server | ||
CMD cd /opt/app/ && /opt/venv/bin/python app.py | ||
|
||
EXPOSE 5000 |
This file was deleted.
Oops, something went wrong.