I am trying to use docker to manage the behind the scenes stuff for testing an application, where a few things need to run: mongo, redis, localstack, localstack data initialization and then the application. I am running the application outside of the docker, natively. To do this I am running docker compose up -d && node server.js
, but the problem is that I can't do it attached or the node command will never run, and if I do it detached the data initialization (setup-resources
) won't be finished before the node application runs.
My docker compose:
services:
mongo:
image: mongo
ports:
- "27017:27017"
redis:
image: redis
ports:
- "6379:6379"
depends_on:
- setup-resources
localstack:
image: localstack/localstack
ports:
- "4566:4566"
volumes:
- "${TMPDIR:-/tmp/localstack}:/tmp/localstack"
- "/var/run/docker.sock:/var/run/docker.sock"
setup-resources:
build: docker_dev/setup
restart: "no"
environment:
- AWS_ACCESS_KEY_ID=hidden
- AWS_SECRET_ACCESS_KEY=hidden
- AWS_DEFAULT_REGION=hidden
- ROOT_BUCKET
- DPS_ARTIFACTS_ROOT_BUCKET
- THUMBNAIL_BUCKET
depends_on:
- localstack
Setup resources dockerfile:
FROM mesosphere/aws-cli
ENTRYPOINT []
ENV ROOT_BUCKET ""
CMD aws --endpoint-url=http://localstack:4566 s3 mb s3://$ROOT_BUCKET-stage