--- title: "Fly.io" description: "Deploy Infisical with Fly.io" --- Prerequisites: - Have an account with [Fly.io](https://fly.io/) - Have installed the [Fly.io CLI](https://fly.io/docs/hands-on/install-flyctl/) In your terminal, run the following command from the source directory of your project to create a new Fly.io app with a `fly.toml` configuration file: ``` fly launch ``` Add a **build** section to the `fly.toml` file to specify the [Infisical public Docker image](https://hub.docker.com/r/infisical/infisical): ``` [build] image = "infisical/infisical:v0.43.4" ``` Afterwards, your `fly.toml` file should look similar to: ``` app = "infisical" primary_region = "lax" [http_service] internal_port = 8080 force_https = true auto_stop_machines = true auto_start_machines = true min_machines_running = 0 processes = ["app"] [[vm]] cpu_kind = "shared" cpus = 1 memory_mb = 1024 [build] image = "infisical/infisical:v0.43.4" ``` Depending on your use-case and requirements, you may find it helpful to further configure your `fly.toml` file with options [here](https://fly.io/docs/reference/configuration/). For example, you may want to adjust the `primary-region` option to specify which [region](https://fly.io/docs/reference/regions/) to create the new machine for your instance of Infisical to minimize distance and therefore latency between the instance and your infrastructure. Running Infisical requires a few environment variables to be set on the Fly.io machine. At minimum, Infisical requires that you set the variables `ENCRYPTION_KEY`, `AUTH_SECRET`, `MONGO_URL`, and `REDIS_URL` which you can read more about [here](/self-hosting/configuration/envars). For this step, we recommend setting the variables as Fly.io [app secrets](https://fly.io/docs/reference/secrets/) which are made available to the app as environment variables. You can set the variables either via the Fly.io CLI or project [dashboard](https://fly.io/dashboard). Run the following command (with each `VALUE` replaced) in the source directory of your project to set the required variables: ``` flyctl secrets set ENCRYPTION_KEY=VALUE AUTH_SECRET=VALUE MONGO_URL=VALUE REDIS_URL=VALUE... ``` In Fly.io, head to your Project > Secrets and add the required variables. ![Fly.io deployment secrets](/images/self-hosting/deployment-options/flyio/flyio-secrets.png) To use more features like emailing and single sign-on, you can set additional configuration options [here](/self-hosting/configuration/envars). Finally, run the following command in the source directory of your project to deploy your Infisical instance on Fly.io with the updated `fly.toml` configuration file from step 2 and secrets from step 3: ``` fly deploy ``` Yes, here are a few that come to mind: - In step 2, we recommend pinning the Docker image to a specific [version of Infisical](https://hub.docker.com/r/infisical/infisical/tags) instead of referring to the `latest` tag to avoid any unexpected version-to-version migration issues. - In step 2, we recommend selecting a `primary_region` option that is closest to your infrastructure/clients to reduce latency; a full list of regions supported by Fly.io can be found [here](https://fly.io/docs/reference/regions/). We're working on putting together a fuller list of deployment best practices as well as minimum resource configuration requirements for running Infisical so stay tuned! Resources: - [Fly.io documentation](https://fly.io/docs/)