# Deploy a Astro app that uses Yarn

Reverhost builds every app from the Dockerfile stored on it, so you choose the install step. These are the lines to use for Astro with Yarn.

## What your Dockerfile runs

| Step | Dockerfile line |
| --- | --- |
| Copy the manifests | `COPY package.json yarn.lock ./` |
| Install | `RUN corepack enable yarn && yarn install --frozen-lockfile` |
| Build | `npm run build`, which runs `astro build` |
| Start | `node ./dist/server/entry.mjs` |

Run scripts with `yarn run <script>` if you prefer. Dev dependencies are installed before the build, and `NODE_ENV=production` is set only after it.

```Dockerfile
FROM node:22-alpine
WORKDIR /app
COPY package.json yarn.lock ./
RUN corepack enable yarn && yarn install --frozen-lockfile
COPY . .
RUN --mount=type=secret,id=appenv,target=/run/secrets/appenv sh -c 'set -a; . /run/secrets/appenv; set +a; npm run build'
ENV NODE_ENV=production PORT=3000 HOST=0.0.0.0
EXPOSE 3000
CMD ["node", "./dist/server/entry.mjs"]
```

## Deploy

Install `@astrojs/node` in standalone mode and use on-demand rendering where you need a server. Then set the Node.js template's last line to `node ./dist/server/entry.mjs`.

```
npx ezhst projects create my-project --link
npx ezhst apps create my-app
npx ezhst link --project <project-slug> --app <app-slug>
npx astro add node
npx ezhst build dockerfile set -f Dockerfile
npx ezhst env import .env
npx ezhst deploy
```

## Things to watch with Yarn

Set `packageManager` in `package.json` to pin your Yarn version. Yarn Berry needs `--immutable` instead of `--frozen-lockfile`, so change that line in your Dockerfile.

Commit `yarn.lock`, because a frozen install fails without it. To change the install step, edit the Dockerfile and upload it again with `ezhst build dockerfile set -f Dockerfile`.

## Next steps

See the [Astro hub](/frameworks/astro) for every Astro guide, or [free Astro hosting](/free-astro-hosting) for what is included.

## Frequently asked questions

### How do I change the Yarn install command?

Edit the install line in your Dockerfile, upload it with `ezhst build dockerfile set -f Dockerfile`, then run `ezhst redeploy`.
