-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
66 lines (48 loc) · 1.87 KB
/
Makefile
File metadata and controls
66 lines (48 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
.PHONY: help build run test clean install dev
# Variables
IMAGE_NAME ?= postgres-backup-s3
IMAGE_TAG ?= latest
DOCKER_USER ?= johnnybui
help: ## Show this help message
@echo 'Usage: make [target]'
@echo ''
@echo 'Available targets:'
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " %-20s %s\n", $$1, $$2}'
install: ## Install dependencies
bun install
dev: ## Run in development mode
bun run src/index.ts
build: ## Build Docker image
docker build -f Dockerfile -t $(DOCKER_USER)/$(IMAGE_NAME):$(IMAGE_TAG) .
build-local: ## Build local binary
bun build src/index.ts --compile --outfile postgres-backup
test-backup: ## Test one-time backup (requires env vars)
docker compose -f docker-compose.example.yml run --rm postgres-backup
test-restore: ## Test restore (requires BACKUP_FILE env var)
@if [ -z "$(BACKUP_FILE)" ]; then \
echo "Error: BACKUP_FILE is required. Usage: make test-restore BACKUP_FILE=postgres/db_2025-10-06.sql.gz"; \
exit 1; \
fi
docker compose -f docker-compose.example.yml run --rm \
-e BACKUP_FILE=$(BACKUP_FILE) \
postgres-backup
list-backups: ## List available backups in S3
docker compose -f docker-compose.example.yml run --rm postgres-backup \
sh -c 'aws $$AWS_ARGS s3 ls s3://$$S3_BUCKET/$$S3_PREFIX/'
push: ## Push Docker image to registry
docker push $(DOCKER_USER)/$(IMAGE_NAME):$(IMAGE_TAG)
run: ## Run with docker compose
docker compose -f docker-compose.example.yml up -d
stop: ## Stop docker compose
docker compose -f docker-compose.example.yml down
logs: ## Show logs
docker compose -f docker-compose.example.yml logs -f postgres-backup
clean: ## Clean build artifacts
rm -f postgres-backup
rm -rf node_modules
docker compose -f docker-compose.example.yml down -v
format: ## Format code
bun x prettier --write "src/**/*.ts"
lint: ## Lint code
bun x tsc --noEmit
.DEFAULT_GOAL := help