Wrapping Up
Time to wrap everything up. Let's start with the keycoak redirect issue.
Keycloak Redirect Issue
Seems like I did an oopsie. I should probably search the codebase for any other TODOs.
Api Nginx Config
Now that that's done, I need to set up the api nginx. For some reason I never got around to doing that.
server { listen 80; server_name {% .Domain %}; location / { proxy_pass http://localhost:{% .Port %}; } }
I've hardcoded the port for now, but I'll have to look into removing them altogether. This would require me to run the nginx in a docker container, but I'm not sure if that's possible. I mildly recall trying to do that a long time ago and not succeeding for some reason, some SSL issue I think.
Had to add my new user to the docker group
sudo usermod -aG docker hatch
A couple of tiny fixes later, the api is running, accessible and returning an error 😢
Automatic Migrations
The reason for the error is that migrations haven't been run. I'm not sure what to do about this. I cannot run them when creating, because the api isn't deployed at that point yet. Maybe I should finally set up an automatic migration process? That would probably require me to embed the migration files in the go binary. I'll have to do some research.
Reading the goose docs, it seems to be fairly straightforward.
I set everything up as documented but there's a weird issue.
panic: pq: relation "goose_db_version" does not exist; pq: permission denied for schema public
Seems like goose doesn't create the versions table if it's run through code?
Okay, this was a postgres permissions problem. I wasted like 3 hours on this, mostly because I was relying on AI, which kept running in circles. Honestly, the use cases for ai are running thinner and thinner each day.
Basically, I was doing this:
CREATE DATABASE barelytics CREATE USER barelytics WITH PASSWORD 'password'; GRANT ALL PRIVILEGES ON DATABASE barelytics TO barelytics;
When I should've done this:
CREATE USER barelytics WITH PASSWORD 'password'; ALTER DATABASE barelytics OWNER TO barelytics; GRANT ALL PRIVILEGES ON DATABASE barelytics TO barelytics;
Then the gotcha - I need to open a new admin connection to the newly created database and run:
GRANT ALL ON SCHEMA public TO barelytics;
Finally the login is working.
Landing Page
Next up, I need to add the landing page generation and setup.
That was pretty easy. It was basically the same setup as the web app, but much simpler. I dumped this one on claude and it wrote it pretty much in first try.
I tried clicking around in prod, and it seems like it doesn't work properly 😟
I had to change this
try_files $uri /index.html;
to this.
try_files $uri $uri/ $uri/index.html /index.html;
so it can load nested htmls.
Looking at the template, I think I'll remove it completely. It has a bunch of unnecessary shit, and I want to build stuff from scratch so I can actually learn.
Done.
Making it Pretty
I want the command output to look nicer. I'll add in some visuals and clean things up a bit.
Finally finished!
This wraps up the hatch project for now. I will still come back to update the templates as I learn and improve, but I'll be doing it on a real project.
Next up - Barelytics! So excited!