-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
91 lines (68 loc) · 1.85 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
# repository
SHELL = /bin/bash
NAME ?= ramoloss
ARCH ?= $(shell uname -m)
VERSION ?= $(shell git describe --tag --abbrev=0)
# docker-compose
DC := $(shell type -p docker-compose)
DC_BUILD_ARGS := --pull --force-rm
DC_RUN_ARGS := -d --no-build
DC_FILE := docker-compose.yml
# docker
#REGISTRY ?= docker.io
REGISTRY ?= ghcr.io
REPOSITORY ?= ramoloss
# image
IMAGE_bot=${NAME}-bot:${VERSION}
IMAGE_REGISTRY_bot=${REGISTRY}/${REGISTRY_USERNAME}/${IMAGE_bot}
export
all:
@echo "Usage: NAME=ramoloss make deploy | build | \
up | down | test | check | push | pull "
# check var or config
check-var-%:
@: $(if $(value $*),,$(error $* is undefined))
@echo ${$*}
check-config:
${DC} -f ${DC_FILE} config
check-config-quiet:
${DC} -f ${DC_FILE} config -q
# build all or one service
build: check-config-quiet
echo ${VERSION}
${DC} -f ${DC_FILE} build ${DC_BUILD_ARGS}
build-%:
@echo "# start $*"
${DC} -f ${DC_FILE} build ${DC_BUILD_ARGS} $*
# up all or one service
up: check-config-quiet
@if [ -z "${DISCORD_TOKEN}" ] ; \
then echo "ERROR: DISCORD_TOKEN \
not defined" ; exit 1 ; fi
${DC} -f ${DC_FILE} up ${DC_RUN_ARGS}
up-%: check-config-quiet
${DC} -f ${DC_FILE} up ${DC_RUN_ARGS} $*
# down all or one service
down:
${DC} -f ${DC_FILE} down
down-%:
${DC} -f ${DC_FILE} down $*
# test
test: test-container
test-%:
@echo "# test $*"
bash tests/test-$*.sh
# push
push: push-bot
push-%:
@if [ -z "${REGISTRY}" -a -z "${REGISTRY_USERNAME}" ] ; \
then echo "ERROR: REGISTRY and REGISTRY_USERNAME \
not defined" ; exit 1 ; fi
docker tag ${IMAGE_$*} ${IMAGE_REGISTRY_$*}
docker push ${IMAGE_REGISTRY_$*}
pull: pull-bot
pull-%:
@if [ -n "${REGISTRY_TOKEN}" -a -n "${REGISTRY_LOGIN}" ] ;\
then echo ${REGISTRY_TOKEN} | docker login ${REGISTRY} \
--username ${REGISTRY_LOGIN} --password-stdin ; fi
docker pull ${REGISTRY}/${REGISTRY_LOGIN}/${NAME}-$*:latest