From 18da31a3d893172e185c48f2aa87facf9d1f8613 Mon Sep 17 00:00:00 2001 From: Constantine Molchanov Date: Fri, 24 Jul 2026 16:03:56 +0400 Subject: [PATCH 1/2] Nim: Add info about compiling to JS and running. --- nim/README.md | 16 ++++++++++++++-- nim/content.md | 16 ++++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/nim/README.md b/nim/README.md index 5e2f6af2fb1d..afdbf315bbd9 100644 --- a/nim/README.md +++ b/nim/README.md @@ -65,10 +65,22 @@ $ docker run --rm -v "$PWD":/usr/src/app -w /usr/src/app nim nim c -r main.nim ## Compile to JavaScript -Nim can compile to JavaScript. This image includes Node.js to serve as the runtime: +Nim can compile to JavaScript: ```console -$ docker run --rm -v "$PWD":/usr/src/app -w /usr/src/app nim nim js -r main.nim +$ docker run --rm -v "$PWD":/usr/src/app -w /usr/src/app nim nim js main.nim +``` + +To compile and run, use a multi-stage Dockerfile with Node.js: + +```dockerfile +FROM nim AS builder +COPY . . +RUN nim js -o:app.js src/app.nim + +FROM node:latest +COPY --from=builder /usr/src/app/app.js . +CMD ["node", "app.js"] ``` ## Managing packages with Nimble diff --git a/nim/content.md b/nim/content.md index f5288810df8a..92ede7e86001 100644 --- a/nim/content.md +++ b/nim/content.md @@ -18,10 +18,22 @@ $ docker run --rm -v "$PWD":/usr/src/app -w /usr/src/app %%IMAGE%% nim c -r main ## Compile to JavaScript -Nim can compile to JavaScript. This image includes Node.js to serve as the runtime: +Nim can compile to JavaScript: ```console -$ docker run --rm -v "$PWD":/usr/src/app -w /usr/src/app %%IMAGE%% nim js -r main.nim +$ docker run --rm -v "$PWD":/usr/src/app -w /usr/src/app %%IMAGE%% nim js main.nim +``` + +To compile and run, use a multi-stage Dockerfile with Node.js: + +```dockerfile +FROM %%IMAGE%% AS builder +COPY . . +RUN nim js -o:app.js src/app.nim + +FROM node:latest +COPY --from=builder /usr/src/app/app.js . +CMD ["node", "app.js"] ``` ## Managing packages with Nimble From 279743a5fd093ebb50eaa359a5a744927958a569 Mon Sep 17 00:00:00 2001 From: Constantine Molchanov Date: Fri, 24 Jul 2026 16:41:35 +0400 Subject: [PATCH 2/2] Revert README.md. --- nim/README.md | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/nim/README.md b/nim/README.md index afdbf315bbd9..5e2f6af2fb1d 100644 --- a/nim/README.md +++ b/nim/README.md @@ -65,22 +65,10 @@ $ docker run --rm -v "$PWD":/usr/src/app -w /usr/src/app nim nim c -r main.nim ## Compile to JavaScript -Nim can compile to JavaScript: +Nim can compile to JavaScript. This image includes Node.js to serve as the runtime: ```console -$ docker run --rm -v "$PWD":/usr/src/app -w /usr/src/app nim nim js main.nim -``` - -To compile and run, use a multi-stage Dockerfile with Node.js: - -```dockerfile -FROM nim AS builder -COPY . . -RUN nim js -o:app.js src/app.nim - -FROM node:latest -COPY --from=builder /usr/src/app/app.js . -CMD ["node", "app.js"] +$ docker run --rm -v "$PWD":/usr/src/app -w /usr/src/app nim nim js -r main.nim ``` ## Managing packages with Nimble