It's a simple question. You are given two characters. Who would win in a fight?
Requires tailwindcss, templ and go 1.21
To run locally, execute:
sh tools/run.sh
This will also attempt to start auto reloading on changes.
If that fails, you can also execute the steps manually.
You'll first have to first export the environment variables from the .env file:
# Neat way to load env variables
set -o allexport
source ./.env
set +o allexport
Then you have to build the tailwindcss file, generate the templ components, and then run the webserver:
tailwindcss -i static/tw.css -o static/main.css \
&& templ generate \
&& go run main.go
This has to be restarted manually after every change.
docker build -t compare .
docker run -p 3000:3000 compare
Database migrations are handled using sql-migrate and can be executed with the following command (requires the database to be running):
docker run \
-v $(pwd)/migrations:/migrations \
--network host migrate/migrate \
-path /migrations/ \
-database 'postgres://docker:docker@localhost:5432/compare?sslmode=disable' \
down -all
To work with the database, an SQL builder called SQLBoiler is used. It generates model files from a running database instance.
First start up the postgres instance:
docker compose up
Then run the migrations as explained above. And lastly run SQLBoiler:
sqlboiler psql
If you don't want to install SQLBoiler, you can also execute it using the Dockerfile provided in tools/
:
docker build -f tools/Dockerfile.sqlboiler . -t build-models
docker run -v $(PWD)/models:/app/models --network host build-models psql
Note, on big changes clear the directory beforehand, because SQLBoiler does not delete any old files.