Zaroz
Git builds

How builds are detected

Zaroz picks how to build your code in this order. The first rule that applies wins.

  1. You chose a builder. If build.builder is dockerfile or railpack in your zaroz.toml, Zaroz uses it.
  2. There is a Dockerfile. If there is a file called Dockerfile in your root directory, Zaroz builds it. You can change the name and path with build.dockerfile.
  3. Otherwise, automatic detection. Zaroz uses Railpack, which reads your code and works out how to install, build and start it.

The setting build.builder = "auto" is the default, and it follows these rules. Use dockerfile to be sure the Dockerfile is used. Use railpack to ignore a Dockerfile you have.

If there is no Dockerfile and Zaroz does not recognise the code, the build fails with detect_failed.

The root directory

Detection looks at the root directory of the service. By default that is the root of the repository. If your app is in a folder, such as apps/api, set that folder as the root directory. When you connect a repository, Zaroz offers the folders it finds. See Monorepos.

Languages

Zaroz recognises a language by one of these files in the root directory:

LanguageFiles
PHPcomposer.json
Gogo.mod
Javapom.xml, build.gradle, build.gradle.kts
RubyGemfile
Pythonrequirements.txt, pyproject.toml, Pipfile, setup.py
Nodepackage.json
Static filesindex.html

If several match, the language higher in this table wins. A Laravel app has a package.json too, but it is a PHP app.

Zaroz also names the framework when it sees one: Next.js, Vite, Astro, Laravel, Rails, Django or Spring. This only changes what the console tells you, for example the usual port. The build itself follows the language.

For a Node project, Zaroz warns you when there is no lockfile (package-lock.json, yarn.lock, pnpm-lock.yaml or a Bun lockfile). Without one, installs are not repeatable. Commit your lockfile.

Change what was detected

You do not have to accept what Zaroz works out. In your zaroz.toml:

SettingWhat it does
build.installThe install command, instead of the detected one.
build.commandThe build command, instead of the detected one.
deploy.startThe start command. For a Dockerfile image it replaces CMD.
build.versionsThe language version, for example versions = { node = "22" }. The languages are node, python, go, php, java and ruby.

If you set nothing, Railpack picks the commands and the version.

The port

Your app must listen on the port in the PORT environment variable. The default is 8080. Zaroz never guesses the port from your code. If your Dockerfile has an EXPOSE line, the console fills in that port for you as a starting value. To use another port, set deploy.port.

Dockerfile builds

With a Dockerfile, the build runs your Dockerfile as written. You can set:

  • build.dockerfile: the path to the file, relative to the root directory.
  • build.context: the folder sent to the build, relative to the repository root. The default is the root directory. A Dockerfile in apps/api that copies shared code from packages/ needs context = ".".
  • build.target: the stage to build in a multi-stage Dockerfile. The default is the last stage.
  • build.args: build arguments. Declare each one with ARG in the Dockerfile. Their values are visible in the image, so never put a password here. Use a build secret.

Use a multi-stage Dockerfile to keep compilers and caches out of the final image. The image can be up to 10 GiB compressed. See image_too_large.

Build cache

The build cache is on by default and makes later builds faster. Turn it off with build.cache = false. On a failed or odd build, Rebuild without cache builds once without it.

Last modified on