mirror of
https://github.com/rjNemo/rentease.git
synced 2026-06-12 13:46:51 +00:00
build(make): replace justfile with Makefile; docs: update README; chore: remove justfile
This commit is contained in:
parent
9aac2aba2f
commit
90d82fb79b
3 changed files with 54 additions and 46 deletions
43
Makefile
Normal file
43
Makefile
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
# Defaults (override via `make VAR=value`)
|
||||||
|
NAME ?= rentease
|
||||||
|
PORT ?= 8000
|
||||||
|
DB_USER ?= ruidy
|
||||||
|
DB_NAME ?= villafleurie
|
||||||
|
|
||||||
|
DOCKER_RUN_ENV = -e DATABASE_URL="host=docker.for.mac.host.internal user=$(DB_USER) database=$(DB_NAME)" -e PORT=$(PORT)
|
||||||
|
|
||||||
|
.PHONY: help build run dev test up-deps format lint stop
|
||||||
|
|
||||||
|
help: ## List available commands
|
||||||
|
@grep -E '^[a-zA-Z_-]+:.*?## ' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " %-12s %s\n", $$1, $$2}'
|
||||||
|
|
||||||
|
build: format lint ## Build the production Docker image
|
||||||
|
docker build -t $(NAME):latest .
|
||||||
|
|
||||||
|
run: build ## Run the production container (port $(PORT))
|
||||||
|
docker run -p $(PORT):$(PORT) $(DOCKER_RUN_ENV) $(NAME)
|
||||||
|
|
||||||
|
dev: ## Build and run the dev container with live reload (Air)
|
||||||
|
docker build -t $(NAME):dev -f Dockerfile.dev .
|
||||||
|
docker run -p $(PORT):$(PORT) --rm \
|
||||||
|
-v `pwd`:/app -v /app/tmp \
|
||||||
|
--name $(NAME) \
|
||||||
|
$(DOCKER_RUN_ENV) $(NAME):dev
|
||||||
|
|
||||||
|
test: ## Run Go tests inside the running dev container
|
||||||
|
docker exec $(NAME) go test ./...
|
||||||
|
|
||||||
|
up-deps: ## Update Go dependencies on host
|
||||||
|
go get -u ./...
|
||||||
|
|
||||||
|
format: ## Generate templ files and format code (dev container must be running)
|
||||||
|
docker exec $(NAME) templ generate internal/view
|
||||||
|
docker exec $(NAME) templ fmt .
|
||||||
|
docker exec $(NAME) go fmt ./...
|
||||||
|
|
||||||
|
lint: ## Lint the code using golangci-lint (dev container must be running)
|
||||||
|
docker exec $(NAME) golangci-lint run ./...
|
||||||
|
|
||||||
|
stop: ## Stop the dev container
|
||||||
|
-@docker stop $(NAME) >/dev/null 2>&1 || true
|
||||||
|
|
||||||
11
README.md
11
README.md
|
|
@ -79,6 +79,17 @@ use a cloud alternative such as Railway, fly.io, _etc._
|
||||||
make dev
|
make dev
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Development Commands
|
||||||
|
|
||||||
|
Use the included Makefile for common tasks:
|
||||||
|
|
||||||
|
- `make dev`: Run the dev container with live reload (Air) on `http://localhost:8000`.
|
||||||
|
- `make run`: Build and run the production image locally.
|
||||||
|
- `make test`: Run `go test ./...` inside the dev container.
|
||||||
|
- `make format`: Generate templ files and format code.
|
||||||
|
- `make lint`: Lint with `golangci-lint`.
|
||||||
|
- `make stop`: Stop the dev container.
|
||||||
|
|
||||||
6. **Access the application**:
|
6. **Access the application**:
|
||||||
Open your browser and go to `http://localhost:8000` to start using Rentease.
|
Open your browser and go to `http://localhost:8000` to start using Rentease.
|
||||||
|
|
||||||
|
|
|
||||||
46
justfile
46
justfile
|
|
@ -1,46 +0,0 @@
|
||||||
# Set default values
|
|
||||||
name := "rentease"
|
|
||||||
port := "8000"
|
|
||||||
db_user := "ruidy"
|
|
||||||
db_name := "villafleurie"
|
|
||||||
|
|
||||||
# List available recipes
|
|
||||||
default:
|
|
||||||
@just --list
|
|
||||||
|
|
||||||
# Build the binary
|
|
||||||
build: format lint
|
|
||||||
@docker build -t {{name}}:latest .
|
|
||||||
|
|
||||||
# Run the binary
|
|
||||||
run: build
|
|
||||||
@docker run -p {{port}}:{{port}} \
|
|
||||||
-e DATABASE_URL="host=docker.for.mac.host.internal user={{db_user}} database={{db_name}}" \
|
|
||||||
-e PORT={{port}} {{name}}
|
|
||||||
|
|
||||||
# Run the binary in dev mode
|
|
||||||
dev:
|
|
||||||
@docker build -t {{name}}:dev -f Dockerfile.dev .
|
|
||||||
@docker run -p {{port}}:{{port}} --rm \
|
|
||||||
-v `pwd`:/app -v /app/tmp \
|
|
||||||
--name {{name}} \
|
|
||||||
-e DATABASE_URL="host=docker.for.mac.host.internal user={{db_user}} database={{db_name}}" \
|
|
||||||
-e PORT={{port}} {{name}}:dev
|
|
||||||
|
|
||||||
# Run the tests
|
|
||||||
test:
|
|
||||||
@docker exec {{name}} go test ./...
|
|
||||||
|
|
||||||
# Update dependencies
|
|
||||||
up-deps:
|
|
||||||
@go get -u ./...
|
|
||||||
|
|
||||||
# Format the code
|
|
||||||
format:
|
|
||||||
@docker exec {{name}} templ generate internal/view
|
|
||||||
@docker exec {{name}} templ fmt .
|
|
||||||
@docker exec {{name}} go fmt ./...
|
|
||||||
|
|
||||||
# Lint the code
|
|
||||||
lint:
|
|
||||||
@docker exec {{name}} golangci-lint run ./...
|
|
||||||
Loading…
Reference in a new issue