|
| 1 | +# default build target |
| 2 | +all:: |
| 3 | + |
| 4 | +all:: dev |
| 5 | +.PHONY: dev remote-dev remote-fasse test release down up clean clean-remote-dev clean-remote-fasse version next-version docker-build docker-build-slurm docker-build-ood docker-push |
| 6 | + |
| 7 | +OOD_UID := $(shell id -u) |
| 8 | +OOD_GID := $(shell id -g) |
| 9 | +OOD_TAG := 2.1.0-0.rc8.el7 |
| 10 | +SLURM_TAG := slurm-21-08-6-1 |
| 11 | +REMOTE_USERNAME := $(if $(SSH_USERNAME),$(SSH_USERNAME),$(USER)) |
| 12 | +SID_SLURM_IMAGE := hmdc/sid-slurm:$(SLURM_TAG) |
| 13 | +SID_ONDEMAND_IMAGE := hmdc/sid-ood:$(SLURM_TAG)-ood-$(OOD_TAG) |
| 14 | + |
| 15 | +ENV := env SLURM_TAG=$(SLURM_TAG) SID_SLURM_IMAGE=$(SID_SLURM_IMAGE) SID_ONDEMAND_IMAGE=$(SID_ONDEMAND_IMAGE) OOD_UID=$(OOD_UID) OOD_GID=$(OOD_GID) |
| 16 | + |
| 17 | +DETACHED_MODE := $(if $(DETACHED),-d,) |
| 18 | + |
| 19 | +NODE_VERSION :=`cat ../.node-version` |
| 20 | +PWD := $(shell pwd) |
| 21 | + |
| 22 | +ifneq ($(shell git branch --show-current),stable) |
| 23 | +NPM_RUN_VERSION_ARGS := --config='.release-it-dev.json' |
| 24 | +endif |
| 25 | + |
| 26 | +TEMPLATE_LOCATION := ./application/lib/ood_core/batch_connect/templates |
| 27 | +TURBOVNC_TEMPLATE := turbovnc.rb |
| 28 | +KVM_TEMPLATE := kvm.rb |
| 29 | + |
| 30 | +remote-dev clean-remote-dev: LOGIN_HOST := login.rc.fas.harvard.edu |
| 31 | +remote-dev clean-remote-dev: APP_FOLDER := ./fasrc/dev/dashboard |
| 32 | +remote-dev: TEMPLATE_URL := https://iqss-sid.rc.fas.harvard.edu/pun/sys/dashboard/files/fs/var/www/ood/apps/sys/sid/lib/ood_core/batch_connect/templates |
| 33 | +remote-dev: CHECK_TEMPLATE_VERSION := "check_version" |
| 34 | + |
| 35 | +remote-fasse clean-remote-fasse: LOGIN_HOST := fasselogin.rc.fas.harvard.edu |
| 36 | +remote-fasse clean-remote-fasse: APP_FOLDER := ./.fasseood/dev/dashboard |
| 37 | +remote-fasse: TEMPLATE_URL := https://fasse-iqss-ood.rc.fas.harvard.edu/pun/sys/dashboard/files/fs/var/www/ood/apps/sys/sid/lib/ood_core/batch_connect/templates |
| 38 | +remote-fasse: HTTP_PROXY := http://rcproxy.rc.fas.harvard.edu:3128 |
| 39 | +remote-fasse: HTTPS_PROXY := http://rcproxy.rc.fas.harvard.edu:3128 |
| 40 | +remote-fasse: CHECK_TEMPLATE_VERSION := "" |
| 41 | + |
| 42 | +dev: down up |
| 43 | + |
| 44 | +remote-dev remote-fasse: version |
| 45 | + $(ENV) http_proxy=$(HTTP_PROXY) https_proxy=$(HTTPS_PROXY) docker-compose build |
| 46 | + @echo "You need to be connected to the VPN" |
| 47 | + ssh $(REMOTE_USERNAME)@$(LOGIN_HOST) mkdir -p $(APP_FOLDER) |
| 48 | + $(ENV) docker-compose run --no-deps --entrypoint="" ood su - ood bash -c "export PATH=/home/ood/bin:/home/ood/ondemand/dev/dashboard/node_modules/.bin:$$PATH; cd /home/ood/ondemand/dev/dashboard; scl enable rh-ruby27 rh-nodejs14 'gem install --user-install bundler -v 2.1.4 && bundle config --local path 'vendor/bundle' && bundle install && npm install yarn --save && bundle exec rake assets:precompile'" |
| 49 | + @echo "You need to be connected to the VPN" |
| 50 | + @./download_and_check.sh $(REMOTE_USERNAME) $(TEMPLATE_URL)/$(TURBOVNC_TEMPLATE) $(TEMPLATE_LOCATION)/$(TURBOVNC_TEMPLATE) $(CHECK_TEMPLATE_VERSION) |
| 51 | + @./download_and_check.sh $(REMOTE_USERNAME) $(TEMPLATE_URL)/$(KVM_TEMPLATE) $(TEMPLATE_LOCATION)/$(KVM_TEMPLATE) $(CHECK_TEMPLATE_VERSION) |
| 52 | + rsync -avz --delete --exclude-from='rsync-exclude.conf' ./application/ -e ssh $(REMOTE_USERNAME)@$(LOGIN_HOST):$(APP_FOLDER) |
| 53 | + |
| 54 | +test: |
| 55 | + $(ENV) docker-compose run --no-deps --entrypoint="" ood su - ood bash -c "export PATH=/home/ood/bin:/home/ood/ondemand/dev/dashboard/node_modules/.bin:$$PATH; cd /home/ood/ondemand/dev/dashboard; scl enable rh-ruby27 rh-nodejs14 'gem install --user-install bundler -v 2.1.4 && bundle config --local path 'vendor/bundle' && bundle install && npm install yarn --save && bundle exec rake test'" |
| 56 | + |
| 57 | +release: next-version |
| 58 | + $(ENV) docker-compose run --no-deps --entrypoint="" ood su - ood bash -c "export PATH=/home/ood/bin:/home/ood/ondemand/dev/dashboard/node_modules/.bin:$$PATH; export RAILS_ENV=production; cd /home/ood/ondemand/dev/dashboard; scl enable rh-ruby27 rh-nodejs14 'gem install --user-install bundler -v 2.1.4 && bundle config --local path 'vendor/bundle' && bundle install && npm install yarn --save && bundle exec rake assets:precompile'" |
| 59 | + mkdir -p ./target |
| 60 | + tar -czvf ./target/sid2-dashboard.tar.gz ./application |
| 61 | + |
| 62 | +down: |
| 63 | + $(ENV) docker-compose down -v || : |
| 64 | + |
| 65 | +up: |
| 66 | + $(ENV) docker-compose up --build $(DETACHED_MODE) |
| 67 | + |
| 68 | +clean: |
| 69 | + rm -rf application/.bundle application/VERSION application/log application/node_modules application/public/assets application/tmp application/vendor/bundle data/* |
| 70 | + $(ENV) docker-compose down --rmi all --volumes |
| 71 | + |
| 72 | +clean-remote-dev clean-remote-fasse: |
| 73 | + echo "For FASSE, you need to be connected to the VPN" |
| 74 | + ssh $(REMOTE_USERNAME)@$(LOGIN_HOST) rm -rfv $(APP_FOLDER) || : |
| 75 | + |
| 76 | +next-version: |
| 77 | + docker run --rm -v $(PWD)/..:/usr/app -w /usr/app node:$(NODE_VERSION) /bin/bash -c "npm install && npm run version -- $(NPM_RUN_VERSION_ARGS) | tail -n 1 > dashboard/application/VERSION" |
| 78 | + |
| 79 | +docker-build: docker-build-slurm docker-build-ood |
| 80 | + |
| 81 | +docker-push: |
| 82 | + docker push $(SID_SLURM_IMAGE) |
| 83 | + docker push $(SID_ONDEMAND_IMAGE) |
| 84 | + |
| 85 | +docker-build-slurm: |
| 86 | + docker build --build-arg SLURM_TAG=$(SLURM_TAG) -t $(SID_SLURM_IMAGE) -f docker/Dockerfile.slurm . |
| 87 | + |
| 88 | +docker-build-ood: |
| 89 | + docker build --build-arg OOD_TAG=$(OOD_TAG) --build-arg SLURM_TAG=$(SLURM_TAG) -t $(SID_ONDEMAND_IMAGE) -f docker/Dockerfile.ondemand . |
| 90 | + |
| 91 | +docker-push-ood: |
| 92 | + docker push $(SID_ONDEMAND_IMAGE) |
0 commit comments