Files
repo-vis/Makefile
Fam Zheng f298e4a2a6
All checks were successful
Deploy to OCI / deploy (push) Successful in 51s
fix: resolve heredoc parsing error in deploy-oci Makefile target
Extract inline Dockerfile to Dockerfile.oci and scp it instead of
generating it via heredoc over SSH. Make's line-continuation backslash
was causing the heredoc delimiter to be parsed as 'DEOFnFROM' by the
remote shell, breaking the image build step.
2026-04-09 20:32:23 +00:00

60 lines
2.0 KiB
Makefile

.PHONY: build-server build-web build deploy deploy-oci clean
MUSL_TARGET_X86 := x86_64-unknown-linux-musl
MUSL_TARGET_ARM := aarch64-unknown-linux-musl
CONTAINER := repo-vis
IMAGE := repo-vis:latest
PORT := 9120
OCI_HOST := oci.euphon.net
build-server-x86:
cd server && cargo build --release --target $(MUSL_TARGET_X86)
build-server-arm:
cd server && cargo build --release --target $(MUSL_TARGET_ARM)
build-web:
cd web && npm run build
build: build-server-x86 build-web
build-arm: build-server-arm build-web
# --- Local Docker deploy (x86_64) ---
deploy: build
-docker stop $(CONTAINER) 2>/dev/null
-docker rm $(CONTAINER) 2>/dev/null
docker build --build-arg MUSL_TARGET=$(MUSL_TARGET_X86) -t $(IMAGE) .
docker run -d \
--name $(CONTAINER) \
-p $(PORT):8080 \
-v repo-vis-data:/app/data \
--restart unless-stopped \
$(IMAGE)
@echo "repo-vis running at http://localhost:$(PORT)"
# --- OCI K8s deploy (aarch64, native build on OCI) ---
OCI_TMP = /tmp/repo-vis-deploy
deploy-oci: build-arm
@echo "==> Uploading to OCI..."
ssh $(OCI_HOST) "rm -rf $(OCI_TMP) && mkdir -p $(OCI_TMP)"
scp server/target/$(MUSL_TARGET_ARM)/release/repo-vis-server $(OCI_HOST):$(OCI_TMP)/
cd web && tar czf /tmp/_rv_dist.tar.gz dist && scp /tmp/_rv_dist.tar.gz $(OCI_HOST):$(OCI_TMP)/
scp Dockerfile.oci $(OCI_HOST):$(OCI_TMP)/Dockerfile
@echo "==> Building image on OCI..."
ssh $(OCI_HOST) 'cd $(OCI_TMP) && tar xzf _rv_dist.tar.gz && \
sudo docker build -t repo-vis:latest . && \
sudo docker save repo-vis:latest -o /tmp/_rv.tar && \
sudo k3s ctr images import /tmp/_rv.tar'
@echo "==> Applying K8s manifests..."
ssh $(OCI_HOST) "kubectl apply -f -" < k8s/namespace.yaml
ssh $(OCI_HOST) "kubectl apply -f -" < k8s/pvc.yaml
ssh $(OCI_HOST) "kubectl apply -f -" < k8s/deployment.yaml
ssh $(OCI_HOST) "kubectl apply -f -" < k8s/service.yaml
ssh $(OCI_HOST) "kubectl apply -f -" < k8s/ingress.yaml
ssh $(OCI_HOST) "kubectl -n repo-vis rollout restart deployment/repo-vis"
@echo "==> Deployed to https://repo-vis.oci.euphon.net"
clean:
cd server && cargo clean
rm -rf web/dist