This repository has been archived by the owner on Dec 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 84
/
Makefile
64 lines (52 loc) · 1.9 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
# IMG is the base path for images..
# Individual images will be
# $(IMG)/$(NAME):$(TAG)
IMG ?= gcr.io/code-search-demo/mlapp/base
PROJECT ?= code-search-demo
# List any changed files. We only include files in the notebooks directory.
# because that is the code in the docker image.
# In particular we exclude changes to the ksonnet configs.
CHANGED_FILES := $(shell git diff-files)
# Whether to use cached images with GCB
USE_IMAGE_CACHE ?= true
ifeq ($(strip $(CHANGED_FILES)),)
# Changed files is empty; not dirty
# Don't include --dirty because it could be dirty if files outside the ones we care
# about changed.
GIT_VERSION := $(shell git describe --always)
else
GIT_VERSION := $(shell git describe --always)-dirty-$(shell git diff | shasum -a256 | cut -c -6)
endif
CONTEXT=label-bot-frontend-prod
hydrate-prod:
rm -rf .build/prod
mkdir -p .build/prod
kustomize build -o .build/prod deployment/overlays/prod
apply-prod: hydrate-prod
kubectl --context=$(CONTEXT) apply -f .build/prod
TAG := $(shell date +v%Y%m%d)-$(GIT_VERSION)
all: build
# To build without the cache set the environment variable
# export DOCKER_BUILD_OPTS=--no-cache
.PHONY: build
build-dir: ./deployment/Dockerfile ./requirements.txt ./flask_app
rm -rf ./build
mkdir -p build
cp ./requirements.txt ./build
cp ./deployment/Dockerfile ./build
cp -r ./flask_app ./build
build: build-dir
cd build && docker build ${DOCKER_BUILD_OPTS} -t $(IMG):$(TAG) -f Dockerfile . \
--label=git-verions=$(GIT_VERSION)
docker tag $(IMG):$(TAG) $(IMG):latest
@echo Built $(IMG):latest
@echo Built $(IMG):$(TAG)
build-gcb: build-dir
gcloud builds submit --machine-type=n1-highcpu-32 --project=$(PROJECT) --tag=$(IMG):$(TAG) \
--timeout=3600 ./build
@echo Built $(IMG):$(TAG)
# Build but don't attach the latest tag. This allows manual testing/inspection of the image
# first.
push: build
docker -- push $(IMG):$(TAG)
@echo Pushed $(IMG):$(TAG)