2024-02-01 22:09:09 +00:00
|
|
|
export GO_VERSION := "1.21"
|
|
|
|
|
|
|
|
_default:
|
|
|
|
@just --list
|
|
|
|
|
2024-02-06 22:34:17 +00:00
|
|
|
_run:
|
|
|
|
#!/bin/env bash
|
|
|
|
export DATABASE_URL=postgresql://postgres:postgres@localhost:1233/postgres?sslmode=disable
|
|
|
|
export DATABASE_MIGRATIONS=file://$(pwd)/migrations
|
|
|
|
export PORT=1234
|
|
|
|
go build -o dist/server cmd/server.go
|
|
|
|
./dist/server
|
|
|
|
|
2024-02-01 22:09:09 +00:00
|
|
|
# Run the app in development mode
|
2024-02-01 18:57:25 +00:00
|
|
|
run:
|
2024-02-06 22:34:17 +00:00
|
|
|
docker compose up db swagger --detach --wait
|
|
|
|
@just _run
|
2024-02-02 14:39:13 +00:00
|
|
|
|
2024-02-06 22:34:17 +00:00
|
|
|
# Run the app in development mode and watch for changes
|
|
|
|
run-watch:
|
|
|
|
docker compose up db swagger --detach --wait
|
|
|
|
watchexec -r -e go just _run
|
2024-02-01 18:57:25 +00:00
|
|
|
|
2024-02-01 22:09:09 +00:00
|
|
|
# Generate OpenAPI files
|
2024-02-01 18:57:25 +00:00
|
|
|
gen:
|
2024-02-06 22:34:17 +00:00
|
|
|
go generate ./...
|
2024-02-01 22:09:09 +00:00
|
|
|
|
2024-02-06 22:34:17 +00:00
|
|
|
# Run e2e tests
|
|
|
|
test:
|
|
|
|
#!/bin/env bash
|
|
|
|
export TESTCONTAINERS_RYUK_DISABLED=true
|
|
|
|
export DATABASE_MIGRATIONS=file://$(pwd)/migrations
|
|
|
|
go test -v -cover ./...
|
|
|
|
|
|
|
|
# Run e2e tests in watch mode
|
|
|
|
test-watch:
|
|
|
|
watchexec -r -e go just test
|
2024-02-02 14:39:13 +00:00
|
|
|
|
|
|
|
# Create a new migration file
|
|
|
|
migration-create name:
|
2024-02-06 22:34:17 +00:00
|
|
|
go run -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@v4.1.0 \
|
|
|
|
create -ext sql -dir migrations -seq {{name}}
|
2024-02-02 14:39:13 +00:00
|
|
|
|
|
|
|
# Run pgcli to connect to the database
|
|
|
|
db-cli:
|
|
|
|
docker compose exec db psql -U postgres -d postgres
|
2024-02-06 22:34:17 +00:00
|
|
|
|
|
|
|
# Deploy the app with docker-compose
|
|
|
|
deploy:
|
|
|
|
docker compose up --build
|
|
|
|
|
|
|
|
# Cleanup the deployment
|
|
|
|
cleanup:
|
|
|
|
docker compose down
|