# How BitHut builds your code

Before a project can run, BitHut builds it: it installs what the code needs and prepares it to start. This page explains how it decides what to do, so you know what to tell your AI when a build fails.

## Two ways to build

**With a Dockerfile.** If the top of the project folder has a file named `Dockerfile`, BitHut builds from it exactly as it says. Use this when you need full control.

**Without a Dockerfile.** BitHut uses Railpack, a builder that recognises the language and framework from the dependency file: `requirements.txt` or `pyproject.toml` for Python, `package.json` for Node.js, `go.mod` for Go, and so on. It installs the dependencies and runs the usual build for that framework, for example `npm run build` for a site.

A single Python or JavaScript file without a dependency file still builds: BitHut adds an empty one. If there is no code it recognises and no Dockerfile, the deploy stops with the finding "BitHut could not tell what language the project is written in".

The `.env` file, `.git`, `node_modules` and virtual environments are never part of the upload. An upload can be up to 100 MB.

## The start command

The start command is what runs the project, for example `python main.py` or `npm start`. BitHut takes it from the Dockerfile or from what Railpack detects. When Railpack finds none and the top of the folder has one script, or a script with a usual name such as `main.py`, `app.py`, `bot.py`, `server.js` or `index.js`, BitHut starts that one.

If BitHut cannot work out how to start the project, the deploy stops with a finding that names a fix: your AI passes a start command, or adds a `start` script to `package.json`.

## The port

A site should listen on the port in the `PORT` variable, on address `0.0.0.0`. BitHut sets `PORT` to `8080` unless the code uses a fixed port: when the code always listens on one number and never reads `PORT`, BitHut sends visitors to that number instead and tells your AI so in the findings. Background processes and scheduled scripts do not need a port.

## Build settings

Some sites need public values while they are built, such as the address of an API in `VITE_API_URL`. These are build settings. BitHut passes them to the build, as build arguments for a Dockerfile. A build setting changes the site only on the next deploy. See [Public build settings](/docs/secrets/build-settings).

## When the build fails

The version does not go online, and the one that worked before keeps running. The Versions tab shows the build log of that version under **Build log**, and your AI gets the last lines of it with the findings. A build can take up to 20 minutes before BitHut stops it.

See [Checks and the trial run](/docs/projects/checks) for what happens after the build.
