How to create a new development environment

Expected behavior

I expect to be able to find complete documentation about how to create a new development environment.

Actual behavior

The documentation that I can find is unclear and / or incomplete.

Here are the steps that I have taken:

  1. navigate to project settings => environments and then click the “add new environment” button.
  2. provide an environment name (DEV-Developer) and a URL (http://localhost:3310)
  3. see the “environment secret”

Now what?
I’m unclear about the arguments to provide to either the docker-based or npm-based install.

For the docker-based install, the document describes a “FOREST_TOKEN” argument. Providing the environment secret as the “FOREST_TOKEN” fails with a message that the project already exists. I can’t find any documentation for any flags that would specify that this is a new environment for an existing project.

The NPM install process consistently fails to connect to my database. I’ve installed psql and confirmed that I can connect with the same connection parameters. My postres database is running in docker and I can connect to it with the hostname “0.0.0.0” or “localhost” or “host.docker.internal” but each of these result in the “Connecting to your database” message being displayed indefinitely from the “lumber generate” command.

I’ve also tried creating a completely new project (via the docker install method) and then trying to edit the .env file to point to my desired project but also without success.

Failure Logs

Try to use the docker run command to do an install for the new environment:

docker run \

-v pwd:/usr/src/app --init
-e DATABASE_URL=postgres://postgres:postgrespassword@host.docker.internal:5432/postgres
-e APP_NAME=cm-admin-proto
-e FOREST_EMAIL=jesse@canada-market.com
-e FOREST_TOKEN={ENVIRONMENT SECRET HERE}
-ti forestadmin/lumber-forestadmin

Fails as follows:

e[Ke[?25h/usr/local/bin/lumber → /usr/local/lib/node_modules/lumber-cli/lumber.js

  • lumber-cli@2.7.3
    updated 1 package in 4.234s
    e[33m>e[39m Environment variable usage detected:
    e[33m>e[39m - DATABASE_URL
    e[33m>e[39m Environment variables are DEPRECATED and will be removed in the future major Lumber version. Please use command parameters instead.
    e[33m>e[39m Type lumber help for more information.
    e[31m>e[39m The directory e[31m/usr/src/app/cm-admin-protoe[39m already exists.
    e[31m>e[39m Please retry with another project name.

Context

Please provide any relevant information about your setup.

  • Package Version:?
  • Express Version:“~4.16.3”
  • Sequelize Version:“~5.15.1”
  • Database Dialect:“pg”: “~6.1.0”
  • Database Version:“pg”: “~6.1.0”
  • Project Name:“cm-admin-proto”

Hello @jesse-elve,

Welcome to the Forest Admin community and thank you for sharing this.

Could you please share the content of your docker-compose.yml file?

Also, did you create the project via our wizard?
The procedure is working on my end, but I get a more complex init command:

docker run \
  -v `pwd`:/usr/src/app --init \
  -e DATABASE_SCHEMA="public" \
  -e DATABASE_SSL="false" \
  -e DATABASE_URL="postgres://user:xxxxx@host.docker.internal:5432/model-testing" \
  -e APP_NAME="xxxxx" \
  -e FOREST_EMAIL="user@test.com" \
  -e FOREST_TOKEN="xxxxx" \
  -e APPLICATION_HOST="localhost" \
  -e APPLICATION_PORT="3310" \
  -ti forestadmin/lumber

Thanks for responding.

I initially created the project via the wizard, yes. However, you can’t put the same app name in twice and I’m trying to create a new environment for an existing project.

Here is my docker-compose.yml:

version: ‘3.4’
services:
app:
build:
context: .
dockerfile: Dockerfile
network: host
container_name: xxx
environment:
- APPLICATION_PORT=3310
- DATABASE_URL=postgres://postgres:xxx@localhost:5432/postgres
- DATABASE_SCHEMA=public
- DATABASE_SSL=false
- FOREST_AUTH_SECRET=asdf
- FOREST_ENV_SECRET=yyy
ports:
- “3310:3310”
volumes:
- ./:/usr/src/app

(With the “yyy” FOREST_ENV_SECRET value take from the the environment settings details page: https://app.forestadmin.com/xxx/Staging/Operations/settings/environments/details/Development)

Or maybe this is not even the right command at all and the “FOREST_TOKEN” is not really an issue. If I omit this param, I’m prompted for a password and the tool continues execution. However, it terminates with the following error:

:heavy_multiplication_x: Creating your project on Forest Admin

A project with this name already exists. Please choose another name.

If I try to change the environment secret of my local dev instance to the new environment secret, I cannot then start that instance: I tried updating the docker-compose.yml and also exporting local environment settings to match but “docker-compose up” then fails with “secret should be set”.

Again, all I’m looking for are simple steps to create a new dev environment and how to run it.

Do you have an environment where all is working alright for this project?

If so, you can try to duplicate your docker-compose.yml file, and update the FOREST_ENV_SECRET with the one found in the environment settings for the new environment.

Launch the new docker project and it should be good to go.