Bläddra i källkod

Added Gunicorn and Nginx for production use

joel
Simon Bowie 3 år sedan
förälder
incheckning
8faf409be7
4 ändrade filer med 38 tillägg och 5 borttagningar
  1. +20
    -5
      docker-compose.prod.yml
  2. +16
    -0
      nginx-conf/toolkit.conf
  3. +1
    -0
      web/app/__init__.py
  4. +1
    -0
      web/requirements.txt

+ 20
- 5
docker-compose.prod.yml Visa fil

@@ -3,12 +3,13 @@ services:
web:
build: ./web
container_name: python
ports:
- "5000:5000"
volumes:
- ./web:/code
expose:
- 5000
env_file:
- ./.env.prod
depends_on:
- db
command: gunicorn --workers=3 --bind 0.0.0.0:5000 "app:create_app()"

db:
image: mariadb:latest
@@ -17,5 +18,19 @@ services:
env_file:
- ./.env.prod
volumes:
dbdata:/var/lib/mysql
- dbdata:/var/lib/mysql
command: '--default-authentication-plugin=mysql_native_password'

nginx:
image: nginx:latest
container_name: nginx
restart: unless-stopped
ports:
- "1337:80"
volumes:
- ./nginx-conf:/etc/nginx/conf.d
depends_on:
- web

volumes:
dbdata:

+ 16
- 0
nginx-conf/toolkit.conf Visa fil

@@ -0,0 +1,16 @@
upstream toolkit {
server web:5000;
}

server {

listen 80;

location / {
proxy_pass http://toolkit;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
}

}

+ 1
- 0
web/app/__init__.py Visa fil

@@ -26,6 +26,7 @@ def create_app():
# get config variables from OS environment variables: set in env file passed through Docker Compose
app.config['SECRET_KEY'] = os.environ.get('SECRET_KEY')
app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get('DATABASE_URL')
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = 'False'

db.init_app(app)


+ 1
- 0
web/requirements.txt Visa fil

@@ -2,3 +2,4 @@ flask
flask-sqlalchemy
flask-login
flask-moment
gunicorn

Laddar…
Avbryt
Spara