-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
executable file
·122 lines (101 loc) · 3.35 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# Filename: <Makefile>
# Copyright (C) <2022> Authors: <Christian Elmo>
#
# This program is free software: you can redistribute it and / or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
path = docker
SHELL := /bin/bash
include ./.sh/config.sh
KNOWN_TARGETS = book img info
ARGS:= $(filter-out $(KNOWN_TARGETS), $(MAKECMDGOALS))
$(eval $(ARGS):;@:)
.PHONY: book img info
book: book-info
ifneq ($(filter $(ARGS), b build) ,)
@$(MAKE) book-build
endif
ifneq ($(filter $(ARGS), o open) ,)
@$(MAKE) book-open
endif
ifneq ($(filter $(ARGS), c clean) ,)
@$(MAKE) book-clean
endif
img: info
ifneq ($(filter $(ARGS), b build) ,)
@$(MAKE) img-build
endif
ifneq ($(filter $(ARGS), p push) ,)
@$(MAKE) img-push
endif
ifneq ($(filter $(ARGS), u update) ,)
@$(MAKE) img-update
endif
info:
@echo "You passed arguments are: $(ARGS)"
update: env-exp img-update
web-build:
git commit --allow-empty -m "[ci-run] Build Website authored by ${GIT_FORGE_USERNAME}"
git push origin main
book-info:
ifeq ($(ARGS),)
@echo "No arguments passed"
@echo "------Possibles arguments are:"
@echo "-> make book <build or b>"
@echo "-> make book <open or o>"
@echo "-> make book <build open or b o>"
@echo "-> make book <clean or c>"
endif
book-build:
eval "$$(conda shell.bash hook)" && \
conda activate $(CONDA_ENV) && \
jupyter-book build book
book-clean:
eval "$$(conda shell.bash hook)" && \
conda activate $(CONDA_ENV) && \
jupyter-book clean book --all
book-open:
$(BROWSER) book/_build/html/index.html
env-exp:
@echo "Exporting conda environment from \"$(CONDA_ENV)\" as YAML file" ; \
eval "$$(conda shell.bash hook)" && \
conda activate $(CONDA_ENV) && \
conda env export | sed 's/name: .*/name: base/' | sed 's/prefix: .*//' > environment.yml ; \
echo "File exporteds as \"./environment.yml\" " ; \
img-update:
@echo "Update image" ; \
$(MAKE) img-build ; \
$(MAKE) img-push
img-push:
@echo "Pushing image" ; \
docker push $(REPO_REGISTRY)/$(IMAGE_NAME):$(TAG) ; \
echo "Pushing image done"
img-build:
@echo "Building image" ; \
docker build -t $(REPO_REGISTRY)/$(IMAGE_NAME):$(TAG) . ; \
echo "Building image done"
img-pull:
docker pull $(REPO_REGISTRY)/$(IMAGE_NAME):$(TAG)
log-registry:
@echo "Please make sure that you already log this machine with your set registry"
@docker login $(DOCKER_REGISTRY_URL)
infos:
@echo "Conda parameters ========================================"
@echo "CONDA_ENV = $(CONDA_ENV)"
@echo "Git forge parameters ===================================="
@echo "GIT_FORGE_USERNAME = $(GIT_FORGE_USERNAME)"
@echo "Registry parameters ====================================="
@echo "DOCKER_REGISTRY_URL = $(DOCKER_REGISTRY_URL)"
@echo "DOCKER_REGISTRY_USERNAME = $(DOCKER_REGISTRY_USERNAME)"
@echo "IMAGE_NAME = $(IMAGE_NAME)"
@echo "TAG = $(TAG)"
@echo "Repository parameters ====================================="
@echo "REPO_REGISTRY = ${REPO_REGISTRY}"