1
|
-.PHONY: start wasm build run clean
|
|
|
2
|
-
|
|
|
3
|
PROFILE ?= dev
|
1
|
PROFILE ?= dev
|
4
|
ifeq "$(PROFILE)" "release"
|
2
|
ifeq "$(PROFILE)" "release"
|
5
|
CARGO_PROFILE = --release
|
3
|
CARGO_PROFILE = --release
|
6
|
WASM_PROFILE = --release
|
4
|
WASM_PROFILE = --release
|
7
|
WASM_EXTRA = --no-default-features --features wee_alloc
|
5
|
WASM_EXTRA = --no-default-features --features wee_alloc
|
|
|
6
|
+SERVER_TARGET = target/release/artshop-server
|
|
|
7
|
+WASM_TARGET = ui/target/wasm32-unknown-unknown/release/artshop_frontend.wasm
|
8
|
else
|
8
|
else
|
9
|
CARGO_PROFILE =
|
9
|
CARGO_PROFILE =
|
10
|
WASM_PROFILE = --dev
|
10
|
WASM_PROFILE = --dev
|
11
|
WASM_EXTRA =
|
11
|
WASM_EXTRA =
|
|
|
12
|
+SERVER_TARGET = target/debug/artshop-server
|
|
|
13
|
+WASM_TARGET = ui/target/wasm32-unknown-unknown/debug/artshop_frontend.wasm
|
12
|
endif
|
14
|
endif
|
13
|
|
15
|
|
|
|
16
|
+SERVER_SOURCES = common/Cargo.toml \
|
|
|
17
|
+ server/Cargo.toml \
|
|
|
18
|
+ $(shell find common -name "*.rs") \
|
|
|
19
|
+ $(shell find server -name "*.rs")
|
|
|
20
|
+WASM_DEPLOY = static/ui/artshop_frontend_bg.wasm
|
|
|
21
|
+WASM_SOURCES = common/Cargo.toml \
|
|
|
22
|
+ ui/Cargo.toml \
|
|
|
23
|
+ $(shell find common -name "*.rs") \
|
|
|
24
|
+ $(shell find ui -name "*.rs")
|
|
|
25
|
+
|
14
|
define msg
|
26
|
define msg
|
|
|
27
|
+ @printf "\033[38;5;197m%s\033[0m" "$(1)"
|
|
|
28
|
+endef
|
|
|
29
|
+
|
|
|
30
|
+define msgnl
|
15
|
@printf "\033[38;5;197m%s\033[0m\n" "$(1)"
|
31
|
@printf "\033[38;5;197m%s\033[0m\n" "$(1)"
|
16
|
endef
|
32
|
endef
|
17
|
|
33
|
|
|
|
34
|
+.PHONY: start run wasm build clean release
|
|
|
35
|
+
|
18
|
start:
|
36
|
start:
|
19
|
- systemfd --no-pid -s 0.0.0.0:3000 -- \
|
|
|
20
|
- cargo watch -i static/ -i var/ -s "PROFILE=$(PROFILE) make run"
|
37
|
+ $(call msgnl,NOTIFY REBUILD RUN)
|
|
|
38
|
+ @systemfd --no-pid -s 0.0.0.0:3000 -- \
|
|
|
39
|
+ cargo watch -i static/ -i var/ \
|
|
|
40
|
+ -s "PROFILE=$(PROFILE) make run"
|
|
|
41
|
+
|
|
|
42
|
+run: build wasm
|
|
|
43
|
+ $(call msgnl,RUN SERVER)
|
|
|
44
|
+ @PROFILE=$(PROFILE) cargo run $(CARGO_PROFILE) --bin artshop-server
|
|
|
45
|
+
|
|
|
46
|
+wasm: $(WASM_DEPLOY)
|
|
|
47
|
+
|
|
|
48
|
+build: $(SERVER_TARGET)
|
|
|
49
|
+
|
|
|
50
|
+clean:
|
|
|
51
|
+ $(call msgnl,CLEAN WORKSPACE)
|
|
|
52
|
+ @PROFILE=$(PROFILE) cargo clean
|
|
|
53
|
+ $(call msgnl,CLEAN INSTALLED WASM)
|
|
|
54
|
+ @rm -Rf ./static/ui
|
|
|
55
|
+ $(call msgnl,CLEAN INSTALLED WASM)
|
|
|
56
|
+ @pushd ui; PROFILE=$(PROFILE) cargo clean; popd
|
|
|
57
|
+
|
|
|
58
|
+$(WASM_TARGET): $(WASM_SOURCES)
|
|
|
59
|
+ $(call msgnl,BUILD WASM UI)
|
|
|
60
|
+ @PROFILE=$(PROFILE) wasm-pack build $(WASM_PROFILE) -d ../static/ui \
|
|
|
61
|
+ -t web --mode no-install ./ui -- $(WASM_EXTRA)
|
21
|
|
62
|
|
22
|
-wasm:
|
|
|
23
|
- $(call msg,BUILD WASM UI)
|
63
|
+$(WASM_DEPLOY): $(WASM_TARGET)
|
|
|
64
|
+ $(call msgnl,INSTALL WASM UI)
|
24
|
@PROFILE=$(PROFILE) wasm-pack build $(WASM_PROFILE) -d ../static/ui \
|
65
|
@PROFILE=$(PROFILE) wasm-pack build $(WASM_PROFILE) -d ../static/ui \
|
25
|
-t web ./ui -- $(WASM_EXTRA)
|
66
|
-t web ./ui -- $(WASM_EXTRA)
|
26
|
|
67
|
|
27
|
-build:
|
|
|
28
|
- $(call msg,PATCH DIFFY)
|
|
|
29
|
- @cargo patch
|
|
|
30
|
- $(call msg,BUILD SERVER)
|
68
|
+$(SERVER_TARGET): $(SERVER_SOURCES)
|
|
|
69
|
+ $(call msgnl,PATCH DIFFY)
|
|
|
70
|
+ @PROFILE=$(PROFILE) cargo patch
|
|
|
71
|
+ $(call msgnl,BUILD SERVER)
|
31
|
@PROFILE=$(PROFILE) cargo build $(CARGO_PROFILE) --bin artshop-server
|
72
|
@PROFILE=$(PROFILE) cargo build $(CARGO_PROFILE) --bin artshop-server
|
32
|
|
73
|
|
33
|
-run: build wasm
|
|
|
34
|
- $(call msg,RUN SERVER)
|
|
|
35
|
- @PROFILE=$(PROFILE) cargo run $(CARGO_PROFILE) --bin artshop-server
|
|
|
36
|
-
|
|
|
37
|
release:
|
74
|
release:
|
38
|
docker build -t artshop -f build/Dockerfile .
|
75
|
docker build -t artshop -f build/Dockerfile .
|
39
|
|
76
|
|
|
|
77
|
+.PHONY: createdb devdb downdb enterdb rootdb
|
|
|
78
|
+
|
|
|
79
|
+createdb: downdb devdb
|
|
|
80
|
+ $(call msg,TRY TO CONNECT TO DB )
|
|
|
81
|
+ @while true;\
|
|
|
82
|
+ do\
|
|
|
83
|
+ echo "SELECT VERSION();"|\
|
|
|
84
|
+ docker exec -i mariadb-dev \
|
|
|
85
|
+ mysql -p123456 >/dev/null 2>&1 && break;\
|
|
|
86
|
+ echo -n ".";\
|
|
|
87
|
+ sleep 3;\
|
|
|
88
|
+ done; echo
|
|
|
89
|
+ $(call msgnl,INITIALIZE APPLICATION DB)
|
|
|
90
|
+ echo "CREATE DATABASE artshop CHARACTER SET = 'utf8mb3' \
|
|
|
91
|
+ COLLATE = 'utf8mb3_general_ci'; \
|
|
|
92
|
+ GRANT ALL PRIVILEGES ON artshop.* TO 'artshop'@'%'"|\
|
|
|
93
|
+ docker exec -i mariadb-dev mysql -p123456
|
|
|
94
|
+ $(call msgnl,RUN MIGRATIONS)
|
|
|
95
|
+ @diesel migration run
|
|
|
96
|
+
|
|
|
97
|
+downdb:
|
|
|
98
|
+ $(call msgnl,STOP DB CONTAINER)
|
|
|
99
|
+ @docker stop mariadb-dev||true
|
|
|
100
|
+ $(call msgnl,REMOVE DB CONTAINER)
|
|
|
101
|
+ @docker rm -v mariadb-dev||true
|
|
|
102
|
+
|
40
|
devdb:
|
103
|
devdb:
|
41
|
- docker network create mariadb-dev-network
|
|
|
42
|
- docker run --detach --network mariadb-dev-network --name mariadb-dev \
|
104
|
+ $(call msgnl,CREATE DB CONTAINER)
|
|
|
105
|
+ @docker run --detach --name mariadb-dev \
|
43
|
-p 3306:3306 \
|
106
|
-p 3306:3306 \
|
44
|
--env MARIADB_USER=artshop \
|
107
|
--env MARIADB_USER=artshop \
|
45
|
--env MARIADB_PASSWORD=123456 \
|
108
|
--env MARIADB_PASSWORD=123456 \
|
46
|
--env MARIADB_ROOT_PASSWORD=123456 mariadb:latest
|
109
|
--env MARIADB_ROOT_PASSWORD=123456 mariadb:latest
|
47
|
|
110
|
|
48
|
enterdb:
|
111
|
enterdb:
|
49
|
- docker exec -it mariadb-dev mysql -D artshop -u artshop -p
|
112
|
+ docker exec -it mariadb-dev mysql -D artshop -u artshop -p123456||true
|
50
|
# docker run -it --network mariadb-dev-network --rm mariadb:latest \
|
113
|
# docker run -it --network mariadb-dev-network --rm mariadb:latest \
|
51
|
# mysql -h mariadb-dev -u artshop -p
|
114
|
# mysql -h mariadb-dev -u artshop -p
|
52
|
|
115
|
|
53
|
rootdb:
|
116
|
rootdb:
|
54
|
- docker exec -it mariadb-dev mysql -p
|
|
|
55
|
-
|
|
|
56
|
-clean:
|
|
|
57
|
- cargo clean
|
|
|
58
|
- rm -Rf ./static/ui |
117
|
+ docker exec -it mariadb-dev mysql -p123456||true |