Danny
Danny

Reputation: 455

String Interpolate environment variable in docker-compose

I have the following docker-compose.yml file:

version: '3.6'

services:
    stripe-cli:
        image: stripe/stripe-cli:latest
        container_name: stripe-cli
        secrets:
            - StripeSecretKey
        environment:
            StripeSecretKey: /run/secrets/StripeSecretKey
        command: --api-key ${StripeSecretKey} listen --forward-to http://localhost:5000/api/payment/webhook
            
secrets:
    StripeSecretKey:
        file: ./secrets/StripeSecretKey.txt

The secret 'StripeSecretKey' points to a text file which has the secret key being:

enter image description here

I am trying to string interpolate my secret key value in the command argumant of the stripe-cli container. But I am unable to do so with the above syntax.

I am getting the following warning when executing the above docker-compose file:

WARNING: The StripeSecretKey variable is not set. Defaulting to a blank string.

I would appreciate the help.

Upvotes: 1

Views: 2117

Answers (1)

Nuxilius
Nuxilius

Reputation: 13

Try like this

        environment:
            STRIPE_API_KEY: /run/secrets/StripeSecretKey
        command: listen --forward-to http://localhost:5000

https://stripe.com/docs/cli/api_keys You can set two environment variables, which take precedence over all other values:

STRIPE_API_KEY: the API key to use for the CLI.
STRIPE_DEVICE_NAME: the device name for the CLI, visible in the Dashboard.

Upvotes: 1

Related Questions