Skip to content

WIP: use deno to compile to single binary - #186

Draft
6543 wants to merge 6 commits into
mainfrom
deno
Draft

WIP: use deno to compile to single binary#186
6543 wants to merge 6 commits into
mainfrom
deno

Conversation

@6543

@6543 6543 commented Sep 29, 2024

Copy link
Copy Markdown
Member

based on #609

 deno compile --allow-read --allow-write --allow-env --allow-net --allow-run src/run.ts

https://deno.com/blog/v1.46

@6543

6543 commented Sep 29, 2024

Copy link
Copy Markdown
Member Author

image

well now i just need to make sure the git impl. is working currectly and cant be broken by user input ...

... but for my 1/2h experiment, it should be doable

@6543

6543 commented Sep 29, 2024

Copy link
Copy Markdown
Member Author

image

Comment thread src/utils/git.ts Outdated
push(args: string[]): Promise<void>;
}

export function simpleGit(): SimpleGit {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mostly untested & we should add tests for it anyway ...

@pat-s

pat-s commented Oct 2, 2024

Copy link
Copy Markdown
Contributor

Will this also reduce the image size? Could we even use a scratch image?

@6543

6543 commented Oct 3, 2024

Copy link
Copy Markdown
Member Author

not scratch jet as we need the git binary working

but yes that's a way to move towards it :)

@6543

6543 commented Oct 3, 2024

Copy link
Copy Markdown
Member Author

the image size would probably increase by ~50Mb but the image would be silli and dont contain any unessesary build-time deps and other unrelated stuff

PS: this here is just a POC if it would work at all

@6543

6543 commented Oct 3, 2024

Copy link
Copy Markdown
Member Author

tldr: if we have a static linked git binary + the deno binary we should be able to use FROM scratch

@pat-s

pat-s commented Oct 3, 2024

Copy link
Copy Markdown
Contributor
git clone git@github.com:git/git.git
mkdir git-static
cd git
make configure
./configure prefix=/path/to/git-static/ CFLAGS="${CFLAGS} -static"
make
make install

6543 pushed a commit that referenced this pull request Jul 17, 2026
Deno 2's Node compatibility runs the existing tsx/Node sources
unchanged, so a hand-rolled git wrapper (as attempted in #186 via the
removed Deno.run API) is unnecessary; simple-git and process.env keep
working as-is. deno.json carries Deno's own compilerOptions since it
misreads the Node-oriented tsconfig, and the compile task skips
type-checking because tsc already covers it and @types/node is absent
from production installs. Runtime loading of release-config.ts from
disk keeps working inside the compiled binary. Installing with --prod
before compiling shrinks the embedded node_modules from ~100MB to
~21MB.
Refs #186
6543 and others added 5 commits July 17, 2026 22:31
Deno 2's Node compatibility runs the existing tsx/Node sources
unchanged, so a hand-rolled git wrapper (as attempted in #186 via the
removed Deno.run API) is unnecessary; simple-git and process.env keep
working as-is. deno.json carries Deno's own compilerOptions since it
misreads the Node-oriented tsconfig, and the compile task skips
type-checking because tsc already covers it and @types/node is absent
from production installs. Runtime loading of release-config.ts from
disk keeps working inside the compiled binary. Installing with --prod
before compiling shrinks the embedded node_modules from ~100MB to
~21MB.
Refs #186
Deno resolves npm dependencies straight from package.json and locks
them in deno.lock, so pnpm, corepack and node are no longer needed for
development. tsx is replaced by deno run, tsc by deno check (which
ships its own node types, dropping typescript and @types/node), and
vitest and prettier keep running unchanged through deno run npm:. The
tsconfig moves into deno.json compilerOptions. CI switches from the
node image with corepack to the deno image running the same tasks.
deno covers runtime, package management, type checking and the
language server, so nodejs, pnpm, typescript and
typescript-language-server can go.
The image previously shipped node_modules plus sources and ran tsx at
startup via a node base image. A single deno build stage installs the
runtime npm dependencies (devDependencies are stripped first so only
~10MB of packages get embedded) and compiles the binary; the final
stage is node-free and contains just git, git-lfs, wget, CA
certificates and the binary. scratch and alpine finals were evaluated
and rejected: deno compile has no musl target and the glibc binary
fails on alpine even with gcompat (__res_init missing), and the plugin
needs the git CLI, /bin/sh for hooks and CA certs at runtime.
Unverified with docker build (no docker daemon available); the build
stage was replayed manually from the exact copied file set and the
resulting binary smoke-tested.
Comment thread Dockerfile Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants