knowyt/Makefile

92 lines
2.2 KiB
Makefile
Raw Normal View History

2021-10-01 14:40:07 +00:00
TMUX_SESSION=knowyt
2022-11-06 08:47:43 +00:00
VERSION=$(shell grep version client/package.json | cut -d\" -f4)
CONTAINER=$(shell which podman || which docker)
2021-07-29 16:39:27 +00:00
.PHONY: info setup run-all run-server run-client run-tmux build clean
2022-03-09 08:09:13 +00:00
2021-07-29 16:39:27 +00:00
info:
@echo available targets:
@perl -ne 'm/^([\w\-]+):/ && print(" $$1\n");' Makefile
2022-11-06 08:47:43 +00:00
setup:
2022-07-13 08:05:07 +00:00
@echo "I checking for tools"
@echo -n " container: " ; \
if ! [ -x "$(CONTAINER)" ]; then \
echo "neither podman nor docker found" ;\
exit 1 ;\
else \
echo "$(CONTAINER)" ;\
fi
2023-06-18 09:16:49 +00:00
@for binary in go go-bindata tmux node pnpm npx \
pexec inotifyloop inotifywait \
newuidmap slirp4netns; do \
2022-07-13 08:05:07 +00:00
echo -n " $$binary: " ; \
if ! which "$$binary"; then \
echo "not found" ;\
exit 1 ;\
fi ;\
done
@echo "I installing client dependencies"
2023-06-18 09:16:49 +00:00
( cd client && pnpm run setup )
@echo "I create client output directory"
mkdir -p client/.output/public/
@echo "I installing server dependencies"
$(MAKE) -C server setup
2022-07-13 08:05:07 +00:00
2021-07-29 16:39:27 +00:00
run-all:
pexec -R -c -e TARGET \
-r run-client \
-r run-server \
-- $(MAKE) '$$TARGET'
run-tmux:
tmux start-server
-tmux kill-session -t "$(TMUX_SESSION)"
tmux new-session -d -s "$(TMUX_SESSION)"
tmux send-keys "make run-client" C-m
tmux splitw -v -l 5
tmux send-keys "make run-server" C-m
tmux attach-session -t "$(TMUX_SESSION)"
run-client:
2023-06-18 09:16:49 +00:00
(cd client/ && pnpm dev)
2021-07-29 16:39:27 +00:00
run-server:
$(MAKE) -C server run-loop
build:
echo $(VERSION)
2023-06-18 09:16:49 +00:00
(cd client/ && pnpm run generate)
2021-07-29 16:39:27 +00:00
$(MAKE) -C server build
$(MAKE) container-build
2022-11-06 08:47:43 +00:00
container-build:
mkdir -p build/files/data
2022-11-06 14:49:05 +00:00
cp server/knowyt build/files/
$(CONTAINER) build --tag knowyt:$(VERSION) .
2022-11-06 08:47:43 +00:00
container-save:
2022-11-06 08:47:43 +00:00
rm -f build/knowyt-$(VERSION).tar
$(CONTAINER) save knowyt:$(VERSION) -o build/knowyt-$(VERSION).tar
2022-11-06 08:47:43 +00:00
ls -lh build/knowyt-$(VERSION).tar
2021-07-29 16:39:27 +00:00
container-run:
$(CONTAINER) run --rm -it -p 8080:32039 -v $$(pwd)/server/data/:/data --name knowyt knowyt:$(VERSION)
2022-03-03 09:29:01 +00:00
container-stop:
$(CONTAINER) stop knowyt
2021-08-04 23:45:31 +00:00
container-publish:
$(CONTAINER) push knowyt:$(VERSION) docker.io/settel/knowyt:$(VERSION)
$(CONTAINER) push knowyt:$(VERSION) docker.io/settel/knowyt:latest
2023-06-04 12:31:02 +00:00
2021-08-04 23:45:31 +00:00
clean:
rm -rf client/.output/
2021-08-05 00:22:28 +00:00
rm -rf client/.nuxt/
$(MAKE) -C server clean
2022-11-06 08:47:43 +00:00
rm -f build/files/knowyt build/knowyt-*.tar
2022-10-05 07:40:18 +00:00
reset-data:
rm -rf server/data/
2022-11-06 08:15:37 +00:00
git checkout server/data/