Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ services:
depends_on:
elasticsearch: { condition: service_healthy }
kibana: { condition: service_healthy }
fleet-server: { condition: service_healthy }

elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:8.1.0-dbc834fd-SNAPSHOT
Expand Down Expand Up @@ -63,6 +64,7 @@ services:

fleet-server:
image: docker.elastic.co/beats/elastic-agent:8.1.0-dbc834fd-SNAPSHOT
entrypoint: /entrypoint.sh
ports:
- 8220:8220
healthcheck:
Expand All @@ -72,8 +74,6 @@ services:
environment:
FLEET_SERVER_ENABLE: "1"
FLEET_SERVER_ELASTICSEARCH_HOST: http://elasticsearch:9200
FLEET_SERVER_ELASTICSEARCH_USERNAME: "${ES_SUPERUSER_USER:-admin}"
FLEET_SERVER_ELASTICSEARCH_PASSWORD: "${ES_SUPERUSER_PASS:-changeme}"
FLEET_SERVER_CERT: /etc/pki/tls/certs/fleet-server.pem
FLEET_SERVER_CERT_KEY: /etc/pki/tls/private/fleet-server-key.pem
FLEET_URL: https://fleet-server:8220
Expand All @@ -85,6 +85,7 @@ services:
elasticsearch: { condition: service_healthy }
kibana: { condition: service_healthy }
volumes:
- "./testing/docker/fleet-server/docker-entrypoint.sh:/entrypoint.sh"
- "./testing/docker/fleet-server/certificate.pem:/etc/pki/tls/certs/fleet-server.pem"
- "./testing/docker/fleet-server/key.pem:/etc/pki/tls/private/fleet-server-key.pem"

Expand Down
16 changes: 16 additions & 0 deletions testing/docker/fleet-server/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

SERVICE_TOKEN_FILE=service_token

if [[ ! -f ${SERVICE_TOKEN_FILE} ]]; then
jsonBody="$(curl -u${KIBANA_USERNAME}:${KIBANA_PASSWORD} -fsSL -XPOST \
"${FLEET_SERVER_ELASTICSEARCH_HOST}/_security/service/elastic/fleet-server/credential/token/compose")"
# use grep and sed to get the service token value as we may not have jq or a similar tool on the instance
token=$(echo ${jsonBody} | grep -Eo '"value"[^}]*' | grep -Eo ':.*' | sed -r "s/://" | sed -r 's/"//g')

echo ${token} > ${SERVICE_TOKEN_FILE}
fi

export FLEET_SERVER_SERVICE_TOKEN=$(cat ${SERVICE_TOKEN_FILE})

/usr/bin/tini -s -- /usr/local/bin/docker-entrypoint