- Manage the database schema and apply migrations in
pkg/storage/db/migrations. - Manage the queries in
pkg/storage/db/sqlc. - Generated query directory
pkg/storage/db/dbx. - Manage the templates in
pkg/ui.
install go task package to run commands defined in Taskfile.yml:
go install github.com/go-task/task/v3/cmd/task@latestthen install all dev tooling:
task setup:toolinglist all tasks:
task --list-allFor configuration see the config.toml passed in as the --config flag to app.
Tip
Generate new session auth keys ask ChatGPT
"Could you generate random hex keys of 32 bytes and 16 bytes for me?"
create your dev config:
task setup:configmake sure to use the correct db dsn in sqlc.yml and that the db is fully migrated.
generate go code from sql:
task gen:sqlcnew:
task migrate:add SEQ="migration_name"up:
task migrate:updown:
task migrate:downGenerate template code with templ.guide
task gen:templuse air to generate the templates and run the server:
task airlist app commands:
go run . helprun the server:
go run . server --config config.dev.tomlcreate a user:
go run . createuser --config config.dev.toml \
--email [email protected] \
--password password \
--firstname Admin \
--lastname UserFor simplicity we are using the standalone cli.
download the cli to the tmp folder (created once air is run):
curl -sLO https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-macos-arm64
chmod +x tailwindcss-macos-arm64
mv tailwindcss-macos-arm64 tmp/tailwindcssbuild and watch:
task gen:tailwindSource JS files are located in pkg/ui/js and are compiled to pkg/static/public/js.
install deps first:
npm installbuild:
task gen:esbuildThis can be used to build the app as a binary and run it in a container.
build:
docker build --build-arg EXPOSE_PORT=80 -t echo-boilerplate:latest .run:
docker run \
--rm \
--name echo-boilerplate \
--publish "80:80" \
--env "DATABASE_HOST=host.docker.internal" \
--env "SERVER_DEBUG=false" \
--env "SERVER_PORT=80" \
echo-boilerplate:latest \
server --config config.tomlif you need it create a postgres container for the database:
docker run \
--detach \
--name "echo-postgres" \
--mount type=tmpfs,destination=/var/lib/postgresql/data \
--publish "5432:5432" \
--env POSTGRES_USER=postgres \
--env POSTGRES_PASSWORD=password \
--env POSTGRES_DB=echo-boilerplate \
postgres:latest