Skip to content
This repository has been archived by the owner on Dec 15, 2021. It is now read-only.

Commit

Permalink
Move ballerina compilation to a script (#831)
Browse files Browse the repository at this point in the history
* Move ballerina compilation to a script

* Compilation script
  • Loading branch information
andresmgot authored Jun 25, 2018
1 parent ee208e9 commit 25c043b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
1 change: 1 addition & 0 deletions docker/runtime/ballerina/Dockerfile.init
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ WORKDIR /kubeless

# Install controller
ADD kubeless_run.tpl.bal /ballerina/files/src/
ADD compile-function.sh /compile-function.sh

ENTRYPOINT [""]
18 changes: 18 additions & 0 deletions docker/runtime/ballerina/compile-function.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
set -e

FUNCTION=${1:?}

# TODO: Remove ballerina pull and additional copy steps in next version update

mkdir -p /kubeless/func/ ?/.ballerina/repo
cp -r /kubeless/*.bal /kubeless/func/
if [ ! -f /kubeless/kubeless.toml ]; then
touch /kubeless/kubeless.toml
fi
cp -r /ballerina/files/src/kubeless_run.tpl.bal /kubeless/
sed 's/<<FUNCTION>>/'"${FUNCTION}"'/g' /kubeless/kubeless_run.tpl.bal > /kubeless/kubeless_run.bal
rm /kubeless/kubeless_run.tpl.bal
ballerina pull kubeless/kubeless
cp -a ?/.ballerina/caches/central.ballerina.io/* ?/.ballerina/repo/
ballerina build kubeless_run.bal
4 changes: 2 additions & 2 deletions kubeless-non-rbac.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@ local runtime_images ='[
{
"name": "ballerina0.975.0",
"version": "0.975.0",
"runtimeImage": "kubeless/ballerina@sha256:e3d1159a7fe285ab206166e3397259b14a71aa39c9575da8ad400ecf7ff8054b",
"initImage": "kubeless/ballerina-init@sha256:f09c885bfdd48d481fd53eae4452fef4e7e6cb4b5221a2bbfbc4955b2a5f2f05"
"runtimeImage": "kubeless/ballerina@sha256:83e51423972f4b0d6b419bee0b4afb3bb87d2bf1b604ebc4366c430e7cc28a35",
"initImage": "kubeless/ballerina-init@sha256:05857ce439a7e290f9d86f8cb38ea3b574670c0c0e91af93af06686fa21ecf4f"
}
],
"depName": "",
Expand Down
12 changes: 1 addition & 11 deletions pkg/langruntime/langruntime.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,17 +343,7 @@ func (l *Langruntimes) GetCompilationContainer(runtime, funcName string, install
case strings.Contains(runtime, "dotnetcore"):
command = "/app/compile-function.sh " + installVolume.MountPath
case strings.Contains(runtime, "ballerina"):
//TODO: Remove ballerina pull and additional copy steps in next version update
command = fmt.Sprintf(
"mkdir -p /kubeless/func/ \\?/.ballerina/repo && "+
"cp -r /kubeless/*.bal /kubeless/func/ && "+
"touch /kubeless/kubeless.toml && "+
"cp -r /ballerina/files/src/kubeless_run.tpl.bal /kubeless/ && "+
"sed 's/<<FUNCTION>>/%s/g' /kubeless/kubeless_run.tpl.bal > /kubeless/kubeless_run.bal && "+
"rm /kubeless/kubeless_run.tpl.bal && "+
"ballerina pull kubeless/kubeless && "+
"cp -a \\?/.ballerina/caches/central.ballerina.io/* \\?/.ballerina/repo/ &&"+
"ballerina build kubeless_run.bal ", funcName)
command = fmt.Sprintf("/compile-function.sh %s", funcName)

default:
return v1.Container{}, fmt.Errorf("Not found a valid compilation step for %s", runtime)
Expand Down

0 comments on commit 25c043b

Please sign in to comment.