- 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.
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.tomlFor 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:tailwindWhen content is in the database you will need a safelist of css classes.
To do this there is a query in pkg/storage/db/sqlc/tailwind.sql, this returns a unique list
of css classes found in the page_html.html field. You can expand this to fit further requirements.
running the following task will rebuild the tailwind.safelist.txt file with an updated list of css classes.
task gen:tailwind-safelistto expand the config make sure you update the tailwind.config.js.tmpl file to include new settings.
With the config rebuilt, re-run the main gen:tailwind task.
This 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 cms:latest .run:
docker run \
--rm \
--name cms \
--publish "80:80" \
--env "DATABASE_HOST=host.docker.internal" \
--env "SERVER_DEBUG=false" \
--env "SERVER_PORT=80" \
cms:latest \
server --config config.tomlif you need it create a postgres container for the database:
docker run \
--detach \
--name "cms-postgres" \
--mount type=tmpfs,destination=/var/lib/postgresql/data \
--publish "5432:5432" \
--env POSTGRES_USER=postgres \
--env POSTGRES_PASSWORD=password \
--env POSTGRES_DB=cms \
postgres:latest