Skip to content

Commit 5dbed73

Browse files
rgbkrkshouples
andauthored
starter work on incorporating the deno kernel (#38)
* starter work on incorporating the deno kernel * include jupyter and install the kernel just to shake it out * Revert db77647 --------- Co-authored-by: Dave Shoup <[email protected]>
1 parent c277cbf commit 5dbed73

File tree

7 files changed

+169
-0
lines changed

7 files changed

+169
-0
lines changed

.github/workflows/build.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,3 +182,41 @@ jobs:
182182
with:
183183
push: ${{ github.event_name != 'pull_request' }}
184184
targets: ${{ steps.target.outputs.TARGET }}
185+
186+
build_deno_kernels:
187+
runs-on: ubuntu-22.04
188+
permissions:
189+
id-token: write
190+
packages: write
191+
strategy:
192+
matrix:
193+
version: ["1.37-dev"]
194+
env:
195+
VERSION: ${{ matrix.version }}
196+
BUILD_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
197+
GITHUB_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
198+
steps:
199+
- uses: actions/checkout@v3
200+
- name: Install Task
201+
uses: arduino/setup-task@e26d8975574116b0097a1161e0fe16ba75d84c1c # v1.0.3
202+
with:
203+
repo-token: ${{ github.token }}
204+
- run: |
205+
task deno:base:copy-files NBL_LANGUAGE_VERSION=${{ matrix.version }}
206+
- run: scripts/set-variables.sh ${{ github.ref_name }} ${{ github.event_name }} ${{ github.event.pull_request.number }}
207+
- uses: docker/login-action@v2
208+
with:
209+
registry: ghcr.io
210+
username: ${{ github.actor }}
211+
password: ${{ github.token }}
212+
- name: Set target
213+
id: target
214+
run: echo "TARGET=deno_${VERSION//./_}" >> "$GITHUB_OUTPUT"
215+
216+
- uses: docker/setup-buildx-action@4c0219f9ac95b02789c1075625400b2acbff50b1 # v2.9.1
217+
218+
- name: Build kernels
219+
uses: docker/bake-action@f32f8b8d70bc284af19f8148dd14ad1d2fbc6c28 # v3.1.0
220+
with:
221+
push: ${{ github.event_name != 'pull_request' }}
222+
targets: ${{ steps.target.outputs.TARGET }}

Taskfile.deno.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
version: 3
2+
3+
vars:
4+
NBL_DENO_VERSION: 1.37-dev
5+
IDENTIFIER: base
6+
7+
# NOTE: When using `deps: []`, variables are inherited from the current task, but when calling them
8+
# directly in `cmds: []`, the variables have to be passed in explicitly.
9+
tasks:
10+
core:build:
11+
desc: Build the Deno image
12+
cmds:
13+
- >-
14+
docker build deno/{{.IDENTIFIER}}/{{.NBL_DENO_VERSION}} \
15+
--build-arg "NBL_DENO_VERSION={{.NBL_DENO_VERSION}}" \
16+
--build-arg "BASE_IMAGE={{.BASE_IMAGE}}" \
17+
--tag "local/kernel-deno-{{.NBL_DENO_VERSION}}-{{.IDENTIFIER}}:dev"
18+
19+
base:copy-files:
20+
desc: Copy files from the Deno directory to the build directories
21+
cmds:
22+
- task copy-root-files LANGUAGE=deno IDENTIFIER={{.IDENTIFIER}} NBL_LANGUAGE_VERSION={{.NBL_DENO_VERSION}}
23+
- task copy-language-files LANGUAGE=deno IDENTIFIER={{.IDENTIFIER}} NBL_LANGUAGE_VERSION={{.NBL_DENO_VERSION}}
24+
25+
base:build:
26+
desc: Build the Deno base image after copying required files
27+
cmds:
28+
- task deno:base:copy-files IDENTIFIER=base NBL_LANGUAGE_VERSION={{.NBL_DENO_VERSION}}
29+
- task deno:core:build IDENTIFIER=base NBL_DENO_VERSION={{.NBL_DENO_VERSION}}

Taskfile.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ includes:
44
python: ./Taskfile.python.yaml
55
r: ./Taskfile.R.yaml
66
rust: ./Taskfile.rust.yaml
7+
deno: ./Taskfile.deno.yaml
78

89
tasks:
910
copy-root-files:

deno/Aptfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
tini
2+
curl
3+
cmake
4+
protobuf-compiler

deno/base/1.37-dev/Dockerfile

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# syntax = docker/dockerfile:1.5
2+
# ---
3+
# Bare minimum Rust 1.72.x image with deno installed
4+
# - no Rust crates/packages aside from builtins and deno
5+
# - no git, secrets, SQL, extensions, etc
6+
# ---
7+
# Deno is installed from a PR that adds Jupyter support
8+
# Rust 1.72 is required
9+
ARG NBL_DENO_VERSION="1.37-dev"
10+
FROM rust:1.72 as base
11+
12+
# User/group setup
13+
USER root
14+
15+
ENV NB_USER="noteable" \
16+
NB_UID=4004 \
17+
NB_GID=4004
18+
19+
RUN groupadd --gid 4004 noteable && \
20+
useradd --uid 4004 \
21+
--shell /bin/false \
22+
--create-home \
23+
--no-log-init \
24+
--gid noteable noteable \
25+
--home-dir /srv/noteable && \
26+
chown --recursive noteable:noteable /srv/noteable && \
27+
mkdir -p /etc/noteable && chown noteable:noteable /etc/noteable
28+
29+
WORKDIR /tmp
30+
31+
COPY apt-install /usr/bin/
32+
COPY Aptfile .
33+
RUN /usr/bin/apt-install Aptfile
34+
35+
USER noteable
36+
37+
ENV PATH="/srv/noteable/.cargo/bin:${PATH}"
38+
39+
RUN cargo install --git https://github.com/bartlomieju/deno --branch jupyter2 deno
40+
41+
COPY secrets_helper.sh /tmp/secrets_helper.sh
42+
COPY run.sh /usr/local/bin
43+
44+
ENV HOME="/srv/noteable"
45+
46+
WORKDIR /etc/noteable/project
47+
EXPOSE 50001-50005
48+
49+
RUN cargo init
50+
51+
ENTRYPOINT ["tini", "-g", "--"]
52+
CMD ["run.sh"]

deno/run.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
set -o pipefail
3+
set -o nounset
4+
set -o errexit
5+
6+
set -x
7+
8+
echo "Local time: $(date)"
9+
10+
set +x
11+
echo "Injecting Secrets into environment, echoing is turned off"
12+
# shellcheck disable=SC1091
13+
source /tmp/secrets_helper.sh
14+
echo "Done injecting Secrets, turning echoing back on"
15+
set -x
16+
17+
18+
echo "Starting Deno kernel"
19+
20+
exec deno --unstable jupyter --conn /etc/noteable/connections/connection_file.json

docker-bake.hcl

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,21 @@ variable "TIMESTAMP" {
2727
default = ""
2828
}
2929

30+
# Group of Deno targets
31+
group "deno" {
32+
targets = [
33+
"deno_1_37-dev",
34+
]
35+
}
36+
37+
# Group of Deno 1.37 targets
38+
group "deno_1_37-dev" {
39+
targets = [
40+
"deno_base_1_37-dev",
41+
]
42+
}
43+
44+
3045
# Group of Rust targets
3146
group "rust" {
3247
targets = [
@@ -383,3 +398,13 @@ target "rust_base_1_70_0" {
383398
notequal("", HANDLE) ? "ghcr.io/noteable-io/kernel-rust-1.70-base:${HANDLE}" : ""
384399
]
385400
}
401+
402+
# Base Deno 1.37-dev image
403+
target "deno_base_1_37-dev" {
404+
inherits = ["base"]
405+
context = "deno/base/1.37-dev"
406+
tags = [
407+
"ghcr.io/noteable-io/kernel-deno-1.37-base:${TAG}",
408+
notequal("", HANDLE) ? "ghcr.io/noteable-io/kernel-deno-1.37-base:${HANDLE}" : ""
409+
]
410+
}

0 commit comments

Comments
 (0)