> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ardor.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# Deployments

> Understand how Ardor deploys an environment — from service configuration to running containers.

## Overview

When you click **Deploy**, Ardor deploys the selected environment: all services in that environment and their runtime settings. This page explains what happens under the hood and how to manage your deployments.

<Tip>
  **Cerebrum handles deployments.** Just ask "deploy to production". The details below help you understand the process or troubleshoot issues.
</Tip>

## How Deployment Works

<Steps>
  <Step title="Prepare Environment">
    Ardor reads the selected environment: its services, resource settings, variables, secrets, ports, and networking configuration.
  </Step>

  <Step title="Build Code Services">
    For services backed by code, Ardor reads each service's `Dockerfile` and builds a container image.
  </Step>

  <Step title="Use Image Services">
    Services created from Docker images skip the build step. Ardor uses the configured image directly.
  </Step>

  <Step title="Deploy Environment">
    Ardor applies the environment configuration and starts or updates the containers for all changed services.
  </Step>
</Steps>

## Dockerfile Requirements

All code services need a `Dockerfile` in the project root. Docker image services do not need a `Dockerfile` because Ardor deploys the configured image directly.

<Card title="Dockerfile Essentials" icon="file-code">
  Your Dockerfile must:

  * **Build your app** — install dependencies, compile code
  * **EXPOSE a port** — the port your app listens on
  * **Define CMD or ENTRYPOINT** — how to start your app
</Card>

### Example Dockerfiles

<Tabs>
  <Tab title="Python">
    ```dockerfile theme={null}
    FROM python:3.12-slim

    WORKDIR /app
    COPY requirements.txt .
    RUN pip install --no-cache-dir -r requirements.txt

    COPY . .

    EXPOSE 8080
    CMD ["python", "app.py"]
    ```
  </Tab>

  <Tab title="Node.js">
    ```dockerfile theme={null}
    FROM node:20-alpine

    WORKDIR /app
    COPY package*.json ./
    RUN npm ci --only=production

    COPY . .

    EXPOSE 8080
    CMD ["npm", "start"]
    ```
  </Tab>

  <Tab title="Go">
    ```dockerfile theme={null}
    FROM golang:1.21-alpine AS builder
    WORKDIR /app
    COPY . .
    RUN go build -o main .

    FROM alpine:latest
    WORKDIR /app
    COPY --from=builder /app/main .

    EXPOSE 8080
    CMD ["./main"]
    ```
  </Tab>
</Tabs>

<Tip>
  Use multi-stage builds (like the Go example) to keep your final image small. Smaller images = faster deployments.
</Tip>

## Docker Image Deployments

Services created from Docker images skip the build step entirely during environment deployment — Ardor pulls the image directly and deploys it with the service's configured settings.

<Card title="Docker Image Guide" icon="docker" href="/docs/services/create_service/docker-image">
  Learn how to deploy pre-built images from Docker Hub.
</Card>

## Build Failures

If a code service build fails, check:

<AccordionGroup>
  <Accordion title="Dockerfile syntax errors">
    Typos, missing commands, or invalid instructions. Validate your Dockerfile locally with `docker build .`
  </Accordion>

  <Accordion title="Missing dependencies">
    Package not found? Make sure your `requirements.txt`, `package.json`, or equivalent is complete and committed.
  </Accordion>

  <Accordion title="Network issues during build">
    Some packages need network access. If using a private package registry, ensure credentials are configured.
  </Accordion>

  <Accordion title="Out of memory during build">
    Large builds (especially Node.js) can run out of memory. Try optimizing your Dockerfile or increasing build resources.
  </Accordion>
</AccordionGroup>

<Card title="Build Logs" icon="scroll" href="/docs/services/logging">
  Check build logs for detailed error messages.
</Card>

## Deployment Failures

If a service container starts but then fails:

<AccordionGroup>
  <Accordion title="App crashes on startup">
    Check runtime logs for errors. Common causes: missing environment variables, database connection failures, port binding issues.
  </Accordion>

  <Accordion title="Health check timeout">
    Your app isn't responding on the configured port. Make sure it binds to `0.0.0.0` and reads the `PORT` environment variable.
  </Accordion>

  <Accordion title="Out of memory">
    Your app needs more RAM than allocated. Increase memory in resource settings.
  </Accordion>
</AccordionGroup>

## Best Practices

<CardGroup cols="2">
  <Card title="Keep images small" icon="compress">
    Use alpine base images and multi-stage builds. Faster builds, faster deploys.
  </Card>

  <Card title="Use specific versions" icon="tag">
    Pin dependency versions in your Dockerfile and package files for reproducible builds.
  </Card>
</CardGroup>

## What's Next

<CardGroup cols="2">
  <Card title="Logging" icon="scroll" href="/docs/services/logging">
    Monitor builds and runtime with detailed logs
  </Card>

  <Card title="Variables & Secrets" icon="key" href="/docs/services/variables-and-secrets">
    Configure environment-specific settings
  </Card>

  <Card title="GitHub Integration" icon="github" href="/docs/integrations/github">
    Connect repositories and keep code in GitHub
  </Card>

  <Card title="Resource Configuration" icon="sliders" href="/docs/services/service#resource-configuration">
    Tune CPU, RAM, and storage for your deployments
  </Card>
</CardGroup>
