Skip to content

Instantly share code, notes, and snippets.

@castellanprime
Created June 24, 2017 00:56
Show Gist options
  • Save castellanprime/8269386788fe28900b7758f4f8a47ac1 to your computer and use it in GitHub Desktop.
Save castellanprime/8269386788fe28900b7758f4f8a47ac1 to your computer and use it in GitHub Desktop.
project structure
=================
docker-compose.yml
mainweb/
nginx/
README
docker-compose.yml
-----------------
version: '2'
services:
app:
restart: always
build: ./mainweb
command: gunicorn -w 2 -b :5000 wsgi:app
networks:
- mainnet
expose:
- "5000"
ports:
- "5000:5000"
nginx:
restart: always
build: ./nginx
networks:
- mainnet
links:
- app
volumes:
- /www/static
expose:
- 8080
ports:
- "8880:8080"
networks:
mainnet:
mainweb/
========
app.py
Dockerfile
requirements.txt
templates/
wsgi.py
mainweb/app.py
--------------
from flask import Flask, render_template
app=Flask(__name__)
@app.route('/')
def home()():
return render_template('templates/home.html')
if __name__=="__main__":
app.run(host="0.0.0.0", port=5000)
mainweb/Dockerfile
---------------------
FROM python:3.5
MAINTAINER castellanprime
RUN mkdir /mainweb
COPY . /mainweb
WORKDIR /mainweb
RUN pip install -r requirements.txt
mainweb/templates/
=============
home.html
mainweb/templates/home.html
--------------------------
<!doctype html>
<html>
<head>
<title> My website </title>
</head>
<body>
<h1> I am here </h1>
</body>
</html>
mainweb/wsgi.py
-----------------
from app import app
if __name__=="__main__":
app.run()
nginx
=============
Dockerfile
sites-enabled.conf
static/
nginx/Dockerfile
----------------
FROM nginx:1.13.1-alpine
MAINTAINER castellanprime
ADD sites-enabled.conf /etc/nginx/conf.d/sites-enabled.conf
ADD static/ /www/static/
nginx/sites-enabled.conf
-------------------------
server{
listen 8080;
server_name app; # Should I put my actual www.XXXXXX.XXXXX address here
charset utf-8;
location /static{
alias /www/static/;
}
location / {
proxy_pass http://app:5000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X_Forwared-For $proxy_add_x_forwarded_for;
}
}
nginx/static
============
css/
js/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment