More Infrastructure

Reflection

This was a week of sinking a lot of time into what felt like not a lot done. I focused this week on standing up the database and deploying the app to Heroku for Capstone. We also decided to drop Typescript which meant recreating the front-end from scratch. Setting up MySQL locally is a delicate process. One wrong choice and nothing works. I had to re-install MySQL probably 4 times. I also dealt with a weird port issue that took an hour or so to resolve. I also wrote the database table creation script in Python that’s executing in app.py along with some SQL that creates some dummy data.

Deploying the app to Heroku was interesting. I decided it was best that we use GitHub integration and automatically deploy the app to Heroku whenever there is a push to the main branch. This meant figuring out how to get Heroku to compile the front-end from React to static JS/CSS/HTML during the build but run the Flask app that serves the static files. While it ended up perhaps 20-30 lines of code, it took a few hours at least to get it all working.

Then came the beast that was setting up a ClearDB MySQL remote database for our app in Heroku. I had a lot of trouble getting Heroku to use the environment variables and for Flask to pick them up and use them in the app. This also took a few hours of research and troubleshooting to get going.

In the end I got it all done and wrote up some documentation on how to install MySQL and setup the database locally, using environment variables to provide database credentials and keep credentials out of the app itself, since the repo is public.

Week 4

  • Stood up database locally, including addition of environment variables for credentials and documentation
  • Wrote MySQL scripts in Python that creates tables and injects dummy data
  • Wrote up documentation on how to install and standup database locally
  • Set up environment variable that flags whether to recreate the tables from scratch and integrated it with the main Flask app
  • Set up deployment pipeline for Heroku, using GitHub branch integration
  • Wrote a postbuild Heroku script for compiling the front-end React code when building the app in Heroku, providing the static files for the app the serve
  • Set up the ClearDB remote database for the deployed app in Heroku

What Went Well and What Didn’t

This was a tough week. A lot of research and trial and error for what felt like not a lot done. Looking at my list of what was accomplished, it does look like a lot. I guess productivity is not always tied to lines of code written. Overall a productive week full of research and troubleshooting to get everything playing nice.

I do enjoy setting up application infrastructure but hoping to get back to more coding next week. I want to start contributing to the functionality of the project and less of laying the scaffolding. Hopefully most of that is behind us now. Though I guess I do enough coding at work though so it’s a nice change of pace.

I have also found that I enjoy writing documentation more than I though. I know how difficult it can be to set up a dev environment locally, and hopefully boiling down the hours spent getting something set up into a succinct few steps can save another developer from hours of hair and sleep loss.

This week’s quote:

A successful man is one who can lay a firm foundation with the bricks others have thrown at him.

– David Brinkley
Print Friendly, PDF & Email

Leave a comment

Your email address will not be published. Required fields are marked *