diff --git a/docs/integrations/overview.mdx b/docs/integrations/overview.mdx index 4f1e992278..36423e787c 100644 --- a/docs/integrations/overview.mdx +++ b/docs/integrations/overview.mdx @@ -12,6 +12,7 @@ Missing an integration? Throw in a [request](https://github.com/Infisical/infisi | [Docker](/integrations/platforms/docker) | Platform | Available | | [Docker-Compose](/integrations/platforms/docker-compose) | Platform | Available | | [Kubernetes](/integrations/platforms/kubernetes) | Platform | Available | +| [PM2](/integrations/platforms/pm2) | Platform | Available | | [Heroku](/integrations/cloud/heroku) | Cloud | Available | | [Vercel](/integrations/cloud/vercel) | Cloud | Available | | [Netlify](/integrations/cloud/netlify) | Cloud | Available | diff --git a/docs/integrations/platforms/docker-compose.mdx b/docs/integrations/platforms/docker-compose.mdx index 698316582e..e030869e33 100644 --- a/docs/integrations/platforms/docker-compose.mdx +++ b/docs/integrations/platforms/docker-compose.mdx @@ -1,45 +1,38 @@ --- title: "Docker Compose" -description: "How to use Infisical to inject environment variables into container defined in your Docker Compose file." +description: "How to use Infisical to inject environment variables into services defined in your Docker Compose file." --- -The Docker Compose integration enables you to inject environment variables from Infisical into the containers defined in your compose file. +Prerequisites: -## Add the CLI to your Dockerfile(s) start command +- Set up and add envars to [Infisical Cloud](https://app.infisical.com) -Follow the [guide to configure Infisical CLI](./docker) in your your Dockerfile first. +## Configure the Infisical CLI for each service -## Generate Infisical Token +Follow this [guide](./docker) to configure the Infisical CLI for each service that you wish to inject environment variables into; you'll have to update the Dockerfile of each service. -In order for Infisical CLI to authenticate and retrieve your project's secrets without exposing your login credentials, you must generate a Infisical Token. -To learn how, visit [Infisical Token](../../getting-started/dashboard/token). Once you have generated the token, keep it handy. +## Generate Infisical Tokens - - If you have multiple services and they do not use the same secrets, you will - have to generate a Infisical Token for each service. - +Generate a unique [Infisical Token](https://infisical.com/docs/getting-started/dashboard/token) for each service. -## Tell Docker Compose your Infisical Token +## Add Infisical Tokens to your Docker Compose file -For each service you want to inject secrets into, set an environment variable called `INFISICAL_TOKEN` equal to a helpful identifier variable. -This will ensure that you can set Infisical Tokens for multiple services. +For each service you want to inject secrets into, set an environment variable called `INFISICAL_TOKEN` equal to a unique identifier variable. -For the example below, we have set `INFISICAL_TOKEN_FOR_WEB` and `INFISICAL_TOKEN_FOR_API` as the `INFISICAL_TOKEN` for the corresponding service. +In the example below, we set `INFISICAL_TOKEN_FOR_WEB` and `INFISICAL_TOKEN_FOR_API` as the `INFISICAL_TOKEN` for the services. ```yaml # Example Docker Compose file services: web: build: . - image: auledge-frontend - container_name: auledge-frontend + image: example-service-1 environment: - INFISICAL_TOKEN=${INFISICAL_TOKEN_FOR_WEB} api: build: . - image: auledge-backend - container_name: auledge-backend + image: example-service-2 environment: - INFISICAL_TOKEN=${INFISICAL_TOKEN_FOR_API} ``` diff --git a/docs/integrations/platforms/docker.mdx b/docs/integrations/platforms/docker.mdx index 8f53336ed6..b4224d6d06 100644 --- a/docs/integrations/platforms/docker.mdx +++ b/docs/integrations/platforms/docker.mdx @@ -3,9 +3,11 @@ title: "Docker" description: "How to use Infisical to inject environment variables into a Docker container." --- -Infisical can be used in a Dockerfile to inject environment variables into a Docker container. +Prerequisites: -## Add the CLI to your Dockerfile +- Set up and add envars to [Infisical Cloud](https://app.infisical.com) + +## Add the Infisical CLI to your Dockerfile @@ -32,32 +34,32 @@ Infisical can be used in a Dockerfile to inject environment variables into a Doc - ## Modify your Dockerfile start command +## Modify the start command in your Dockerfile + +Starting your service with the Infisical CLI pulls your secrets from Infisical and injects them into your service. - To make your Docker container consume Infisical secrets, you can start your application with Infisical. - This will automatically pull the necessary secrets and make them available to your application as if they were natively exposed within the container. +```dockerfile +CMD ["infisical", "run", "---", "[your service start command]"] - ```dockerfile - CMD ["infisical", "run", "---", "[your application start command]"] +# example with single single command +CMD ["infisical", "run", "---", "npm run start"] - # example with single single command - CMD ["infisical", "run", "---", "npm run start"] +# example with multiple commands +CMD ["infisical", "run", "--command", "npm run start && ..."] +``` - # example with multiple commands - CMD ["infisical", "run", "--command", "npm run start && ..."] - ``` +## Generate an Infisical Token - View more options for the `run` command [here](../../cli/commands/run) +Head to your project settings in Infisical Cloud to generate an [Infisical Token](https://infisical.com/docs/getting-started/dashboard/token). ## Feed Docker your Infisical Token -The CLI looks out for an environment variable called `INFISICAL_TOKEN`. If the token is detected, the CLI will authenticate, retrieve, and inject the environment variables which the token is authorized for. - ```bash docker run --env INFISICAL_TOKEN=[token]... ``` -## Generate an Infisical Token + -[Generate an Infisical Token](../../getting-started/dashboard/token) and keep it handy. +The Infisical CLI uses the detected `INFISICAL_TOKEN` environment variable to authenticate, retrieve, and inject the environment variables which the token is authorized for. + diff --git a/docs/integrations/platforms/pm2.mdx b/docs/integrations/platforms/pm2.mdx new file mode 100644 index 0000000000..e9b04bbb20 --- /dev/null +++ b/docs/integrations/platforms/pm2.mdx @@ -0,0 +1,52 @@ +--- +title: "PM2" +description: "How to use Infisical to inject environment variables and secrets with PM2 into a Node.js app" +--- + +Prerequisites: + +- Set up and add envars to [Infisical Cloud](https://app.infisical.com) +- [Install the CLI](/cli/overview) + +## Initialize Infisical for your Node.js app + +```bash +# navigate to the root of your of your project +cd /path/to/project + +# then initialize infisical +infisical init +``` + +## Create a bash or js script + + + +```bash infisical-run.sh +infisical run -- npm start +``` + +```js infisical-run.js +const spawn = require("child_process").spawn; + +const infisical = spawn("infisical", ["run", "--", "npm", "start"]); + +infisical.stdout.on("data", (data) => console.log(`${data}`)); +infisical.stderr.on("data", (data) => console.error(`${data}`)); +``` + + + +## Start your application as usual but with the script + + + +```bash infisical-run.sh +pm2 start infisical-run.sh +``` + +```bash infisical-run.js +pm2 start infisical-run.js +``` + + diff --git a/docs/mint.json b/docs/mint.json index 4ce1d6c03e..4417691523 100644 --- a/docs/mint.json +++ b/docs/mint.json @@ -209,7 +209,8 @@ "pages": [ "integrations/platforms/docker", "integrations/platforms/docker-compose", - "integrations/platforms/kubernetes" + "integrations/platforms/kubernetes", + "integrations/platforms/pm2" ] }, {