This is an automated email from the ASF dual-hosted git repository. msciabarra pushed a commit to branch sample-builder in repository https://gitbox.apache.org/repos/asf/openserverless-task.git
commit c018d595e2df2ab846f9a231f2943634522c3e59 Author: Michele Sciabarra <[email protected]> AuthorDate: Mon Jul 21 07:47:59 2025 +0200 improved builder --- ide/python/findimg.js | 2 +- ide/python/opsfile.yml | 23 ++++++++++++++++++----- ide/util/opsfile.yml | 3 ++- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/ide/python/findimg.js b/ide/python/findimg.js index ebd3c6d..1611d70 100644 --- a/ide/python/findimg.js +++ b/ide/python/findimg.js @@ -34,7 +34,7 @@ async function main() { } const { prefix, name, tag } = runtime.image; - console.log(`${prefix}/${name}:${tag}`); + console.log(`${prefix}/${name}:${tag}|${language}_${tag}`); } main(); diff --git a/ide/python/opsfile.yml b/ide/python/opsfile.yml index 594a4bf..3d8a3d1 100644 --- a/ide/python/opsfile.yml +++ b/ide/python/opsfile.yml @@ -41,17 +41,30 @@ tasks: #sha256sum "{{.DIR}}/requirements.txt" SHA="$(sha256sum "{{.DIR}}/requirements.txt" | awk '{print substr($1, 0, 12)}')" KIND="$(awk '/--kind/ {print $2}' "{{.DIR}}/__main__.py")" - FROM="$(bun findimg.js "$KIND" "$OPS_ROOT/runtimes.json")" - cat <<EOF >"{{.DIR}}/Dockerfile" - #--docker "$DOCKER_CUSTOM_RUNTIMES:$SHA" + FROM_TAG="$(bun findimg.js "$KIND" "$OPS_ROOT/runtimes.json")" + FROM="${FROM_TAG%|*}" + TAG="${FROM_TAG#*|}.${SHA}" + #echo FROM=$FROM + #echo TAG=$TAG + if rg "$TAG" "{{.DIR}}/Dockerfile" + then echo Image already built + else + cat <<EOF >"{{.DIR}}/Dockerfile" + #--docker "$DOCKER_CUSTOM_RUNTIMES:$TAG" FROM $FROM USER root ADD requirements.txt /tmp/requirements.txt RUN pip3 install --no-cache-dir -r /tmp/requirements.txt USER nobody EOF - cat "{{.DIR}}/Dockerfile" - docker buildx build --builder "$DOCKER_BUILDER" -t "$DOCKER_CUSTOM_RUNTIMES:$SHA" "{{.DIR}}" --push + #cat "{{.DIR}}/Dockerfile" + if docker buildx build --builder "$DOCKER_BUILDER" -t "$DOCKER_CUSTOM_RUNTIMES:$SHA" "{{.DIR}}" --push + then echo Built "$DOCKER_CUSTOM_RUNTIMES:$SHA" + else rm "{{.DIR}}/Dockerfile" + fi + fi + else + echo "no requirements.txt found, skipping image build" fi sources: - "{{.DIR}}/requirements.txt" diff --git a/ide/util/opsfile.yml b/ide/util/opsfile.yml index 0176ef6..7e8e132 100644 --- a/ide/util/opsfile.yml +++ b/ide/util/opsfile.yml @@ -40,7 +40,8 @@ tasks: cmds: - | cd $OPS_PWD - DIR="$(ops -opspath "packages/{{.A}}")" + DIR="$(opspath "packages/{{.A}}")" + echo $DIR if test -e "packages/{{.A}}/__main__.py" then $OPS ide python action DIR="$DIR" elif test -e "packages/{{.A}}/index.js"
