Selfhosting

Information on selfhosting Env Tree

Depending on your requirements you may wish to selfhost Env Tree, this documentation covers setup and possible configuration options for a self hosted enviroment

With Railway

To host with railway please use the template

Deploy on Railway

At least one method of authentication must be provided

GitHub Authentication

Callback url must be set to https://<railway url>/api/auth/callback/github

GitLab Authentication

Callback url must be set to https://<railway url>/api/auth/callback/gitlab

Required scopes must be at least read_user

With Docker

To the basic setup will use the docker image provided with Github and Gitlab authentication options.

  1. Pull the docker image docker pull ghcr.io/maxs-rose/env-tree
  2. Create a .env file containing the configuration for your selfhosted enviroment:
    DATABASE_URL=postgresql://<postgresurl>
    CONFIG_ENCRYPTION_SECRET=<secret>
    GITHUB_ID=<id>
    GITHUB_SECRET=<secret>
    GITLAB_ID=<id>
    GITLAB_SECRET=<secret>
    NEXTAUTH_URL=<url>
    NEXTAUTH_SECRET=<secret>
    CONFIG_AUDIT_RETENTION=<integer> # Default 0
  3. Start the container docker run -d --name env-tree -p 3000:3000 --env-file .env ghcr.io/maxs-rose/env-tree

At least one method of authentication must be provided

GitHub Authentication

Callback url must be set to https://<url>/api/auth/callback/github

GitLab Authentication

Callback url must be set to https://<url>/api/auth/callback/gitlab

Required scopes must be at least read_user

Advanced Setup: Building from Source

To build and run Env Tree from source:

  1. Clone the repo
  2. Run yarn install
  3. Under apps > cloud create a .env file with the following settings:
    DATABASE_URL=postgresql://<postgresurl>
    CONFIG_ENCRYPTION_SECRET=<secret>
    GITHUB_ID=<id>
    GITHUB_SECRET=<secret>
    GITLAB_ID=<id>
    GITLAB_SECRET=<secret>
    NEXTAUTH_URL=<url>
    NEXTAUTH_SECRET=<secret>
    CONFIG_AUDIT_RETENTION=<integer> # Default 0
  4. Run yarn prisma generate
  5. Run yarn build --filter cloud
  6. Finally to start the application run yarn start --filter cloud

Note: This is also applicable to development setups

Altering Authentication Providers

If you wish to alter the available login providers this can be done by editing apps > cli > cloud > src > pages > api > auth > [...nextauth].ts then editing the getProviders function. Please refer to the Next Auth documentation for configuration of this section

Advanced Setup: Altering default CLI url

If you also wish to edit the node CLI to default to your selfhosted url:

  1. Edit index.ts in apps > cli > src > utils > consts.ts
  2. Replace defaultUrl = 'https://secrets-production.up.railway.app/' with your custom URL
  3. Run yarn build --filter cli
  4. You can now publish your custom cli to your selfhosted/private package repo