Nixpacks is pretty cool. Instead of having to write my own Dockerfile, Nixpacks analyzes the source code and generates a Docker image from the source code.
- It works with Node.js out-of-the-box, among other runtimes.
- All 3 major package managers (npm, Yarn and pnpm) are supported^[by checking for the presence of the appropriate lock file or Corepack configuration].
- Nx and Turborepo are supported out-of-the-box.
- Caching is set up automatically.
Installation
Install Nixpacks using the system package manager.
# Homebrew (macOS)
brew install railwayapp/tap/nixpacks
# In Codespaces
curl -sSL https://nixpacks.com/install.sh | bash
:::
Build an image
Use the nixpacks build . command to build the app.
Additional configuration can be provided via environment variables or using -e NAME=VALUE.
- To build a single package in a Turborepo project, set
NIXPACKS_TURBO_APP_NAMEand overrideNIXPACKS_BUILD_CMDso just that service is built.
# Build the root
nixpacks build . --name my-app
# Build a package in a turborepo project
nixpacks build . \
-e NIXPACKS_TURBO_APP_NAME=web-service \
-e NIXPACKS_BUILD_CMD='pnpm turbo build --filter web-service' \
--name my-app
:::
Learn more
Documentation: https://nixpacks.com/docs/providers/node