-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.docker
112 lines (84 loc) · 3.62 KB
/
Makefile.docker
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# Requires (on Ubuntu):
# - apt:docker-compose-v2
# - apt:docker-buildx
export COMPOSE_PROJECT_NAME=biobricks-okg
# NOTE Always make `docker-graph-volumes.json` as this can vary due to symlinks
# outside of the repository.
.PHONY: \
docker-build \
docker-graph-volumes.json \
docker-compose-up docker-compose-down \
docker-compose-logs \
docker-compose-exec-db-virtuoso \
docker-compose-exec-db-virtuoso-load-rdf-data \
docker-compose-exec-db-virtuoso-isql-load-list #
DOCKER_COMPOSE_CONFIG_FILES := docker-compose.yml docker-graph-volumes.json
DOCKER_COMPOSE_CONFIG_ARGS := $(foreach F,$(DOCKER_COMPOSE_CONFIG_FILES),-f $F)
define DOCKER_MESSAGE
# Docker
## Build
- docker-build : build Docker image
## Docker Compose
### Service
- docker-compose-up : start Docker Compose (in background)
- docker-compose-down : stop Docker Compose
- docker-compose-logs : show logs of Docker Compose
### Exec
- docker-compose-exec-db-virtuoso : start bash inside of `db-virtuoso`
- docker-compose-exec-db-virtuoso-load-rdf-data : load RDF data from `/data` mount
- docker-compose-exec-db-virtuoso-isql-load-list : show the current load list (status of loading)
# Variables
- DB_VIRTUOSO_PATH : directory for top-level of database storage (required for docker targets)
(set to: ${DB_VIRTUOSO_PATH})
endef
MESSAGE += $(DOCKER_MESSAGE)
docker-graph-volumes.json: graphs.yaml \
bin-guard-cpanel_json_xs \
bin-guard-jq \
bin-guard-sort \
bin-guard-xargs \
bin-guard-sponge
cpanel_json_xs -f yaml < graphs.yaml \
| jq 'map(.path)|.[]' \
| sort \
| xargs ./bin/docker-rec-file-mapper /data \
| jq '{ services: { "db-virtuoso": { "volumes": . } } }' \
| sponge docker-graph-volumes.json
docker-build:
docker buildx bake -f docker-bake.hcl
docker-test:
docker buildx bake -f docker-bake.hcl --progress plain db-virtuoso-deploy-tester
docker-compose-up: env-guard-DB_VIRTUOSO_PATH docker-build $(DOCKER_COMPOSE_CONFIG_FILES)
[ -n "${DB_VIRTUOSO_PATH}" ] || ( echo "Must set DB_VIRTUOSO_PATH" && exit 1 )
[ -f "${DB_VIRTUOSO_PATH}/database/virtuoso.ini" ] || $(ECHO) -n '' > "${ROOT_DIR}/db-virtuoso/initdb.d/11-load-datasets.output.sql"
$(MKDIR_P) "${DB_VIRTUOSO_PATH}/database"
$(MKDIR_P) "${DB_VIRTUOSO_PATH}/data"
docker compose \
$(DOCKER_COMPOSE_CONFIG_ARGS) \
up -d
docker-compose-down: env-guard-DB_VIRTUOSO_PATH $(DOCKER_COMPOSE_CONFIG_FILES)
docker compose \
$(DOCKER_COMPOSE_CONFIG_ARGS) \
down
docker-compose-logs: env-guard-DB_VIRTUOSO_PATH $(DOCKER_COMPOSE_CONFIG_FILES)
docker compose \
$(DOCKER_COMPOSE_CONFIG_ARGS) \
logs -f
docker-compose-exec-db-virtuoso: env-guard-DB_VIRTUOSO_PATH $(DOCKER_COMPOSE_CONFIG_FILES)
docker compose \
$(DOCKER_COMPOSE_CONFIG_ARGS) \
exec db-virtuoso bash
docker-compose-exec-db-virtuoso-load-rdf-data-noninteractive: env-guard-DB_VIRTUOSO_PATH $(DOCKER_COMPOSE_CONFIG_FILES)
docker compose \
$(DOCKER_COMPOSE_CONFIG_ARGS) \
exec db-virtuoso bash -c '/script/load-rdf-dir /data > /tmp/load-rdf-dir.sql; isql "exec=LOAD /tmp/load-rdf-dir.sql"'
docker-compose-exec-db-virtuoso-load-rdf-data: env-guard-DB_VIRTUOSO_PATH $(DOCKER_COMPOSE_CONFIG_FILES)
docker compose \
$(DOCKER_COMPOSE_CONFIG_ARGS) \
exec --tty --interactive db-virtuoso bash -ic '/script/load-rdf-dir /data'
docker-compose-exec-db-virtuoso-isql-load-list: env-guard-DB_VIRTUOSO_PATH $(DOCKER_COMPOSE_CONFIG_FILES)
docker compose \
$(DOCKER_COMPOSE_CONFIG_ARGS) \
exec db-virtuoso isql 'exec=SELECT * FROM DB.DBA.load_list;'
clean::
$(RM) docker-graph-volumes.json