This repository has been archived on 2024-04-25. You can view files and clone it, but cannot push or open issues or pull requests.
golang-rest-example/justfile

55 lines
1.2 KiB
Makefile
Raw Permalink Normal View History

2024-02-01 22:09:09 +00:00
export GO_VERSION := "1.21"
_default:
@just --list
_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:
docker compose up db swagger --detach --wait
@just _run
2024-02-02 14:39:13 +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:
go generate ./...
2024-02-01 22:09:09 +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:
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
# Deploy the app with docker-compose
deploy:
docker compose up --build
# Cleanup the deployment
cleanup:
docker compose down