瀏覽代碼

Reconfigured environment variables for security

joel
Simon Bowie 3 年之前
父節點
當前提交
cfb960b29b
共有 6 個檔案被更改,包括 35 行新增6 行删除
  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 查看文件

@@ -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 查看文件

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

+ 21
- 0
docker-compose.prod.yml 查看文件

@@ -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 查看文件

@@ -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 查看文件

@@ -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 查看文件

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

Loading…
取消
儲存