-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
106 lines (85 loc) · 3.46 KB
/
Makefile
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
.PHONY: frontend helm-update
ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
# ----------------------------------------
# Bring Localstack Up
# ----------------------------------------
compose-up:
docker compose -f docker-compose.yaml --profile local --profile metrics up
# ----------------------------------------
# Bring Localstack Down
# ----------------------------------------
compose-down:
docker compose -f docker-compose.yaml --profile local --profile metrics down
# ----------------------------------------
# Build all crates in release mode
# ----------------------------------------
release:
cargo build --release
# ----------------------------------------
# Build all crates in release mode
# ----------------------------------------
debug:
cargo build
# ----------------------------------------
# Set Git Config for Git Hooks
# ----------------------------------------
hooks:
$(shell git config --local core.hooksPath .githooks)
# ----------------------------------------
# Make docker builder
# ----------------------------------------
rust-builder:
docker build -f docker/rust/builder.Dockerfile ./docker/rust/ -t stephensampson.dev/connected-home/rust-builder:latest
# ----------------------------------------
# Make docker builder
# ----------------------------------------
cargo-build-docker:
mkdir -p ./.cargo_docker_cache
docker run -u $(id -u ${USER}):$(id -g ${USER}) \
--mount=target=/app,type=bind,source=${ROOT_DIR} \
-e CARGO_BUILD_INCREMENTAL=true \
-e SQLX_OFFLINE=true \
-e PROFILE=debug \
-e CARGO_TARGET_DIR=target/docker \
-e CARGO_HOME=/app/.cargo_docker_cache \
stephensampson.dev/connected-home/rust-builder:latest cargo build -j1 # this fails sporadically with multiple jobs on OS X
# ----------------------------------------
# Clean Rust Applications in Docker
# ----------------------------------------
cargo-clean-docker:
mkdir -p ./.cargo_docker_cache
docker run -u $(id -u ${USER}):$(id -g ${USER}) \
--mount=target=/app,type=bind,source=${ROOT_DIR} \
-e PROFILE=debug \
-e CARGO_TARGET_DIR=target/docker \
-e CARGO_HOME=/app/.cargo_docker_cache \
stephensampson.dev/connected-home/rust-builder:latest cargo clean
# ----------------------------------------
# Compile Rust Applications in Docker
# ----------------------------------------
pack-rust-docker:
docker build -f docker/rust/service.Dockerfile \
--tag stephensampson.dev/connected-home/api-gateway:latest \
--tag stephensampson.dev/connected-home/consumer:latest \
--tag stephensampson.dev/connected-home/producer:latest \
--tag stephensampson.dev/connected-home/user-service:latest \
.
# ----------------------------------------
# Run Database Migrations
# ----------------------------------------
migrations:
sqlx migrate run --source crates/user-service/migrations
# ----------------------------------------
# Validate SQLX Queries
# ----------------------------------------
sqlx-check:
cargo sqlx prepare --workspace --
# ----------------------------------------
# Generate Secrets
# ----------------------------------------
secrets:
mkdir -p .secrets
test -f ./.secrets/postgresql_username || echo 'connectedhome' > ./.secrets/postgresql_username
test -f ./.secrets/postgresql_password || echo 'connectedhome' > ./.secrets/postgresql_password
test -f ./.secrets/rabbitmq_username || echo 'connectedhome' > ./.secrets/mqtt_username
test -f ./.secrets/rabbitmq_password || echo 'connectedhome' > ./.secrets/mqtt_password