skip to Main Content

We can start stripe-cli from terminal using command:
docker run --rm -it stripe/stripe-cli listen --forward-to http://127.0.0.1:8080/stripe/webhook --api-key sk_API-KEY

but how could I add this service to already existing docker-compose file, which works well both on localhost and in AWS? I want to hit a specific endpoint in javaapp whenever stripe-cli detects an event.

Example docker-compose file which should be extended:

version: "3.8"
services:

  https:
    build:
      context: ./docker/nginx
    ports:
      - 443:443
      - 80:80
    extra_hosts:
      - host.docker.internal:host-gateway

  javaapp:
    image: 1.dkr.ecr.eu-west-1.amazonaws.com/JAVA_APP:${JAVA_APP:-latest}
    ports:
      - 8080:8080
    environment:
      JAVA_OPTS: -java.app.config=/etc/config.groovy
    volumes:
      - ./configuration/application/java/ExternalConfig.docker.groovy:/etc/config.groovy
    extra_hosts:
      - host.docker.internal:host-gateway
    profiles:
      - javaapp

  redis:
    image: redis:6.2.6-alpine
    ports:
      - 6379:6379
    volumes:
      - company-redis:/data

  mongo:
    image: mongo:3.6.12
    ports:
      - 27017:27017
    volumes:
      - company-mongo:/data/db/
      
volumes:
  company-mongo:
  company-redis:

2

Answers


  1. Chosen as BEST ANSWER

    If I add to docker-compose.yml file section:

      stripe-cli:
        image: stripe/stripe-cli
        container_name: stripe-cli
        command: "listen --api-key sk_test_TOKEN --skip-verify --forward-to 192.168.96.1:8080/webapp/stripe/events"
    

    it works on localhost, but it fails on a staging server.

    I tried to substitute --forward-to 192.168.96.1:8080/webapp/stripe/events with --forward-to javaapp:8080/webapp/stripe/events but it fails with:

    [ERROR] Failed to POST: Post "http://javaapp:8080/webapp/stripe/events": dial tcp: lookup javaapp on 127.0.0.11:53: server misbehaving
    

    I tried to substitute --forward-to 192.168.96.1:8080/webapp/stripe/events with --forward-to localhost:8080/webapp/stripe/events but it fails with:

    [ERROR] Failed to POST: Post "http://localhost:8080/webapp/stripe/events": dial tcp 127.0.0.1:8080: connect: connection refused
    

  2. There’s guidance for leveraging the Docker image of Stripe CLI in the README (link). You will likely need to adapt these steps to work with your docker-compose case, including the noted details about the password store.

    Since you mentioned both local and hosted flows, note that this should only be required for local/non-publicly-accessible endpoints. If you’re deploying to a public endpoint, you could instead leverage the Webhook Endpoints Create API (ref) to create a new endpoint for your new public endpoint as part of the deploy sequence, and if temporary then delete it when the endpoint is destroyed.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search