From dde805d7f3a20a2f503542b54f21aa47e33c11a9 Mon Sep 17 00:00:00 2001
From: Staffan Olsson <staffan@repos.se>
Date: Thu, 28 Nov 2024 13:14:44 +0100
Subject: [PATCH] ystack's y-deno is unmaintained so build runtime from
 official

deno distroless image instead
---
 .github/workflows/images.yaml   | 45 ++++++++++++++++++++++++++++++++-
 runtime-deno/Dockerfile         | 14 +++-------
 runtime-quarkus-deno/Dockerfile |  8 +++---
 test.sh                         |  2 ++
 4 files changed, 53 insertions(+), 16 deletions(-)

diff --git a/.github/workflows/images.yaml b/.github/workflows/images.yaml
index acf9734..6629c85 100644
--- a/.github/workflows/images.yaml
+++ b/.github/workflows/images.yaml
@@ -53,7 +53,6 @@ jobs:
         crane cp curlimages/curl:$TAG_CURL ghcr.io/yolean/curl:$TAG_CURL
         crane cp busybox:$TAG_BUSYBOX ghcr.io/yolean/busybox:$TAG_BUSYBOX
         crane cp mailgun/kafka-pixy:0.17.0@sha256:0b5f4795c0b0d80729fa7415ec70ae4d411e152c6149656dddf01b18184792e0 ghcr.io/yolean/kafka-pixy:0.17.0
-        crane cp docker.io/yolean/runtime-deno:2c6e176109a4cb1850cb7f8fa56411d370e3f705@sha256:5aeb0b9191bb8c0f1f4b46fb4e9a03857d5b78007a1b960dcced9404dd368bc9 ghcr.io/yolean/runtime-deno:2c6e176109a4cb1850cb7f8fa56411d370e3f705
         crane cp tinygo/tinygo:$TAG_TINYGO ghcr.io/yolean/tinygo:$TAG_TINYGO
     -
       name: Set up QEMU
@@ -291,6 +290,20 @@ jobs:
         push: true
         cache-from: type=gha
         cache-to: type=gha,mode=max
+    -
+      name: Build and push runtime-deno latest
+      uses: docker/build-push-action@v5
+      env:
+        SOURCE_DATE_EPOCH: 0
+      with:
+        context: runtime-deno
+        tags: |
+          ghcr.io/yolean/runtime-deno:latest
+          ghcr.io/yolean/runtime-deno:${{ github.sha }}
+        platforms: linux/amd64,linux/arm64/v8
+        push: true
+        cache-from: type=gha
+        cache-to: type=gha,mode=max
     -
       name: Build and push java root
       uses: docker/build-push-action@v5
@@ -542,6 +555,36 @@ jobs:
         cache-to: type=gha,mode=max
         build-contexts: |
           yolean/runtime-quarkus-ubuntu:root=docker-image://ghcr.io/yolean/runtime-quarkus-ubuntu:root
+    -
+      name: Build and push runtime-quarkus-deno root
+      uses: docker/build-push-action@v5
+      env:
+        SOURCE_DATE_EPOCH: 0
+      with:
+        context: runtime-quarkus-deno
+        tags: |
+          ghcr.io/yolean/runtime-quarkus-deno:root
+          ghcr.io/yolean/runtime-quarkus-deno:${{ github.sha }}-root
+        platforms: linux/amd64,linux/arm64/v8
+        push: true
+        cache-from: type=gha
+        cache-to: type=gha,mode=max
+    -
+      name: Build and push runtime-quarkus-deno latest
+      uses: docker/build-push-action@v5
+      env:
+        SOURCE_DATE_EPOCH: 0
+      with:
+        context: to-nonroot/runtime-quarkus-deno
+        tags: |
+          ghcr.io/yolean/runtime-quarkus-deno:latest
+          ghcr.io/yolean/runtime-quarkus-deno:${{ github.sha }}
+        platforms: linux/amd64,linux/arm64/v8
+        push: true
+        cache-from: type=gha
+        cache-to: type=gha,mode=max
+        build-contexts: |
+          yolean/runtime-quarkus-deno:root=docker-image://ghcr.io/yolean/runtime-quarkus-deno:root
     -
       name: Build and push runtime-quarkus-ubuntu-jre root
       uses: docker/build-push-action@v5
diff --git a/runtime-deno/Dockerfile b/runtime-deno/Dockerfile
index e577622..af5f02e 100644
--- a/runtime-deno/Dockerfile
+++ b/runtime-deno/Dockerfile
@@ -1,15 +1,9 @@
-FROM yolean/builder-quarkus as libs
-
-RUN y-deno -V
+FROM denoland/deno:distroless-2.1.1@sha256:8c7fbba4e216e9535ac9869744ce36e225814aa3adc7754fdeb5930a2a86f34f AS deno
 
 FROM --platform=$TARGETPLATFORM gcr.io/distroless/static-debian12:nonroot@sha256:d71f4b239be2d412017b798a0a401c44c3049a3ca454838473a4c32ed076bfea
 
-COPY --from=libs \
-  /usr/lib/x86_64-linux-gnu/libgcc_s.so.* \
-  /usr/lib/x86_64-linux-gnu/
-
-COPY --from=libs \
-  /usr/local/src/ystack/bin/deno /deno
+COPY --from=deno \
+  /bin/deno /usr/local/bin/deno
 
-ENTRYPOINT ["/deno"]
+ENTRYPOINT ["/usr/local/bin/deno"]
 CMD ["-V"]
diff --git a/runtime-quarkus-deno/Dockerfile b/runtime-quarkus-deno/Dockerfile
index 4851207..fe5ffa3 100644
--- a/runtime-quarkus-deno/Dockerfile
+++ b/runtime-quarkus-deno/Dockerfile
@@ -1,8 +1,6 @@
-FROM yolean/builder-base as base
-
-RUN y-deno -V
+FROM yolean/runtime-deno AS runtime-deno
 
 FROM yolean/runtime-quarkus-ubuntu
 
-COPY --from=base \
-  /usr/local/src/ystack/bin/deno /usr/local/bin/deno
+COPY --from=runtime-deno \
+  /usr/local/bin/deno /usr/local/bin/deno
diff --git a/test.sh b/test.sh
index c86f8d6..10ace74 100755
--- a/test.sh
+++ b/test.sh
@@ -31,6 +31,7 @@ blobs
 headless-chrome
 git-http-readonly
 runtime-quarkus
+runtime-deno
 "
 
 MULTIARCH_TONONROOT="
@@ -42,6 +43,7 @@ node-watchexec
 node-kafka-watch
 node-gcloud
 runtime-quarkus-ubuntu
+runtime-quarkus-deno
 runtime-quarkus-ubuntu-jre
 runtime-quarkus-dev
 toil-storage