I have the augmented localstack image in this Dockerfile.localstack.dev:
FROM localstack/localstack
RUN apk update
RUN apk add bash
ENV WAITFORIT_VERSION="v2.4.1"
RUN curl -o /usr/local/bin/waitforit -sSL https://github.com/maxcnunes/waitforit/releases/download/$WAITFORIT_VERSION/waitforit-linux_amd64 && \
chmod +x /usr/local/bin/waitforit
And I would like to run the awslocal script to create a queue when the localstack container is spun up and ready.
and this is my docker-compose.yml file:
version: '3'
services:
localstack:
build:
dockerfile: Dockerfile.localstack.dev
context: .
environment:
SERVICES: "firehose,kinesis,lambda,s3,sns,ses,sqs,dynamodb"
ports:
- "4561-4583:4561-4583"
command: waitforit -address=http://localstack:4576 -timeout=150 -retry=3000 -- awslocal sqs create-queue --queue-name testqueue
I am using watforit to wait for the container to start up. (credit to https://github.com/localstack/localstack/issues/732)
however, after the local stack container startup, I don't see the testqueue been created inside the container.
Thanks for reporting @7seven7lst . The waitforit based approach does not work anymore since we've switched to supervisord to start up the init process.
The recommended way of bootstrapping your container is by mounting a /docker-entrypoint-initaws.d directory that contains shell init scripts. Please see the README for details: https://github.com/localstack/localstack#initializing-a-fresh-instance
Hope that helps - please re-open this issue if the problem persists. Thanks
@whummer
Thanks for pointing this! I will look into it and it should solve my question.
I still have a question: If I have a localstack docker container and another service container managed by docker-compose.yml, how would my other service container know that localstack container is "Ready" ready? something like waitforit would still work?
version: '3'
services:
otherservice:
...OMITTING_DETAILS...
command: waitforit -address=http://localstack:4576 -timeout=150 -retry=3000 <start_command>
@7seven7lst you could grep the output of the container, and once you hit the output line Ready., you can assume that the services are ready.
We're following this approach also in other places, e.g., the JUnit test runner for Java: https://github.com/localstack/localstack/blob/45bafca1889bda7593e282e1c5f92f059ca4cede/localstack/ext/java/src/main/java/cloud/localstack/Localstack.java#L84