import { Layout } from "@/components/docs/Layout";
import { Fence } from "@/components/shared/Fence";
import { Callout } from "@/components/shared/Callout";

export const meta = {
  title: "Deploying Formbricks to production",
  description:
    "Utilize Docker-Compose for easy deployment on your machine. Clone the repo, configure settings, and build the image to access the app on localhost.",
};

<Callout title="Public Beta" type="warning">
  Formbricks is not yet stable. Please reach out to us when you deploy Formbricks in production:
  hola@formbricks.com
</Callout>

## Deploy with Docker-Compose

The easiest way to deploy Formbricks on your own machine is using Docker. This requires Docker and the docker compose plugin on your system to work.

Clone the repository:

```bash
git clone https://github.com/formbricks/formbricks.git && cd formbricks
```

Create a `.env` file based on `.env.docker` and change all fields according to your setup. This file comes with a basic setup and Formbricks works without making any changes to the file. To enable email sending functionality you need to configure the SMTP settings in the `.env` file. If you configured your email credentials, you can also comment the following lines to enable email verification (`# NEXT_PUBLIC_EMAIL_VERIFICATION_DISABLED=1`) and password reset (`# NEXT_PUBLIC_PASSWORD_RESET_DISABLED=1`)

Copy the `.env.docker` file to `.env` and edit it with an editor of your choice if needed.

```bash
cp .env.docker .env
```

Note: The environment variables are used at build time. When you change environment variables later, you need to rebuild the image with `docker compose build` for the changes to take effect.

Finally start the docker compose process to build and spin up the Formbricks container as well as the PostgreSQL database.

```bash
docker compose up -d
# (use docker-compose if you are on an older docker version)
```

You can now access the app on [http://localhost:3000](http://localhost:3000). You will be automatically redirected to the login. To use your local installation of Formbricks, create a new account.

## Stop the containers

To stop the containers, run:

```bash
docker compose down
```

## Update Formbricks

To update Formbricks, pull the latest changes from the repository:

```bash
git pull
```

and rebuild the image:

```bash
docker compose build
```

Then you can stop and restart the containers again:

```bash
docker compose down
docker compose up -d
```

## Debugging

If you encounter any issues, you can check the logs of the container with:

```bash
docker compose logs -f
```

You can close the logs again with `CTRL + C`.

export default ({ children }) => <Layout meta={meta}>{children}</Layout>;
