Hello.
I'm trying to configure an APM server as a service in a docker-compose file. I'm doing this by setting some environment variables. This works for Elasticsearch and Kibana (although very differently, for Elasticsearch I can just usexpack.security.enabled
but for Kibana I have to translate the vars to XPACK_SECURITY_ENABLED
).
The thing is, I'm not letting the image's default CMD run. Instead of that, I'm running a script that waits until Elasticsearch service is up and running and then runs APM server's entrypoint. Like this:
docker-compose.yml:
apm-server:
container_name: apm-server_$ELASTIC_VERSION
image: ffknob.com.br/apm-server:$ELASTIC_VERSION
build:
context: apm-server/
args:
- ELASTIC_VERSION=$ELASTIC_VERSION
volumes:
- shared:/shared
- certs:/usr/share/apm-server/config/certs/:ro
ports:
- 8200:8200
environment:
- apm-server.host=apm-server:8200
- apm-server.ssl.enaled=true
- apm-server.ssl.key=config/certs/apm-server.key
- apm-server.ssl.certificate=config/certs/apm-server.crt
- apm-server.ssl.key_passphrase=$APM_SERVER_CERT_PASSWORD
- apm-server.secret_token=$APM_SERVER_SECRET_TOKEN
- output.elasticsearch.hosts=["elasticsearch01:9200","elasticsearch02:9200","elasticsearch03:9200"]
- output.elasticsearch.username=apm_system
- output.elasticsearch.password=$APM_SYSTEM_USER_PASSWORD
- output.elasticsearch.protocol=https
networks:
- elastic
depends_on:
- elasticsearch01
Dockerfile:
ARG ELASTIC_VERSION
FROM docker.elastic.co/apm/apm-server:$ELASTIC_VERSION
COPY wait-for-bootstrap.sh /
CMD [ "/wait-for-bootstrap.sh", "/usr/local/bin/docker-entrypoint", "-e" ]
wait-for-bootstrap.sh:
#!/bin/sh
set -e
CMD="$@"
ELASTICSEARCH_BOOTSTRAP_READY_FILE=/shared/bootstrap/bootstrap.ready
if [[ ! -f ${ELASTICSEARCH_BOOTSTRAP_READY_FILE} ]]
then
>&2 echo "Elasticsearch bootstrap not ready yet. Waiting..."
until [ -f ${ELASTICSEARCH_BOOTSTRAP_READY_FILE} ]
do
sleep 1
done
fi
>&2 echo "Elasticsearch bootstrap finished."
exec ${CMD}
Result: The APMserver runs (apm-server -e), but all the environment variables I've set in the docker-compose.yml are ignored.
So, what am I doing wrong?
Thank you!