Updated scripts to enable deploying prod server
This commit is contained in:
parent
d80b07d43d
commit
3eea1d946a
30
app.py
30
app.py
@ -8,24 +8,20 @@ from controllers.web.endpoints import blueprint
|
|||||||
Database manager...
|
Database manager...
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
|
||||||
def main():
|
# Set app secret key to sign session cookies
|
||||||
print(__package__)
|
secret_key = environ.get("APPSECRET")
|
||||||
app = Flask(__name__)
|
if secret_key is None:
|
||||||
|
# NO Secret Key set!
|
||||||
# Set app secret key to sign session cookies
|
print("No app secret set, please set one before deploying in production")
|
||||||
secret_key = environ.get("APPSECRET")
|
app.secret_key = "DEFAULTKEY"
|
||||||
if secret_key is None:
|
else:
|
||||||
# NO Secret Key set!
|
app.secret_key = secret_key
|
||||||
print("No app secret set, please set one before deploying in production")
|
|
||||||
app.secret_key = "DEFAULTKEY"
|
|
||||||
else:
|
|
||||||
app.secret_key = secret_key
|
|
||||||
|
|
||||||
# Register a blueprint
|
|
||||||
app.register_blueprint(blueprint)
|
|
||||||
app.run(debug=True, host="0.0.0.0")
|
|
||||||
|
|
||||||
|
# Register a blueprint
|
||||||
|
app.register_blueprint(blueprint)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
app.run(debug=True, host="0.0.0.0", port=8080)
|
||||||
|
|
||||||
|
@ -7,11 +7,11 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
- APPSECRET=test
|
- APPSECRET=test
|
||||||
- ENVIRON=test
|
- ENVIRON=test
|
||||||
# - ENVIRON=prod
|
#- ENVIRON=prod
|
||||||
- FILESTORE=static/assets/img/products/
|
- FILESTORE=static/assets/img/products/
|
||||||
tty: true
|
tty: true
|
||||||
ports:
|
ports:
|
||||||
- "5000:5000"
|
- "8080:8080"
|
||||||
volumes:
|
volumes:
|
||||||
- .:/app
|
- .:/app
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
@ -1,2 +1,24 @@
|
|||||||
#! /bin/bash
|
#! /bin/bash
|
||||||
pytest --disable-warnings && python ./scripts/create_database.py && python ./app.py
|
pytest --disable-warnings
|
||||||
|
python ./scripts/create_database.py
|
||||||
|
|
||||||
|
EXPECTED_VALUE="test"
|
||||||
|
|
||||||
|
if [ -z "$ENVIRON" ]; then
|
||||||
|
echo "ENVIRON is not set."
|
||||||
|
else
|
||||||
|
echo "ENVIRON is set to: $ENVIRON"
|
||||||
|
|
||||||
|
# Trim leading and trailing whitespaces
|
||||||
|
ACTUAL_VALUE=$(echo "$ENVIRON" | tr -d '[:space:]')
|
||||||
|
|
||||||
|
if [ "$ACTUAL_VALUE" = "$EXPECTED_VALUE" ]; then
|
||||||
|
echo "Launching DEV Server"
|
||||||
|
python ./app.py
|
||||||
|
else
|
||||||
|
echo "Launching PROD Server"
|
||||||
|
waitress-serve --host 0.0.0.0 app:app
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user