# Deploying a Temporal Service

There are many ways to self-host a [Temporal Service](/temporal-service). The right way for you depends entirely on your
use case and where you plan to run it.

This page provides instructions for deploying a Temporal Service for sustained workloads that exceed what the
[development server](/cli#start-a-development-server) is designed to handle. For local development or testing, you can use the
Temporal CLI to [start a local development Temporal Service](/cli#start-a-development-server).

> **⚠️ Warning:**
> Temporal Hosts Should Not Be Exposed to the Open Internet
>
> In self-hosted deployments, the Temporal Service is a critical control and persistence component and should be secured
> similarly to a database. Temporal services should run on hosts that are not accessible from the public internet, with
> network configurations that restrict access to trusted internal networks only.
>

For step-by-step guides on deploying and configuring Temporal, refer to our
[Infrastructure tutorials](https://learn.temporal.io/tutorials/infrastructure/).

## Use Docker Compose

You can run a Temporal Service in [Docker](https://docs.docker.com/engine/install) containers using
[Docker Compose](https://docs.docker.com/compose/install).

### Prerequisites

- You have Docker Compose installed.
- Docker is running and the daemon is available.
- Git is installed and available.

### Procedure

1. Clone the [temporalio/samples-server](https://github.com/temporalio/samples-server) repository.

2. Change into the `compose` directory.

   ```
   cd samples-server/compose
   ```

3. Run the `docker compose up` command. This uses the default configuration from the `docker-compose.yaml` file, which
   includes a PostgreSQL database, an Elasticsearch instance, and exposes the Temporal gRPC Frontend on port 7233.

   ```
   docker compose up
   ```

   The Temporal Web UI will be available at `http://localhost:8080`.

4. (Optional) Review
   [the additional configuration options](https://github.com/temporalio/samples-server/tree/main/compose#other-configuration-files)
   available in the samples-server repository and use `docker compose up` with the corresponding configuration file to
   try them out. The configurations include different databases, visibility stores, and TLS settings.

## Use Temporal Server binaries

You can run a complete Temporal Server by deploying two Go binaries -- the
[core Temporal Server](https://github.com/temporalio/temporal/releases/), and the
[Temporal UI Server](https://github.com/temporalio/ui-server/releases).

Each service can be deployed separately. Refer to
[How to Configure a Temporal Service without a Proxy](https://learn.temporal.io/tutorials/infrastructure/configuring-sqlite-binary/)
to deploy each service using `systemd`. If you need to run the Temporal Server behind a reverse proxy, refer to our
tutorials to deploy the Temporal Service behind an
[Nginx reverse proxy](https://learn.temporal.io/tutorials/infrastructure/nginx-sqlite-binary/) or an
[Envoy edge proxy](https://learn.temporal.io/tutorials/infrastructure/envoy-sqlite-binary/).

### Configuration templating

Configuration templating is how the Temporal Server turns a template config file into the final `config.yaml` it runs
with. It lets you reuse one template across environments by filling in values from environment variables. For example,
database endpoints, TLS paths, or feature flags.

If you are **not** using a custom config template, you can skip this section. The default configuration is rendered
automatically by the server and embedded in the binary.

#### Template compatibility

If you use a custom configuration template, be aware of the following:

- The server renders templates with embedded `sprig`, so any `dockerize`-specific syntax or helpers will fail
- Some template syntax differs, particularly `.Env` and `default` function usage.
- Refer to the [sprig documentation](http://masterminds.github.io/sprig/) for supported template functions
- Use `temporal-server render-config` to verify your templates render correctly

#### Helm Chart configuration

When deploying with Helm charts versions 0.73.1 or later, you may need to adjust the following configuration options
depending on the images you are using.

| Configuration Option         | Description                                                               | Default       |
| ---------------------------- | ------------------------------------------------------------------------- | ------------- |
| `server.useEntrypointScript` | Whether to use entrypoint script that autodetects `dockerize` vs `sprig`. | `false`       |
| `server.configMapsToMount`   | Which config template to mount: `"dockerize"`, `"sprig"`, or `"both"`.    | `"dockerize"` |
| `server.setConfigFilePath`   | Set `TEMPORAL_SERVER_CONFIG_FILE_PATH` environment variable.              | `false`       |

Refer to the following guidelines to determine if you need to adjust the configuration options:

- The default settings work if you are only using pre-1.30 images with 0.73.1 or later Helm chart.
- If you are using 1.30+ images with 0.73.1 or later Helm chart, you need to set `server.configMapsToMount` to `"sprig"`
  and `server.setConfigFilePath` to `true`. Keep the `server.useEntrypointScript` as `false`.
- If you need use the Helm chart with both pre-1.30 and 1.30+ images, you need to set `server.configMapsToMount` to
  `"both"` and `server.useEntrypointScript` to `true`. Keep the `server.setConfigFilePath` as `false`.

## Import the Server package

The Temporal Server is a standalone Go application that can be [imported](/references/server-options) into another
project.

You might want to do this to pass custom plugins or any other customizations through the
[Server Options](/references/server-options). Then you can build and run a binary that contains your customizations.

This requires Go v1.19 or later, as specified in the Temporal Server
[Build prerequisites](https://github.com/temporalio/temporal/blob/main/CONTRIBUTING.md#build-prerequisites).

## Use Helm charts

[Temporal Helm charts](https://github.com/temporalio/helm-charts) enable you to get a Temporal Service running on
[Kubernetes](https://kubernetes.io/) by deploying the Temporal Server services to individual pods and connecting them to
your existing database and Elasticsearch instances.

The Temporal Helm charts repo contains
[extensive documentation](https://github.com/temporalio/helm-charts/blob/main/README.md) about Kubernetes deployments.

> **⚠️ Caution:**
> Helm Chart version compatibility
>
> If you are using Temporal Server images 1.30+, you must upgrade to Helm chart version 0.73.1 or later.
>
> Helm chart versions below 0.73.1 are **not compatible** with `server` and `admin-tools` images **version 1.30 and
> later**. You **cannot** override old chart versions with newer images.
>
