---
title: 'Deployment'
description: 'Deploy static Ecopages sites and apps with server routes to production hosts.'
order: 3
---

import { RuiAlert, RuiAlertDescription, RuiAlertTitle } from '@ecopages/radiant-ui/alert';

# Deployment

Deploying an Ecopages application depends on whether you are using only static features or if you've added API routes and server-side logic.

## Production Build

Before deploying, you must create a production build. This processes your assets, pre-renders static pages, and prepares the `dist` directory.

For projects using the [Vite host plugin](/docs/ecosystem/vite-plugin), `ecopages build` still produces the same `dist` output; Vite orchestrates dev and optional build integration only.

```bash
pnpm run build
```

This command will:

1. Set `NODE_ENV=production`.
2. Clean the `dist` directory.
3. Generate static HTML for all files in `src/pages`.
4. Write `robots.txt` (and optional `sitemap.xml` when enabled — see [Sitemap](/docs/core/sitemap)).
5. Process images and CSS.
6. Collect all necessary server-side files.

---

## Static Hosting

If your site **does not** use API routes or programmatic server logic, you can host the contents of the `dist` directory on any static provider.

- **Vercel / Netlify**: Connect your repository and set the build command to `pnpm run build`. Set the output directory to `dist`.
- **GitHub Pages**: Use a GitHub Action to run `pnpm run build` and deploy the output directory.

<RuiAlert variant="info" layout="banner" class="unstyled">
	<RuiAlertTitle>Base URL Configuration</RuiAlertTitle>
	<RuiAlertDescription>
		Even for static sites, ensure your `ECOPAGES_BASE_URL` is set correctly during the build so that metadata and
		links are absolute.
	</RuiAlertDescription>
</RuiAlert>

---

## Server Hosting (Node/Bun)

If your application uses **API routes** or **dynamic server logic**, you need a runtime environment compatible with the adapter you configured (Bun or Node).

### 1. Using `pnpm run start`

After building, you can start the production server:

```bash
pnpm run start
```

### 2. Docker Deployment

You can easily containerize your Ecopages app using the official Bun image when using the Bun adapter.

```dockerfile
FROM oven/bun:latest

WORKDIR /app

COPY package.json ./
RUN bun install --production

COPY . .
RUN bun run build

EXPOSE 3000
CMD ["bun", "run", "start"]
```

### 3. VPS / PaaS (Railway, Fly.io)

Deploy the server by pointing the platform to your `app.ts` as the entry point and ensuring it runs with the `start` command in production.

---

## Environment Check

Before going live, check that these environment variables are set on your hosting provider:

| Variable            | Recommended Value                                    |
| :------------------ | :--------------------------------------------------- |
| `NODE_ENV`          | `production`                                         |
| `ECOPAGES_BASE_URL` | Your production domain (e.g., `https://example.com`) |
| `ECOPAGES_PORT`     | The port required by your host (e.g., `8080`)        |
| `ECOPAGES_HOSTNAME` | `0.0.0.0` (for Docker/Cloud environments)            |
