forked from konstan/img-authz-plugin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
47 lines (38 loc) · 1.71 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
PLUGIN_NAME ?= sixsq/img-authz-plugin
PLUGIN_TAG ?= $(shell arch)
BUILD_DIR = PLUGIN_${PLUGIN_TAG}
REGISTRIES :=
NOTARY :=
NOTARY_ROOT_CA :=
all: clean rootfs create push
build: clean rootfs
local_install: clean rootfs create enable
clean:
@echo " - Removing the local build cache ./${BUILD_DIR}"
@rm -rf ./${BUILD_DIR}
rootfs:
@echo " - Building the rootfs Docker image"
@docker build -t ${PLUGIN_NAME}:rootfs .
@echo " - Create rootfs folder at ./${BUILD_DIR}/rootfs"
@mkdir -p ./${BUILD_DIR}/rootfs
@echo " - Initialize container from ${PLUGIN_NAME}:rootfs"
@docker create --name rootfs ${PLUGIN_NAME}:rootfs true
@echo " - Exporting container filesystem into ./${BUILD_DIR}/rootfs"
@docker export rootfs | tar -x -C ./${BUILD_DIR}/rootfs
@echo " - Copying config.json to ./${BUILD_DIR}"
@cp config.json ./${BUILD_DIR}/
@echo " - Deleting build container rootfs"
@docker rm -vf rootfs
create:
@echo " - Removing existing plugin ${PLUGIN_NAME}:${PLUGIN_TAG} if exists"
@docker plugin rm -f ${PLUGIN_NAME}:${PLUGIN_TAG} || true
@echo " - Creating new plugin ${PLUGIN_NAME}:${PLUGIN_TAG} from ./${BUILD_DIR}"
@docker plugin create ${PLUGIN_NAME}:${PLUGIN_TAG} ./${BUILD_DIR}
enable:
@echo " - Setting authz registries if any. Current value: ${REGISTRIES}"
@if [ ! -z ${REGISTRIES} ] && [ ! -z ${NOTARY} ]; then docker plugin set ${PLUGIN_NAME}:${PLUGIN_TAG} REGISTRIES=${REGISTRIES} NOTARY=${NOTARY} NOTARY_ROOT_CA=${NOTARY_ROOT_CA}; fi
@echo " - Enabling the plugin ${PLUGIN_NAME}:${PLUGIN_TAG} locally"
@docker plugin enable ${PLUGIN_NAME}:${PLUGIN_TAG}
push:
@echo " - Publishing plugin ${PLUGIN_NAME}:${PLUGIN_TAG} (make sure access to chosen registry is provided)"
@docker plugin push ${PLUGIN_NAME}:${PLUGIN_TAG}