Nim Programming Language Official Docker Images
Nim is a statically typed, imperative programming language that focuses on efficiency, expressiveness, and elegance. It is designed to be as fast as C and as readable as Python, while offering a powerful macro system for metaprogramming.
These images provide a stable, multi-architecture environment for developing and deploying Nim applications.
Key Features
- Multi-Backend Support: Compiles to C, C++, and JavaScript. GCC is included for native binaries.
- Precompiled Binaries: Built using official Nim binaries for maximum reliability and consistency with the upstream releases.
- Multi-Arch: Native support for
amd64,arm64/v8,i386, andarm32/v7via Docker manifests.
How to Use This Image
Compile and Run (C Backend)
To compile a file named main.nim:
docker run --rm -v "$(pwd)":/usr/src/app nim:latest nim c main.nim
To compile and immediately run:
docker run --rm -v "$(pwd)":/usr/src/app nim:latest nim c -r main.nim
Compile to JavaScript
To compile a .nim file to JS:
docker run --rm -v "$(pwd)":/usr/src/app nim:latest nim js main.nim
To compile and run, use a multi-stage Dockerfile with Node.js:
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
The image is configured with SSL support to allow Nimble to install packages from remote repositories:
docker run --rm -v "$(pwd)":/usr/src/app nim:latest nimble setup -y
To build a binary Nimble package:
docker run --rm -v "$(pwd)":/usr/src/app nim:latest nimble build