Makefile 1.32 KB
.PHONY: start wasm build run clean

PROFILE ?= dev
ifeq "$(PROFILE)" "release"
CARGO_PROFILE = --release
WASM_PROFILE = --release
WASM_EXTRA = --no-default-features --features wee_alloc
else
CARGO_PROFILE =
WASM_PROFILE = --dev
WASM_EXTRA =
endif

define msg
	@printf "\033[38;5;197m%s\033[0m\n" "$(1)"
endef

start:
	systemfd --no-pid -s 0.0.0.0:3000 -- \
		cargo watch -i static/ -i var/ -s "PROFILE=$(PROFILE) make run"

wasm:
	$(call msg,BUILD WASM UI)
	@PROFILE=$(PROFILE) wasm-pack build $(WASM_PROFILE) -d ../static/ui \
		-t web ./ui -- $(WASM_EXTRA)

build:
	$(call msg,BUILD SERVER)
	@PROFILE=$(PROFILE) cargo build $(CARGO_PROFILE) --bin artshop-server

run: build wasm
	$(call msg,RUN SERVER)
	@PROFILE=$(PROFILE) cargo run $(CARGO_PROFILE) --bin artshop-server

release:
	docker build -t artshop -f build/Dockerfile .

devdb:
	docker network create mariadb-dev-network
	docker run --detach --network mariadb-dev-network --name mariadb-dev \
		-p 3306:3306 \
		--env MARIADB_USER=artshop \
		--env MARIADB_PASSWORD=123456 \
		--env MARIADB_ROOT_PASSWORD=123456 mariadb:latest

enterdb:
	docker exec -it mariadb-dev mysql -D artshop -u artshop -p
#	docker run -it --network mariadb-dev-network --rm mariadb:latest \
#		mysql -h mariadb-dev -u artshop -p

rootdb:
	docker exec -it mariadb-dev mysql -p

clean:
	cargo clean
	rm -Rf ./static/ui