Skip to content
This repository was archived by the owner on Dec 11, 2023. It is now read-only.

Commit 3875dc9

Browse files
author
Sameer Naik
committed
implement makefile build infrastructure
1 parent aa3b33b commit 3875dc9

File tree

2 files changed

+57
-26
lines changed

2 files changed

+57
-26
lines changed

Makefile

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
REPO = knative-lambda-runtime
2+
REPO_DESC = TriggerMesh Knative Lambda Runtime
3+
RUNTIMES = java8 node-10.x node-4.x python-2.7 python-3.7 ruby-2.5
4+
5+
BASE_DIR ?= $(CURDIR)
6+
7+
DOCKER ?= docker
8+
IMAGE_REPO ?= gcr.io/triggermesh
9+
IMAGE_TAG ?= latest
10+
IMAGE_SHA ?= $(shell git rev-parse HEAD)
11+
12+
.PHONY: help images cloudbuild-test cloudbuild
13+
14+
all: images
15+
16+
help: ## Display this help
17+
@awk 'BEGIN {FS = ":.*?## "; printf "\n$(REPO_DESC)\nUsage:\n make \033[36m<source>\033[0m\n"} /^[a-zA-Z0-9._-]+:.*?## / {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
18+
19+
IMAGES = $(foreach r,$(RUNTIMES),$(r).image)
20+
images: $(IMAGES) ## Build the Docker images
21+
$(IMAGES): %.image:
22+
@docker build -t $(IMAGE_REPO)/knative-lambda-$$(echo "$*" | sed -n -e "s/\([[:alnum:]]*\)\(-\)*\([0-9]*\)\(\.\)*\([0-9]*\)\(\.\)*\([0-9]*\).*/\1\3\5\7/p") $*
23+
24+
25+
CLOUDBUILD_TEST = $(foreach r,$(RUNTIMES),$(r).cloudbuild-test)
26+
cloudbuild-test: $(CLOUDBUILD_TEST) ## Test container image build with Google Cloud Build
27+
$(CLOUDBUILD_TEST): %.cloudbuild-test:
28+
@echo "gcloud builds submit $* --config cloudbuild.yaml --substitutions _RUNTIME=knative-lambda-$$(echo "$*" | sed -n -e "s/\([[:alnum:]]*\)\(-\)*\([0-9]*\)\(\.\)*\([0-9]*\)\(\.\)*\([0-9]*\).*/\1\3\5\7/p"),COMMIT_SHA=${IMAGE_SHA},_KANIKO_IMAGE_TAG=_"
29+
@gcloud builds submit $* --config cloudbuild.yaml --substitutions _RUNTIME=knative-lambda-$$(echo "$*" | sed -n -e "s/\([[:alnum:]]*\)\(-\)*\([0-9]*\)\(\.\)*\([0-9]*\)\(\.\)*\([0-9]*\).*/\1\3\5\7/p"),COMMIT_SHA=${IMAGE_SHA},_KANIKO_IMAGE_TAG=_
30+
31+
CLOUDBUILD = $(foreach r,$(RUNTIMES),$(r).cloudbuild)
32+
cloudbuild: $(CLOUDBUILD) ## Build and publish image to GCR
33+
$(CLOUDBUILD): %.cloudbuild:
34+
@echo "gcloud builds submit $* --config cloudbuild.yaml --substitutions _RUNTIME=knative-lambda-$$(echo "$*" | sed -n -e "s/\([[:alnum:]]*\)\(-\)*\([0-9]*\)\(\.\)*\([0-9]*\)\(\.\)*\([0-9]*\).*/\1\3\5\7/p"),COMMIT_SHA=${IMAGE_SHA},_KANIKO_IMAGE_TAG=${IMAGE_TAG}"
35+
@gcloud builds submit $* --config cloudbuild.yaml --substitutions _RUNTIME=knative-lambda-$$(echo "$*" | sed -n -e "s/\([[:alnum:]]*\)\(-\)*\([0-9]*\)\(\.\)*\([0-9]*\)\(\.\)*\([0-9]*\).*/\1\3\5\7/p"),COMMIT_SHA=${IMAGE_SHA},_KANIKO_IMAGE_TAG=${IMAGE_TAG}

