mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
Add docs for PM2 integration, update Docker/Docker-Compose integration docs
This commit is contained in:
@@ -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 |
|
||||
|
||||
@@ -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
|
||||
|
||||
<Info>
|
||||
If you have multiple services and they do not use the same secrets, you will
|
||||
have to generate a Infisical Token for each service.
|
||||
</Info>
|
||||
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}
|
||||
```
|
||||
|
||||
@@ -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
|
||||
|
||||
<Tabs>
|
||||
<Tab title="Alpine">
|
||||
@@ -32,32 +34,32 @@ Infisical can be used in a Dockerfile to inject environment variables into a Doc
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
## Modify your Dockerfile start command
|
||||
## Modify the start command in your Dockerfile
|
||||
|
||||
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.
|
||||
Starting your service with the Infisical CLI pulls your secrets from Infisical and injects them into your service.
|
||||
|
||||
```dockerfile
|
||||
CMD ["infisical", "run", "---", "[your application start command]"]
|
||||
```dockerfile
|
||||
CMD ["infisical", "run", "---", "[your service 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 && ..."]
|
||||
```
|
||||
|
||||
View more options for the `run` command [here](../../cli/commands/run)
|
||||
## Generate an Infisical Token
|
||||
|
||||
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
|
||||
<Info>
|
||||
|
||||
[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.
|
||||
|
||||
</Info>
|
||||
|
||||
52
docs/integrations/platforms/pm2.mdx
Normal file
52
docs/integrations/platforms/pm2.mdx
Normal file
@@ -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
|
||||
|
||||
<CodeGroup>
|
||||
|
||||
```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}`));
|
||||
```
|
||||
|
||||
</CodeGroup>
|
||||
|
||||
## Start your application as usual but with the script
|
||||
|
||||
<CodeGroup>
|
||||
|
||||
```bash infisical-run.sh
|
||||
pm2 start infisical-run.sh
|
||||
```
|
||||
|
||||
```bash infisical-run.js
|
||||
pm2 start infisical-run.js
|
||||
```
|
||||
|
||||
</CodeGroup>
|
||||
@@ -209,7 +209,8 @@
|
||||
"pages": [
|
||||
"integrations/platforms/docker",
|
||||
"integrations/platforms/docker-compose",
|
||||
"integrations/platforms/kubernetes"
|
||||
"integrations/platforms/kubernetes",
|
||||
"integrations/platforms/pm2"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user