Move deployment to Makefile
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 4e6cfb5..f433e17 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -118,16 +118,6 @@
- ssh-add $SSH_PRIVATE_KEY
- end_section setup_ssh
script:
- - start_section korapxmlu "Uploading Krill to KorAP instance dnb"
- - if [ $(ls target/*.krill.tar | wc -l) -lt 1 ]; then echo 'error - less than 1 Krill files found'; false; fi
- - rm -rf json && mkdir -p json
- - for f in target/*.krill.tar; do tar -C json -xf $f; done
- - rsync -e "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" -avz --delete json korap@$DEPLOY_SERVER:/opt/korap/instance-dnb/
- - end_section korapxmlu
- - start_section korapxmlr "Indexing data & restarting KorAP instance dnb"
- - ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null korap@$DEPLOY_SERVER "cd /opt/korap/instance-dnb/ &&
- rm -rf index && mkdir -p index &&
- docker run -u root --rm -v /opt/korap/instance-dnb:/data:z korap/kustvakt:latest-full Krill-Indexer.jar -c /kustvakt/kustvakt.conf -i /data/json -o /data/index/ && INDEX=./index docker-compose --profile=full -p kyc-ger restart"
- - end_section korapxmlr
- - echo "Deploying $VID"
+ - start_section korapxmlu "Uploading index to KorAP4DNB instance"
+ - make deploy
- end_section deploy
diff --git a/Makefile b/Makefile
index 0d548d4..9198048 100644
--- a/Makefile
+++ b/Makefile
@@ -1,11 +1,16 @@
SRC_DIR ?= test/resources/DNB
BUILD_DIR = build
TARGET_DIR ?= target
+DEPLOY_HOST ?= compute.ids-mannheim.de
+DEPLOY_USER ?= korap
+DEPLOY_PATH ?= /export/netapp/korap4dnb
-.PHONY: all clean test krill index
+.PHONY: all clean test krill index deploy server-log server-status
.PRECIOUS: %.zip %.tree_tagger.zip %.ud.zip %.spacy.zip %.i5.xml %.tar
+.DELETE_ON_ERROR:
+
all: index
krill: $(TARGET_DIR)/dnb.krill.tar
@@ -59,6 +64,16 @@
%.index.tar.xz: %.index
tar -I 'xz -T0' -C $(dir $<) -cf $@ $(notdir $<)
+deploy: $(TARGET_DIR)/dnb.index.tar.xz korap4dnb-compose.yml
+ rsync -v $^ $(DEPLOY_USER)@$(DEPLOY_HOST):$(DEPLOY_PATH)/
+ ssh $(DEPLOY_USER)@$(DEPLOY_HOST) "mkdir -p $(DEPLOY_PATH) && cd $(DEPLOY_PATH) && docker compose -p korap4dnb --profile=lite -f $(notdir $(word 2,$^)) up -d --dry-run && docker compose -p korap4dnb stop && (mv -f dnb.index dnb.index.bak || true) && tar Jxvf $(notdir $<) && docker compose -p korap4dnb --profile=lite -f $(notdir $(word 2,$^)) up -d"
+
+show-server-log:
+ ssh $(DEPLOY_USER)@$(DEPLOY_HOST) "cd $(DEPLOY_PATH) && docker compose -p korap4dnb --profile=lite -f korap4dnb-compose.yml logs -f"
+
+show-server-status:
+ ssh $(DEPLOY_USER)@$(DEPLOY_HOST) "cd $(DEPLOY_PATH) && docker compose -p korap4dnb --profile=lite -f korap4dnb-compose.yml ps"
+
clean:
rm -rf $(BUILD_DIR) $(TARGET_DIR)
diff --git a/Readme.md b/Readme.md
index d329d43..766982f 100644
--- a/Readme.md
+++ b/Readme.md
@@ -42,6 +42,10 @@
## News
+* 2024-03-18
+ * added `make deploy` to install new index and restart local KorAP@DNB instance (also available as ci target)
+ * added `show-server-logs` and `show-server-status` make targets to monitor the local KorAP@DNB instance
+
* 2024-03-17
* added `make all` to build all targets, including the index
diff --git a/korap4dnb-compose.yml b/korap4dnb-compose.yml
new file mode 100644
index 0000000..0d5883d
--- /dev/null
+++ b/korap4dnb-compose.yml
@@ -0,0 +1,77 @@
+version: '3.8'
+volumes:
+ example-index:
+services:
+ kalamar:
+ image: "korap/kalamar:dnb"
+ ports:
+ - "64543:64543"
+ environment:
+ KALAMAR_API: "http://kustvakt:8089/api/"
+ depends_on:
+ - kustvakt
+ profiles:
+ - lite
+ restart: "unless-stopped"
+ full-init:
+ image: "korap/kalamar:latest-conv"
+ command: super_client_info kalamar /kalamar/data/super_client_info
+ volumes:
+ - type: bind
+ source: "${PWD}/data/"
+ target: "/kalamar/data"
+ profiles:
+ - full
+ - init
+ user: root
+ restart: "no"
+ kalamar-full:
+ image: "korap/kalamar:latest-conv"
+ ports:
+ - "64543:64543"
+ environment:
+ KALAMAR_API: "http://kustvakt-full:8089/api/"
+ volumes:
+ - type: bind
+ source: "${PWD}/data/kalamar.production.conf"
+ target: "/kalamar/kalamar.production.conf"
+ - type: bind
+ source: "${PWD}/data/super_client_info"
+ target: /kalamar/super_client_info
+ depends_on:
+ kustvakt-full:
+ condition: service_started
+ full-init:
+ condition: service_completed_successfully
+ profiles:
+ - full
+ restart: "unless-stopped"
+ user: root
+ kustvakt:
+ image: "korap/kustvakt:latest"
+ expose:
+ - 8089
+ volumes:
+ - "${PWD}/dnb.index:/kustvakt/index:z"
+ profiles:
+ - lite
+ restart: "unless-stopped"
+ kustvakt-full:
+ image: "korap/kustvakt:latest-full"
+ expose:
+ - 8089
+ user: root
+ volumes:
+ - "${PWD}/dnb.index:/kustvakt/index:z"
+ - type: bind
+ source: "${PWD}/data/"
+ target: /kustvakt/data/
+ profiles:
+ - full
+ depends_on:
+ full-init:
+ condition: service_completed_successfully
+ restart: "unless-stopped"
+configs:
+ super_client_info:
+ external: true