Deployment Setup

Got up early today, had a good night's sleep, it's raining outside, my schedule is free, and I'm determined to finish everything up.

This was the todo list from a few days ago:

  • Creating github repositories
  • mostly done
  • Generating dockerfiles and deploying
  • Setting up database credentials and creating databases
  • Automating DNS

Next up, CI/CD. FOr that, I need to add some secrets to the github repos.

Okay, got the docker and ssh variables ready, now it's time to set up proper config loading.

Got the config loading and refactored the code a bit.

Spent 2 more hours untangling the code, refactoring and organizing. The configuration is all over the place, I need to set it up so it can load both dev and prod config. Made a lot of progress, still not quite there yet, but good enough for now. I'll get back to it when it's time to deploy.

I am now generating the docker-compose with the api service in it. Time to figure out how to deploy the web-app, I guess.

Thinking about whether to just deploy static files, or wrap it in an nginx container.

Decided on deploying static files, with the following structure:

hatch/
├── docker-compose.yml       # compose for the api / any other container
├── web-app/                 # dir per each static site
│   ├── nginx.config         # site config with symlink in /etc/nginx/sites-enabled
│   └── static/              # Built static files

Should be pretty easy to set up. Now I'm thinking about the ENV variables. I'm thinking about build vs runtime, but all of them are public anyways, so why don't I just hardcode them? Think I'll do that.

I will keep two env files:

  • .env.local
  • .env.production

Then, when running vite build, it will automatically use the production one.

Next up, I'm missing a GitHub action that will build and copy this thing over to the prod machine on build.

Okay that's done. A few things I need to do before I try running this:

  • initialize the app dir on the machine
    • create app dir
    • create docker-compose
    • create nginx.config and symlink in sites-enabled
  • Set up environment variables on GitHub Actions in both repositories

Managed to set up the ssh client and create the docker-compose. Unfortunately, I ran out of time today. Nonetheless, a very productive session.