forked from libis/rdm-integration
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
97 lines (84 loc) · 3.82 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# Author: Eryk Kulikowski @ KU Leuven (2023). Apache 2.0 License
STAGE ?= dev
BUILD_BASE_HREF ?= /integration/
include env.$(STAGE)
include .env
export
.SILENT:
SHELL = /bin/bash
# Set USER_ID and GROUP_ID to current user's uid and gid if not set
USER_ID ?= $(shell id -u)
GROUP_ID ?= $(shell id -g)
build: fmt staticcheck ## Build Docker image
docker build \
--build-arg USER_ID=$(USER_ID) --build-arg GROUP_ID=$(GROUP_ID) \
--build-arg OAUTH2_POXY_VERSION=$(OAUTH2_POXY_VERSION) --build-arg NODE_VERSION=$(NODE_VERSION) \
--build-arg FRONTEND_VERSION=$(FRONTEND_VERSION) --build-arg NODE_ENV=$(NODE_ENV) \
--build-arg BASE_HREF=$(BUILD_BASE_HREF) --build-arg CUSTOMIZATIONS=$(CUSTOMIZATIONS) \
--tag "$(IMAGE_TAG)" ./image
push: ## Push Docker image (only in prod stage)
if [ "$(STAGE)" = "prod" ]; then \
echo "Pushing Docker image to repository ..."; \
docker push $(IMAGE_TAG); \
else \
echo "Not in production stage. Pushing not allowed."; \
fi
init: ## initialize docker volumes before running the server locally
docker compose -f docker-compose.yml down || true
rm -rf docker-volumes
mkdir -p docker-volumes/cache/data
mkdir -p docker-volumes/dataverse/data/docroot
mkdir -p docker-volumes/dataverse/data/temp
mkdir -p docker-volumes/dataverse/data/uploads
mkdir -p docker-volumes/dataverse/data/exporters
mkdir -p docker-volumes/dataverse/secrets/api
mkdir -p docker-volumes/dataverse/conf
mkdir -p docker-volumes/integration/aws
mkdir -p docker-volumes/integration/conf
mkdir -p docker-volumes/integration/data
mkdir -p docker-volumes/solr/conf
mkdir -p docker-volumes/solr/data
mkdir -p docker-volumes/postgresql/data
mkdir -p docker-volumes/keycloak/conf
mkdir -p docker-volumes/localstack/conf
mkdir -p docker-volumes/localstack/data
mkdir -p docker-volumes/minio/data/mybucket
echo -n 'secret-admin-password' > docker-volumes/dataverse/secrets/password
echo -n 'secret-unblock-key' > docker-volumes/dataverse/secrets/api/key
echo AWS_ACCESS_KEY_ID=4cc355_k3y > docker-volumes/integration/aws/aws.env
echo -n AWS_SECRET_ACCESS_KEY=s3cr3t_4cc355_k3y >> docker-volumes/integration/aws/aws.env
cp -R conf/dataverse/* docker-volumes/dataverse/conf
cp -R conf/customizations docker-volumes/integration/conf/customizations
cp -R conf/solr/* docker-volumes/solr/conf
cp conf/backend_config.json docker-volumes/integration/conf/backend_config.json
cp conf/frontend_config.json docker-volumes/integration/conf/frontend_config.json
cp conf/example_oauth_secrets.json docker-volumes/integration/data/example_oauth_secrets.json
cp conf/oauth2-proxy.cfg docker-volumes/integration/conf/oauth2-proxy.cfg
cp conf/localstack/buckets.sh docker-volumes/localstack/conf/buckets.sh
cp conf/keycloak/test-realm.json docker-volumes/keycloak/conf/test-realm.json
docker compose -f docker-compose.yml up -d --build
@echo -n "Waiting for Dataverse initialized "
@while [ ! -f docker-volumes/dataverse/data/initialized ]; do \
[[ $$? -gt 0 ]] && echo -n 'x' || echo -n '.'; sleep 1; done && true
@echo ' OK.'
docker compose -f docker-compose.yml down
clean: ## delete docker volumes
rm -rf docker-volumes
up: ## Run the server locally
if [ ! -f docker-volumes/dataverse/data/initialized ]; then \
$(MAKE) init; \
fi
docker compose -f docker-compose.yml up -d --build
@echo -n "Waiting for Dataverse ready "
@while [ "$$(curl -sk -m 1 -I http://localhost:8080/api/info/version | head -n 1 | cut -d$$' ' -f2)" != "200" ]; do \
[[ $$? -gt 0 ]] && echo -n 'x' || echo -n '.'; sleep 1; done && true
@echo ' OK.'
down: ## Stop the server locally
docker compose -f docker-compose.yml down
fmt: ## Format the go code
cd image && go fmt ./app/...
staticcheck: ## staticcheck the go code
cd image && ~/go/bin/staticcheck ./app/...
upgrade_dependencies: ## upgrade all go dependencies
cd image && go get -u ./app/...
cd image && go mod tidy