AnySites

// BUILD CONFIGURATION

Deploy with a Custom Dockerfile

Required for Python, Go, and anything else that isn't Node.js.

Any repository can include its own Dockerfile at the root, and if present, it's always used instead of auto-generation — regardless of tech stack. For Python, Go, Ruby, Rust, or anything else that isn't Node.js, this is required, not optional; see Framework Auto-Detection for why.

Requirements

  • EXPOSE and actually listen on the port configured in project settings (0.0.0.0:$PORT, not localhost/127.0.0.1 — the health check and reverse proxy connect from outside the container).
  • Read configuration from environment variables — DATABASE_URL, PORT, and anything you set yourself are all injected as container env vars, see Environment Variables.
  • Respond to at least one HTTP request within the deploy's health-check window, or the deploy is marked failed and traffic stays on the previous version.

Example — Python (Flask/Gunicorn)

FROM python:3.12-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
EXPOSE 8000
CMD ["gunicorn", "-b", "0.0.0.0:8000", "app:app"]

Example — Go

FROM golang:1.22 AS builder
WORKDIR /app
COPY . .
RUN CGO_ENABLED=0 go build -o server .

FROM alpine:3.20
COPY --from=builder /app/server /server
EXPOSE 8000
CMD ["/server"]
When you generate a Dev Prompt for a project on a non-Node tech stack, it includes a Dockerfile example matching your configured port — see the project's Dev Prompt page.

Related documentation