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

# Dockerfile

> Find out how to use Dockerfiles to customize your application builds.

Sevalla uses [Nixpacks](/applications/build-options/nixpacks) by default to build your application and set up the container image. You can change this to use a Dockerfile to set up your container image within the application's [Settings](/applications/settings/) (**Settings** > **Build strategy** > **Update build strategy**). Using a Dockerfile gives you more control, and you can use almost any language, so you are not restricted to the languages [Nixpacks](/applications/build-options/nixpacks) or [Buildpacks](/applications/build-options/buildpacks) support.

A Dockerfile sets up the environment depending on the instructions within the Dockerfile, which must include commands to install the language, adjacent software, and libraries, [set up the port](/applications/networking#edit-application-port), and start the web server. Sevalla automatically sets the `PORT` environment variable. You do not need to define it yourself or hard-code it into the application. For example, in Node.js, use `process.env.PORT` in your code when referring to the server port.

Detailed information about how to create a Dockerfile is available in [Docker Docs](https://docs.docker.com/compose/gettingstarted/#step-2-create-a-dockerfile).

<Info>
  To use the Web Terminal with an application created with a Dockerfile, make sure Bash is installed in the container. In most cases, the base image (e.g. Ubuntu) includes a shell package and will work by default. In some more streamlined containers, the shell package may not be included, and you’ll need to add it. The base image determines how to add the shell package:Alpine: apk add bashUbuntu/Debian: apt install bashFedora: dnf install bash
</Info>

## Dockerfile settings

To use a Dockerfile, you must change the **Build strategy** in the application's [Settings](/applications/settings/) (**Settings** > **Build strategy** > **Update build strategy**).

The **Dockerfile path** is the path to your Dockerfile relative to the repository root. For example, if your Dockerfile is in the repository root, enter **Dockerfile** in that field. If your Dockerfile is in a subdirectory named **app**, enter the path to the Dockerfile: **app/Dockerfile**.

**Context** is the path in the repository we need access to so we can build your application. Most applications are built from the repository root, and you can enter the repository root (**.**) in the **Context** field. If your application needs to be built from a subdirectory (e.g., **app**), enter that subdirectory path in the **Context** field: **app**.

The **Registry credential** is only required for private Docker images. You must enter your registry credentials within **Integration** > **Registry credentials**. Once you’ve entered your credentials in the Company settings, you can choose which credentials you want to use.

## Dockerfile and pnpm

If you use [pnpm with a Dockerfile](https://pnpm.io/docker), you must use the following location for `PNPM_HOME`:

```text theme={null}
ENV PNPM_HOME="~/.pnpm"
```

## Example Dockerfile

To help get you started, here’s an example Dockerfile you can use for reference or as a starting point.

```text theme={null}
FROM node:carbon

LABEL maintainer="Sevalla devs"

# Set the working directory to /app
WORKDIR /app

# Copy the current directory contents into the container at /app
COPY . /app

# Install any needed packages specified in package.json
RUN npm install

# Run app when the container launches
CMD ["npm", "start"]
```

## Host a database with a Dockerfile

If you combine [persistent storage](/applications/storage) and a Dockerfile, you can host pretty much any database you want with our [Application Hosting](https://sevalla.com/application-hosting/). Even something like a Microsoft SQL Server database, which isn’t supported on our [Database Hosting](https://sevalla.com/database-hosting/), can be deployed. If you can containerize it with a Dockerfile, you can deploy it on Application Hosting.

Persistent storage is needed to retain the data in your database. If you deploy a database on Application Hosting without persistent storage, all data will be lost if the application is restarted or redeployed.

Docker images for many databases can be found at [Docker Hub](https://hub.docker.com/). Look for the [Docker Official Image](https://docs.docker.com/docker-hub/image-library/trusted-content/) badge when searching for a database to get the most secure and well-documented images that follow best practices.
