From d80caf6580629b26cf07b86db4a52a85af7a929a Mon Sep 17 00:00:00 2001 From: "Dimitri B." Date: Sat, 7 Dec 2024 19:42:30 +0100 Subject: [PATCH] Add possibility to define the timezone via the `TZ` env var in the docker containers Fixes #117 --- .env | 10 +++++++--- apm-server/Dockerfile | 7 +++++++ docker-compose.nodes.yml | 2 ++ docker-compose.setup.yml | 5 ++++- docker-compose.yml | 4 ++++ elasticsearch/Dockerfile | 7 +++++++ kibana/Dockerfile | 7 +++++++ logstash/Dockerfile | 7 +++++++ 8 files changed, 45 insertions(+), 4 deletions(-) diff --git a/.env b/.env index 7308593..0a2f4de 100644 --- a/.env +++ b/.env @@ -19,10 +19,14 @@ LOGSTASH_HOST=logstash APMSERVER_HOST=apm-server APMSERVER_PORT=8200 -#----------- Credientals ------------------------# +#----------- Timezone ---------------------------# +# Set the timezone in all containers +TZ=Etc/UTC + +#----------- Credentials ------------------------# # Username & Password for Admin Elasticsearch cluster. # This is used to set the password at setup, and used by others to connect to Elasticsearch at runtime. -# USERNAME cannot be changed! It is set here for parmeterization only. +# USERNAME cannot be changed! It is set here for parameterization only. ELASTIC_USERNAME=elastic ELASTIC_PASSWORD=changeme AWS_ACCESS_KEY_ID=nottherealid @@ -34,7 +38,7 @@ ELASTIC_CLUSTER_NAME=elastdocker-cluster ELASTIC_INIT_MASTER_NODE=elastdocker-node-0 ELASTIC_NODE_NAME=elastdocker-node-0 -# Hostnames of master eligble elasticsearch instances. (matches compose generated host name) +# Hostnames of master eligible elasticsearch instances. (matches compose generated host name) ELASTIC_DISCOVERY_SEEDS=elasticsearch #----------- For Multinode Cluster --------------# diff --git a/apm-server/Dockerfile b/apm-server/Dockerfile index 92efc37..5b564eb 100644 --- a/apm-server/Dockerfile +++ b/apm-server/Dockerfile @@ -3,3 +3,10 @@ ARG ELK_VERSION # https://github.com/elastic/apm-server FROM docker.elastic.co/apm/apm-server:${ELK_VERSION} ARG ELK_VERSION + +USER root +RUN apt-get -qq update -y \ + && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* +USER apm-server diff --git a/docker-compose.nodes.yml b/docker-compose.nodes.yml index 70d737a..97c7e29 100644 --- a/docker-compose.nodes.yml +++ b/docker-compose.nodes.yml @@ -14,6 +14,7 @@ services: ELK_VERSION: ${ELK_VERSION} restart: unless-stopped environment: + TZ: ${TZ} ELASTIC_USERNAME: ${ELASTIC_USERNAME} ELASTIC_PASSWORD: ${ELASTIC_PASSWORD} ELASTIC_CLUSTER_NAME: ${ELASTIC_CLUSTER_NAME} @@ -51,6 +52,7 @@ services: ELK_VERSION: ${ELK_VERSION} restart: unless-stopped environment: + TZ: ${TZ} ELASTIC_USERNAME: ${ELASTIC_USERNAME} ELASTIC_PASSWORD: ${ELASTIC_PASSWORD} ELASTIC_CLUSTER_NAME: ${ELASTIC_CLUSTER_NAME} diff --git a/docker-compose.setup.yml b/docker-compose.setup.yml index 716fb99..d4298b7 100644 --- a/docker-compose.setup.yml +++ b/docker-compose.setup.yml @@ -13,6 +13,7 @@ services: - ./secrets:/secrets - ./setup/:/setup/ environment: + TZ: ${TZ} ELASTIC_PASSWORD: ${ELASTIC_PASSWORD} certs: @@ -25,4 +26,6 @@ services: user: "0" volumes: - ./secrets:/secrets - - ./setup/:/setup \ No newline at end of file + - ./setup/:/setup + environment: + TZ: ${TZ} \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 3d895fc..ce5badc 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -39,6 +39,7 @@ services: ELK_VERSION: ${ELK_VERSION} restart: unless-stopped environment: + TZ: ${TZ} ELASTIC_USERNAME: ${ELASTIC_USERNAME} ELASTIC_PASSWORD: ${ELASTIC_PASSWORD} ELASTIC_CLUSTER_NAME: ${ELASTIC_CLUSTER_NAME} @@ -91,6 +92,7 @@ services: - source: elastic.ca target: /certs/ca.crt environment: + TZ: ${TZ} ELASTIC_USERNAME: ${ELASTIC_USERNAME} ELASTIC_PASSWORD: ${ELASTIC_PASSWORD} ELASTICSEARCH_HOST_PORT: https://${ELASTICSEARCH_HOST}:${ELASTICSEARCH_PORT} @@ -111,6 +113,7 @@ services: volumes: - ./kibana/config/:/usr/share/kibana/config:ro environment: + TZ: ${TZ} ELASTIC_USERNAME: ${ELASTIC_USERNAME} ELASTIC_PASSWORD: ${ELASTIC_PASSWORD} ELASTICSEARCH_HOST_PORT: https://${ELASTICSEARCH_HOST}:${ELASTICSEARCH_PORT} @@ -139,6 +142,7 @@ services: volumes: - ./apm-server/config/apm-server.yml:/usr/share/apm-server/apm-server.yml:ro environment: + TZ: ${TZ} ELASTIC_USERNAME: ${ELASTIC_USERNAME} ELASTIC_PASSWORD: ${ELASTIC_PASSWORD} ELASTICSEARCH_HOST_PORT: https://${ELASTICSEARCH_HOST}:${ELASTICSEARCH_PORT} diff --git a/elasticsearch/Dockerfile b/elasticsearch/Dockerfile index 70e33ff..8901aff 100644 --- a/elasticsearch/Dockerfile +++ b/elasticsearch/Dockerfile @@ -3,6 +3,13 @@ ARG ELK_VERSION # https://github.com/elastic/elasticsearch-docker FROM docker.elastic.co/elasticsearch/elasticsearch:${ELK_VERSION} +USER root +RUN apt-get -qq update -y \ + && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* +USER elasticsearch + # Add healthcheck COPY scripts/docker-healthcheck . HEALTHCHECK CMD sh ./docker-healthcheck diff --git a/kibana/Dockerfile b/kibana/Dockerfile index 62b9868..9235753 100644 --- a/kibana/Dockerfile +++ b/kibana/Dockerfile @@ -4,5 +4,12 @@ ARG ELK_VERSION FROM docker.elastic.co/kibana/kibana:${ELK_VERSION} ARG ELK_VERSION +USER root +RUN apt-get -qq update -y \ + && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* +USER kibana + # Add your kibana plugins setup here # Example: RUN kibana-plugin install \ No newline at end of file diff --git a/logstash/Dockerfile b/logstash/Dockerfile index 673814e..5b6c5bd 100644 --- a/logstash/Dockerfile +++ b/logstash/Dockerfile @@ -3,6 +3,13 @@ ARG ELK_VERSION # https://github.com/elastic/logstash-docker FROM docker.elastic.co/logstash/logstash:${ELK_VERSION} +USER root +RUN apt-get -qq update -y \ + && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* +USER logstash + HEALTHCHECK --interval=240s --timeout=120s --retries=5 \ CMD curl -s -XGET 'http://127.0.0.1:9600'