-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
43 lines (32 loc) · 932 Bytes
/
Makefile
File metadata and controls
43 lines (32 loc) · 932 Bytes
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
DATABASE_URL?=postgres://postgres:password@localhost:5432/database
HOST?=0.0.0.0
PORT?=8000
DOCKER_DB_CONTAINER_NAME:=db
DOCKER_COMPOSE:=docker-compose
DOCKER_COMPOSE_FILE:=docker-compose.yaml
# API
.PHONY: run
run:
DATABASE_URL="$(DATABASE_URL)" HOST="$(HOST)" PORT=$(PORT) cargo run
.PHONY: test
test:
DATABASE_URL="$(DATABASE_URL)" cargo test
# DB
# Start the PostgreSQL container
.PHONY: db-up
db-up:
$(DOCKER_COMPOSE) -f $(DOCKER_COMPOSE_FILE) up $(DOCKER_DB_CONTAINER_NAME) -d
# Stop and remove the PostgreSQL container
.PHONY: db-down
db-down:
$(DOCKER_COMPOSE) -f $(DOCKER_COMPOSE_FILE) down $(DOCKER_DB_CONTAINER_NAME)
.PHONY: db-migrate
db-migrate:
DATABASE_URL="$(DATABASE_URL)" diesel migration run
# Clean up the Docker volume
.PHONY: db-clean
db-clean:
$(DOCKER_COMPOSE) -f $(DOCKER_COMPOSE_FILE) down $(DOCKER_DB_CONTAINER_NAME) -v
.PHONY: test-db
test-db:
cargo test -- --ignored --test-threads=1