-
Notifications
You must be signed in to change notification settings - Fork 2
/
common.mk
58 lines (47 loc) · 1.53 KB
/
common.mk
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
# Copyright 2020 RICOS Co. Ltd.
#
# This file is a part of ricosjp/allgebra, distributed under Apache-2.0 License
# https://github.com/ricosjp/allgebra
#
PUBLIC_REGISTRY := ghcr.io/ricosjp/allgebra
CI_REGISTRY_IMAGE ?= registry.ritc.jp/ricos/allgebra
CI_COMMIT_REF_NAME ?= manual_deploy
ALLGEBRA_VERSION := 22.05.5
ALLGEBRA_TOPDIR := $(shell git rev-parse --show-toplevel)
GIT_HASH := $(shell git rev-parse HEAD)
BUILD_DATE := $(shell date --rfc-3339=ns)
#
# Following definitions assumes
#
# - $(TARGET)
# - $(HERE)
#
# are defined in parent Makefile
#
ifndef TARGET
$(error Variable "TARGET" is not set for common.mk)
endif
ifndef HERE
$(error Variable "HERE" is not set for common.mk)
endif
ESCAPED = $(subst /,-,$(TARGET))
IMAGE = $(CI_REGISTRY_IMAGE)/$(ESCAPED):$(CI_COMMIT_REF_NAME)
RELEASE_IMAGE = $(PUBLIC_REGISTRY)/$(TARGET):$(CI_COMMIT_REF_NAME)
DOCKER_BUILD_ARGS := --build-arg="REGISTRY=$(CI_REGISTRY_IMAGE)" --build-arg="TAG=$(CI_COMMIT_REF_NAME)"
build:
docker build $(DOCKER_BUILD_ARGS) -f $(HERE)/Dockerfile -t $(IMAGE) $(ALLGEBRA_TOPDIR)
in: build
docker run -it --rm -v $(ALLGEBRA_TOPDIR)/examples:/examples $(IMAGE)
in-gpu: build
docker run -it --rm --gpus=all -v $(ALLGEBRA_TOPDIR)/examples:/examples $(IMAGE)
push: build
docker push $(IMAGE)
release/build:
docker pull $(IMAGE)
docker build \
$(DOCKER_BUILD_ARGS) --build-arg="TARGET=$(ESCAPED)" \
-f $(ALLGEBRA_TOPDIR)/release.Dockerfile \
-t $(RELEASE_IMAGE) \
$(ALLGEBRA_TOPDIR)
release/push: release/build
docker push $(RELEASE_IMAGE)