github.com/kubeflow/training-operator@v1.7.0/examples/pytorch/mnist/Makefile (about) 1 # Copyright 2021 The Kubeflow Authors 2 # 3 # Licensed under the Apache License, Version 2.0 (the "License"); 4 # you may not use this file except in compliance with the License. 5 # You may obtain a copy of the License at 6 # 7 # http://www.apache.org/licenses/LICENSE-2.0 8 # 9 # Unless required by applicable law or agreed to in writing, software 10 # distributed under the License is distributed on an "AS IS" BASIS, 11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 # See the License for the specific language governing permissions and 13 # limitations under the License. 14 # 15 # Requirements: 16 # https://github.com/mattrobenolt/jinja2-cli 17 # pip install jinja2-clie 18 IMG = gcr.io/kubeflow-examples/pytorch-dist-mnist 19 PUBLIC = gcr.io/kubeflow-examples/pytorch-dist-mnist 20 DIR := ${CURDIR} 21 22 # List any changed files. 23 CHANGED_FILES := $(shell git diff-files --relative=examples/dist-mnist) 24 25 ifeq ($(strip $(CHANGED_FILES)),) 26 # Changed files is empty; not dirty 27 # Don't include --dirty because it could be dirty if files outside the ones we care 28 # about changed. 29 TAG := $(shell date +v%Y%m%d)-$(shell git describe --always) 30 else 31 TAG := $(shell date +v%Y%m%d)-$(shell git describe --always --dirty)-$(shell git diff | shasum -a256 | cut -c -6) 32 endif 33 34 all: build 35 36 # To build without the cache set the environment variable 37 # export DOCKER_BUILD_OPTS=--no-cache 38 build: 39 docker build ${DOCKER_BUILD_OPTS} -t $(IMG):$(TAG) . 40 docker tag ${DOCKER_BUILD_OPTS} $(IMG):$(TAG) $(IMG):latest 41 @echo Built $(IMG):$(TAG) 42 43 # Build but don't attach the latest tag. This allows manual testing/inspection of the image 44 # first. 45 push: build 46 gcloud docker -- push $(IMG):$(TAG) 47 @echo Pushed $(IMG) with :$(TAG) tags 48 49 push-latest: push 50 gcloud container images add-tag --quiet $(IMG):$(TAG) $(IMG):latest --verbosity=info 51 echo created $(IMG):latest 52 53 push-public: push-latest 54 gcloud container images add-tag --quiet $(IMG):$(TAG) $(PUBLIC):$(TAG) --verbosity=info 55 gcloud container images add-tag --quiet $(IMG):$(TAG) $(PUBLIC):latest --verbosity=info