From f5f303e934c2411d12395caed92a69db92ad496c Mon Sep 17 00:00:00 2001 From: Dave Shoup Date: Tue, 19 Sep 2023 10:06:51 -0400 Subject: [PATCH] [deno] add intermediate `packages` build (#47) --- .github/workflows/build.yml | 2 +- .gitignore | 4 ++++ Taskfile.deno.yaml | 13 ++++++++++++- deno/base/{1.37-dev => 1.37}/Dockerfile | 0 deno/packages/1.37/Dockerfile | 10 ++++++++++ deno/packages/deps.ts | 15 ++++++++++++++ docker-bake.hcl | 26 +++++++++++++++++++------ 7 files changed, 62 insertions(+), 8 deletions(-) rename deno/base/{1.37-dev => 1.37}/Dockerfile (100%) create mode 100644 deno/packages/1.37/Dockerfile create mode 100644 deno/packages/deps.ts diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 83d89c0..4f08233 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -190,7 +190,7 @@ jobs: packages: write strategy: matrix: - version: ["1.37-dev"] + version: ["1.37"] env: VERSION: ${{ matrix.version }} BUILD_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} diff --git a/.gitignore b/.gitignore index 07822e1..896239b 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ .Rprofile apt-install Aptfile +deps.ts environment.txt git_credential_helper.py git-wrapper.sh @@ -40,10 +41,13 @@ run.sh !python/base-gpu/initial-condarc +!deno/packages/deps.ts + !python/base/requirements.in !python/datascience/requirements.in !python/noteable/requirements.in +!deno/packages/run.sh !python/run.sh !python/base-gpu/run.sh !r/run.sh diff --git a/Taskfile.deno.yaml b/Taskfile.deno.yaml index b860974..22514aa 100644 --- a/Taskfile.deno.yaml +++ b/Taskfile.deno.yaml @@ -1,7 +1,7 @@ version: 3 vars: - NBL_DENO_VERSION: 1.37-dev + NBL_DENO_VERSION: 1.37 IDENTIFIER: base # NOTE: When using `deps: []`, variables are inherited from the current task, but when calling them @@ -21,9 +21,20 @@ tasks: cmds: - task copy-root-files LANGUAGE=deno IDENTIFIER={{.IDENTIFIER}} NBL_LANGUAGE_VERSION={{.NBL_DENO_VERSION}} - task copy-language-files LANGUAGE=deno IDENTIFIER={{.IDENTIFIER}} NBL_LANGUAGE_VERSION={{.NBL_DENO_VERSION}} + - cp deno/packages/deps.ts deno/packages/{{.NBL_DENO_VERSION}}/deps.ts base:build: desc: Build the Deno base image after copying required files cmds: - task deno:base:copy-files IDENTIFIER=base NBL_LANGUAGE_VERSION={{.NBL_DENO_VERSION}} - task deno:core:build IDENTIFIER=base NBL_DENO_VERSION={{.NBL_DENO_VERSION}} + + packages:build: + desc: Build the Deno 1.3x image with commonly-installed packages + cmds: + # ensure the base image is built first + - task deno:base:build IDENTIFIER=packages NBL_DENO_VERSION={{.NBL_DENO_VERSION}} + # copy adjusted lockfile + - cp deno/packages/deps.ts deno/packages/{{.NBL_DENO_VERSION}}/deps.ts + # build the packages image off of the base image + - task build LANGUAGE=deno NBL_LANGUAGE_VERSION={{.NBL_DENO_VERSION}} IDENTIFIER=packages BUILD_TARGET=main -- --build-context base=docker-image://local/kernel-deno-{{.NBL_DENO_VERSION}}-base:dev diff --git a/deno/base/1.37-dev/Dockerfile b/deno/base/1.37/Dockerfile similarity index 100% rename from deno/base/1.37-dev/Dockerfile rename to deno/base/1.37/Dockerfile diff --git a/deno/packages/1.37/Dockerfile b/deno/packages/1.37/Dockerfile new file mode 100644 index 0000000..fb423c2 --- /dev/null +++ b/deno/packages/1.37/Dockerfile @@ -0,0 +1,10 @@ +# syntax = docker/dockerfile:1.5 +# Packages build: imports/caches commonly-installed packages to ease load time +# hadolint ignore=DL3006 +FROM base as main + +USER noteable + +# Copy and cache our desired imports +COPY ./deps.ts /tmp/deps.ts +RUN deno cache /tmp/deps.ts diff --git a/deno/packages/deps.ts b/deno/packages/deps.ts new file mode 100644 index 0000000..fb78711 --- /dev/null +++ b/deno/packages/deps.ts @@ -0,0 +1,15 @@ +import "https://deno.land/std/assert/mod.ts"; +import "https://deno.land/x/canvas@v1.4.1/mod.ts"; +import "https://deno.land/x/deno_dom/deno-dom-wasm-noinit.ts"; +import "https://deno.land/x/display/mod.ts"; +import "https://deno.land/x/skia_canvas/mod.ts"; + +import "https://esm.sh/jsdom"; +import "https://esm.sh/twind"; + +import "npm:apache-arrow"; +import "npm:d3"; +import "npm:express"; +import "npm:nodejs-polars"; +import "npm:react"; +import "npm:vega-lite-api"; diff --git a/docker-bake.hcl b/docker-bake.hcl index 6c3e7ac..489c8bc 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -30,14 +30,15 @@ variable "TIMESTAMP" { # Group of Deno targets group "deno" { targets = [ - "deno_1_37-dev", + "deno_1_37", ] } # Group of Deno 1.37 targets -group "deno_1_37-dev" { +group "deno_1_37" { targets = [ - "deno_base_1_37-dev", + "deno_base_1_37", + "deno_packages_1_37", ] } @@ -399,12 +400,25 @@ target "rust_base_1_70_0" { ] } -# Base Deno 1.37-dev image -target "deno_base_1_37-dev" { +# Base Deno 1.37 image +target "deno_base_1_37" { inherits = ["base"] - context = "deno/base/1.37-dev" + context = "deno/base/1.37" tags = [ "ghcr.io/noteable-io/kernel-deno-1.37-base:${TAG}", notequal("", HANDLE) ? "ghcr.io/noteable-io/kernel-deno-1.37-base:${HANDLE}" : "" ] } + +# Deno 1.37 packages variant +target "deno_packages_1_37" { + context = "deno/packages/1.37" + contexts = { + base = "target:deno_base_1_37" + } + target = "main" + tags = [ + "ghcr.io/noteable-io/kernel-deno-1.37-packages:${TAG}", + notequal("", HANDLE) ? "ghcr.io/noteable-io/kernel-deno-1.37-packages:${HANDLE}" : "" + ] +}