1

In Ghost 0.x, config was provided via a single config.js file with keys for each env.
In Ghost 1.0, config is provided via multiple config.json files

How do you provide environment variables in Ghost 1.0?

I would like to dynamically set the port value using process.env.port on Cloud9 IDE like so.

config.development.json

{
  "url": "http://localhost",
  "server": {
    "port": process.env.port,
    "host": process.env.IP
  }
}

When I run the application using ghost start with the following config, it says You can access your publication at http://localhost:2368, but when I go to http://localhost:2368 in http://c9.io it gives me an error saying No application seems to be running here!

{
  "url": "http://localhost:2368",
  "server": {
    "port": 2368,
    "host": "127.0.0.1"
  }
}
Ishan
  • 3,931
  • 11
  • 37
  • 59

1 Answers1

1

I managed to figure out how to do this.

Here is the solution incase if someone else is also trying to figure out how to do the same thing.

In your config.development.json file, add the following.

{
  "url": "http://{workspace_name}-{username}.c9users.io:8080",
  "server": {
    "port": 8080,
    "host": "0.0.0.0"
  }
}

Alternatively, run the following command in the terminal. This will dynamically get the value for the port and host environment variable and add the above content to the config.development.json file.

ghost config url http://$C9_HOSTNAME:$PORT
ghost config server.port $PORT
ghost config server.host $IP
Ishan
  • 3,931
  • 11
  • 37
  • 59