Sfoglia il codice sorgente

Reconfigured environment variables for security

joel
Simon Bowie 3 anni fa
parent
commit
cfb960b29b
6 ha cambiato i file con 35 aggiunte e 6 eliminazioni
  1. +8
    -0
      .env.dev
  2. +1
    -1
      .gitignore
  3. +21
    -0
      docker-compose.prod.yml
  4. +3
    -2
      web/app/__init__.py
  5. +2
    -2
      web/app/tool.py
  6. +0
    -1
      web/requirements.txt

+ 8
- 0
.env.dev Vedi File

@@ -0,0 +1,8 @@
# This config file contains the environment variables for the application and for the database

# Flask variables
FLASK_APP=app
FLASK_RUN_HOST=0.0.0.0
FLASK_ENV=development
SECRET_KEY=f9DWPyF70N
DATABASE_URL=sqlite:///db.sqlite

+ 1
- 1
.gitignore Vedi File

@@ -1,3 +1,3 @@
web/app/__pycache__/
web/app/db.sqlite
.env.dev
.env.prod

+ 21
- 0
docker-compose.prod.yml Vedi File

@@ -0,0 +1,21 @@
version: "3.9"
services:
web:
build: ./web
container_name: python
ports:
- "5000:5000"
volumes:
- ./web:/code
env_file:
- ./.env.prod

db:
image: mariadb:latest
container_name: mariadb
restart: unless-stopped
env_file:
- ./.env.prod
volumes:
dbdata:/var/lib/mysql
command: '--default-authentication-plugin=mysql_native_password'

+ 3
- 2
web/app/__init__.py Vedi File

@@ -1,6 +1,7 @@
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_login import LoginManager
import os

# init SQLAlchemy so we can use it later in our models
db = SQLAlchemy()
@@ -8,8 +9,8 @@ db = SQLAlchemy()
def create_app():
app = Flask(__name__)

app.config['SECRET_KEY'] = 'f9DWPyF70N'
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///db.sqlite'
app.config['SECRET_KEY'] = os.environ.get('SECRET_KEY')
app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get('DATABASE_URL')

db.init_app(app)


+ 2
- 2
web/app/tool.py Vedi File

@@ -4,14 +4,14 @@ from .models import Tool
from werkzeug.exceptions import abort
from . import db

tool = Blueprint('tool', __name__)

def get_tool(tool_id):
tool = Tool.query.filter_by(id=tool_id).first()
if tool is None:
abort(404)
return tool

tool = Blueprint('tool', __name__)

@tool.route('/tools')
def get_tools():
tools = Tool.query

+ 0
- 1
web/requirements.txt Vedi File

@@ -1,4 +1,3 @@
flask
requests
flask-sqlalchemy
flask-login

Loading…
Annulla
Salva