Container management
Environment variables

Environment variables

Our platform provides a way to send environment variables to your services. When the container service starts, it will have access to these variables in its environment.

Configuration file's variables

To send variables to a service, you must declare your environment variable in a variables object inside the configuration file of the service See configuration file. The property names of this object will be the name of your variables. Their value can be a string, an empty string or an object.

Example of warp.config.js

module.exports = {
  docker: "docker",
  variables: {
    myfirstvar: "value",
    mysecondvar: "",
    mythirdvar: {
      local: true,
    },
  },
};

If it is an object (like for mythirdvar in the previous example), then its possible values are:

{
  local: true,
}

In this case, the value will be taken from the shell environment variable.

{
  empty: true,
}

In this case, the variable will be declared but not assigned a value.

{
  undef: true,
}

In this case, the variable will be undefined.

Default exported variables

General

  • WARP_PROJECT_ID, the project ID where the service is deployed,
  • WARP_PROJECT, the project name where the service is deployed,
  • WARP_ENV_ID, the environment ID where the service is deployed,
  • WARP_ENV, the environment name where the service is deployed,
  • WARP_SERVICE_ID, the service ID of the deployed service,
  • WARP_SERVICE, the service name of the deployed service,
  • WARP_DEPLOYMENT_ID, the deployment ID,
  • WARP_DEPLOYMENT, the deployment name,
  • WARP_RUNNER_ID, the runner ID where the service is deployed,
  • WARP_RUNNER, the runner name where the service is deployed,

For a server service only

WARP_PORT

Contains the port your server listens on.

For example:

const express = require("express");
const app = express();
const port = process.env.WARP_PORT;
 
app.get("/", (req, res) => {
  res.send("Hello World!");
});
 
app.listen(port, () => {
  console.log(`Example app listening at http://localhost:${port}`);
});

PATH

Contains the path of the operating system.