You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Dispenser allows you to securely retrieve sensitive values, such as API keys or passwords, directly from Google Cloud Secret Manager. These secrets are accessed at runtime and injected into your configuration variables.
4
+
5
+
## Prerequisites
6
+
7
+
To use this feature, the environment where Dispenser is running (e.g., a Google Compute Engine VM) must be authenticated with Google Cloud and have permission to access the secrets.
8
+
9
+
1.**Service Account**: Ensure the Virtual Machine (VM) is running with a Service Account that has the **Secret Manager Secret Accessor** role (`roles/secretmanager.secretAccessor`).
10
+
2.**Authentication**: If running outside of GCP, you may need to set the `GOOGLE_APPLICATION_CREDENTIALS` environment variable pointing to a service account key file.
11
+
12
+
## Configuration
13
+
14
+
You can define secrets in your `dispenser.vars` file. Instead of a plain string value, use a table to specify the secret source and details.
15
+
16
+
### Syntax
17
+
18
+
```toml
19
+
variable_name = { source = "google", name = "projects/PROJECT_ID/secrets/SECRET_NAME" }
20
+
```
21
+
22
+
-`source`: Must be set to `"google"`.
23
+
-`name`: The full resource name of the secret. This typically follows the format `projects/<PROJECT_ID>/secrets/<SECRET_NAME>`.
24
+
-`version` (Optional): The version of the secret to retrieve. Defaults to `"latest"` if not specified.
25
+
26
+
## Example
27
+
28
+
Suppose you have a secret stored in Google Secret Manager that contains an OAuth Client ID.
29
+
30
+
**1. Define the secret in `dispenser.vars`:**
31
+
32
+
```toml
33
+
# dispenser.vars
34
+
35
+
# Regular variable
36
+
docker_registry = "docker.io"
37
+
38
+
# Secret variable from Google Secret Manager
39
+
oauth_client_id = { source = "google", name = "projects/123456789012/secrets/MY_OAUTH_CLIENT_ID" }
40
+
41
+
# Secret variable with a specific version
42
+
db_password = { source = "google", name = "projects/123456789012/secrets/DB_PASSWORD", version = "2" }
43
+
```
44
+
45
+
**2. Use the variable in `dispenser.toml` or `docker-compose.yaml`:**
46
+
47
+
Once defined, these variables can be used just like any other variable in Dispenser.
48
+
49
+
In `dispenser.toml`:
50
+
```toml
51
+
[[instance]]
52
+
path = "my-service"
53
+
# ...
54
+
```
55
+
56
+
In your service's `docker-compose.yaml`:
57
+
```yaml
58
+
services:
59
+
app:
60
+
image: my-app:latest
61
+
environment:
62
+
- CLIENT_ID=${oauth_client_id}
63
+
- DB_PASS=${db_password}
64
+
```
65
+
66
+
When Dispenser runs, it will fetch the actual values from Google Secret Manager and make them available to your Docker Compose configuration.
@@ -193,6 +193,8 @@ This is useful for reusing the same configuration in multiple deployments.
193
193
app_version = "latest"
194
194
```
195
195
196
+
Dispenser also supports fetching secrets from Google Secret Manager. For more details on configuring secrets, see the [GCP secrets documentation](GCP.md).
197
+
196
198
3. Use these variables in your `dispenser.toml`.
197
199
198
200
```toml
@@ -267,6 +269,30 @@ No referenced variables
267
269
268
270
From now on, whenever you push a new image to your registry with the `latest` tag, Dispenser will automatically detect it, pull the new version, and redeploy your service with zero downtime.
269
271
272
+
### Managing the Service with CLI Signals
273
+
274
+
Dispenser includes a built-in mechanism to send signals to the running daemon using the `-s` or `--signal` flag. This allows you to reload the configuration or stop the service without needing to use `kill` manually.
275
+
276
+
**Note:** This command relies on the `dispenser.pid` file, so you should run it from the same directory where Dispenser is running (typically `/opt/dispenser` for the default installation).
277
+
278
+
**Reload Configuration:**
279
+
280
+
To reload the `dispenser.toml` configuration without restarting the process:
281
+
282
+
```sh
283
+
dispenser -s reload
284
+
```
285
+
286
+
This is useful for adding new instances or changing configuration parameters without interrupting currently monitored services.
0 commit comments