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
If I add to docker-compose.yml file section:
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: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: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.