Closed mick-net closed 4 years ago
Could this have anything to do with the app_context?
in billing/models/invoice.py I added:
app = Flask(__name__)
app.config.from_object('config.settings')
....
with app.app_context():
moneybird_tax_rate_id_no_vat = \
app.config.get("MONEYBIRD_TAX_RATE_ID_NO_VAT")
I did this since I wasn't able to use Flask's current_app:
raise RuntimeError('working outside of application context')
RuntimeError: working outside of application context
Hi,
What happens if you put in a dummy string value instead of None
for that env's default value?
At Docker build time the .env
file will not be available since we're not copying it in (that's because it's being ignored in the .dockerignore
file which is good) so our options are:
Pick reasonable default values for the env variables that require being present to not blow up in your settings.py
file (such as your custom env variable since it's converting it to an int
),
At build time, pass in non-secret dummy values into the build args for each required env variable (similar to what we do with FLASK_ENV
) which will let things build, but then at run-time those will be overwritten with our real .env
file's values.
Thanks for the quick reply. That worked.
Hi Nick,
I'm using your Build A SaaS app with Flask framework. The course was great. I build my own API app on top of it. I started adding extra environment parameters to the .env file and to the settings.py. I can build the web docker container when Flask is in 'development'. However when I set Flask to 'production' than I get the following error:
If I comment out the code below in the dockerfile, it builds again in production:
Do you have any suggestions?
Version: Flask-Static-Digest==0.1.2