Skip to content

Commit

Permalink
Add possibility to define the timezone via the TZ env var in the do…
Browse files Browse the repository at this point in the history
…cker containers

Fixes sherifabdlnaby#117
  • Loading branch information
BendingBender committed Dec 7, 2024
1 parent fd7f419 commit d80caf6
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 4 deletions.
10 changes: 7 additions & 3 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 --------------#
Expand Down
7 changes: 7 additions & 0 deletions apm-server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions docker-compose.nodes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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}
Expand Down
5 changes: 4 additions & 1 deletion docker-compose.setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ services:
- ./secrets:/secrets
- ./setup/:/setup/
environment:
TZ: ${TZ}
ELASTIC_PASSWORD: ${ELASTIC_PASSWORD}

certs:
Expand All @@ -25,4 +26,6 @@ services:
user: "0"
volumes:
- ./secrets:/secrets
- ./setup/:/setup
- ./setup/:/setup
environment:
TZ: ${TZ}
4 changes: 4 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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}
Expand All @@ -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}
Expand Down Expand Up @@ -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}
Expand Down
7 changes: 7 additions & 0 deletions elasticsearch/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions kibana/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 <name|url>
7 changes: 7 additions & 0 deletions logstash/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down

0 comments on commit d80caf6

Please sign in to comment.