This is a Rest Api template using python and flask framework.
This template contains:
- User authentication
- Integration with Amazon AWS S3 and kraken for image optimize and storage
- Migration scripts with Flask-Migrate
- Some basic features: cities, groups, states and users
Step-by-step setup tutorial of the Python Flask Template.
The tutorial assumes that the user's OS is UNIX based, if not make the appropriate changes and select the correct OS in the documentation.
If running on Windows remember to enable Hyper-V and virtual environments.
create docker group, you'll probably have to reboot after this.
sudo groupadd docker
sudo usermod -aG docker $USER
It's possible to run your container and debug with it using PyCharm.
- Build, Execution, Deployment
To enable docker in PyCharm go to: File>Settings>Build,Execution,Deployment>Docker Click in the + icon and use the default settings
- Project Interpreter
We need to create a remote python interpreter, basically the python interpreter running inside our container.
Go to File>Settings>Project: python-flask-template>Python Interpreter
Add a configuration clicking in the icon and clicking on "Add" and configure it like so:
- Run/Debug Configurations
The final step in the setup is to configure the Run/Debug configuration, create one using the Remote Interpreter.
First deploy
docker-compose up --build
Regular Deploy
docker-compose up
Once the project is up and running just debug the application by clicking in the debug icon
You ready to go!
- Redeploy restoring all databases
bash init.sh
To make a migration on the database use:
docker-compose exec api flask db migrate -m"<your message>"
if there's a conflict with the migration heads, run:
bash db-merge.sh