cloudbuild.yaml

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,28 @@
11
steps:
2-
## Build python37 runtime
3-
- name: 'gcr.io/cloud-builders/docker'
4-
args: [ 'build', '-t', 'gcr.io/$PROJECT_ID/knative-lambda-python37:$REVISION_ID', '-t', 'gcr.io/$PROJECT_ID/knative-lambda-python37:latest', '-f' ,'./python-3.7/Dockerfile', '.' ]
52

6-
## Build python27 runtime
7-
- name: 'gcr.io/cloud-builders/docker'
8-
args: [ 'build', '-t', 'gcr.io/$PROJECT_ID/knative-lambda-python27:$REVISION_ID', '-t', 'gcr.io/$PROJECT_ID/knative-lambda-python27:latest', '-f' ,'./python-2.7/Dockerfile', '.' ]
3+
- name: gcr.io/kaniko-project/executor:latest
4+
args:
5+
- --dockerfile=Dockerfile
6+
- --build-arg=VERSION=${_KANIKO_IMAGE_TAG}
7+
- --destination=gcr.io/$PROJECT_ID/${_RUNTIME}:${COMMIT_SHA}
8+
- --destination=gcr.io/$PROJECT_ID/${_RUNTIME}:${_KANIKO_IMAGE_TAG}
9+
- --cache-repo=gcr.io/$PROJECT_ID/${_RUNTIME}/cache
10+
- --cache=${_KANIKO_USE_BUILD_CACHE}
11+
- --no-push=${_KANIKO_NO_PUSH}
12+
- ${_KANIKO_EXTRA_ARGS}
13+
waitFor: ['-']
914

10-
## Build node4 runtime
11-
- name: 'gcr.io/cloud-builders/docker'
12-
args: [ 'build', '-t', 'gcr.io/$PROJECT_ID/knative-lambda-node4:$REVISION_ID', '-t', 'gcr.io/$PROJECT_ID/knative-lambda-node4:latest', '-f' ,'./node-4.x/Dockerfile', '.' ]
15+
timeout: 600s
1316

14-
## Build node10 runtime
15-
- name: 'gcr.io/cloud-builders/docker'
16-
args: [ 'build', '-t', 'gcr.io/$PROJECT_ID/knative-lambda-node10:$REVISION_ID', '-t', 'gcr.io/$PROJECT_ID/knative-lambda-node10:latest', '-f' ,'./node-10.x/Dockerfile', '.' ]
17+
substitutions:
18+
_RUNTIME:
19+
_KANIKO_IMAGE_TAG: latest
20+
_KANIKO_NO_PUSH: 'false'
21+
_KANIKO_USE_BUILD_CACHE: 'true'
22+
_KANIKO_EXTRA_ARGS:
1723

18-
## Build ruby25 runtime
19-
- name: 'gcr.io/cloud-builders/docker'
20-
args: [ 'build', '-t', 'gcr.io/$PROJECT_ID/knative-lambda-ruby25:$REVISION_ID', '-t', 'gcr.io/$PROJECT_ID/knative-lambda-ruby25:latest', '-f' ,'./ruby-2.5/Dockerfile', '.' ]
24+
options:
25+
substitution_option: ALLOW_LOOSE
2126

22-
## Build java8 runtime
23-
- name: 'gcr.io/cloud-builders/docker'
24-
args: [ 'build', '-t', 'gcr.io/$PROJECT_ID/knative-lambda-java8:$REVISION_ID', '-t', 'gcr.io/$PROJECT_ID/knative-lambda-java8:latest', 'java8' ]
25-
26-
images:
27-
- 'gcr.io/$PROJECT_ID/knative-lambda-python37'
28-
- 'gcr.io/$PROJECT_ID/knative-lambda-python27'
29-
- 'gcr.io/$PROJECT_ID/knative-lambda-node4'
30-
- 'gcr.io/$PROJECT_ID/knative-lambda-node10'
31-
- 'gcr.io/$PROJECT_ID/knative-lambda-ruby25'
32-
- 'gcr.io/$PROJECT_ID/knative-lambda-java8'
27+
tags:
28+
- knative-lambda-runtime

0 commit comments

Comments
 (0)