This repository has been archived by the owner on Dec 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement makefile build infrastructure
- Loading branch information
Sameer Naik
committed
Nov 20, 2020
1 parent
aa3b33b
commit 3875dc9
Showing
2 changed files
with
57 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
REPO = knative-lambda-runtime | ||
REPO_DESC = TriggerMesh Knative Lambda Runtime | ||
RUNTIMES = java8 node-10.x node-4.x python-2.7 python-3.7 ruby-2.5 | ||
|
||
BASE_DIR ?= $(CURDIR) | ||
|
||
DOCKER ?= docker | ||
IMAGE_REPO ?= gcr.io/triggermesh | ||
IMAGE_TAG ?= latest | ||
IMAGE_SHA ?= $(shell git rev-parse HEAD) | ||
|
||
.PHONY: help images cloudbuild-test cloudbuild | ||
|
||
all: images | ||
|
||
help: ## Display this help | ||
@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) | ||
|
||
IMAGES = $(foreach r,$(RUNTIMES),$(r).image) | ||
images: $(IMAGES) ## Build the Docker images | ||
$(IMAGES): %.image: | ||
@docker build -t $(IMAGE_REPO)/knative-lambda-$$(echo "$*" | sed -n -e "s/\([[:alnum:]]*\)\(-\)*\([0-9]*\)\(\.\)*\([0-9]*\)\(\.\)*\([0-9]*\).*/\1\3\5\7/p") $* | ||
|
||
|
||
CLOUDBUILD_TEST = $(foreach r,$(RUNTIMES),$(r).cloudbuild-test) | ||
cloudbuild-test: $(CLOUDBUILD_TEST) ## Test container image build with Google Cloud Build | ||
$(CLOUDBUILD_TEST): %.cloudbuild-test: | ||
@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=_" | ||
@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=_ | ||
|
||
CLOUDBUILD = $(foreach r,$(RUNTIMES),$(r).cloudbuild) | ||
cloudbuild: $(CLOUDBUILD) ## Build and publish image to GCR | ||
$(CLOUDBUILD): %.cloudbuild: | ||
@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}" | ||
@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} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,28 @@ | ||
steps: | ||
## Build python37 runtime | ||
- name: 'gcr.io/cloud-builders/docker' | ||
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', '.' ] | ||
|
||
## Build python27 runtime | ||
- name: 'gcr.io/cloud-builders/docker' | ||
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', '.' ] | ||
- name: gcr.io/kaniko-project/executor:latest | ||
args: | ||
- --dockerfile=Dockerfile | ||
- --build-arg=VERSION=${_KANIKO_IMAGE_TAG} | ||
- --destination=gcr.io/$PROJECT_ID/${_RUNTIME}:${COMMIT_SHA} | ||
- --destination=gcr.io/$PROJECT_ID/${_RUNTIME}:${_KANIKO_IMAGE_TAG} | ||
- --cache-repo=gcr.io/$PROJECT_ID/${_RUNTIME}/cache | ||
- --cache=${_KANIKO_USE_BUILD_CACHE} | ||
- --no-push=${_KANIKO_NO_PUSH} | ||
- ${_KANIKO_EXTRA_ARGS} | ||
waitFor: ['-'] | ||
|
||
## Build node4 runtime | ||
- name: 'gcr.io/cloud-builders/docker' | ||
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', '.' ] | ||
timeout: 600s | ||
|
||
## Build node10 runtime | ||
- name: 'gcr.io/cloud-builders/docker' | ||
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', '.' ] | ||
substitutions: | ||
_RUNTIME: | ||
_KANIKO_IMAGE_TAG: latest | ||
_KANIKO_NO_PUSH: 'false' | ||
_KANIKO_USE_BUILD_CACHE: 'true' | ||
_KANIKO_EXTRA_ARGS: | ||
|
||
## Build ruby25 runtime | ||
- name: 'gcr.io/cloud-builders/docker' | ||
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', '.' ] | ||
options: | ||
substitution_option: ALLOW_LOOSE | ||
|
||
## Build java8 runtime | ||
- name: 'gcr.io/cloud-builders/docker' | ||
args: [ 'build', '-t', 'gcr.io/$PROJECT_ID/knative-lambda-java8:$REVISION_ID', '-t', 'gcr.io/$PROJECT_ID/knative-lambda-java8:latest', 'java8' ] | ||
|
||
images: | ||
- 'gcr.io/$PROJECT_ID/knative-lambda-python37' | ||
- 'gcr.io/$PROJECT_ID/knative-lambda-python27' | ||
- 'gcr.io/$PROJECT_ID/knative-lambda-node4' | ||
- 'gcr.io/$PROJECT_ID/knative-lambda-node10' | ||
- 'gcr.io/$PROJECT_ID/knative-lambda-ruby25' | ||
- 'gcr.io/$PROJECT_ID/knative-lambda-java8' | ||
tags: | ||
- knative-lambda-runtime |