Creating an image for elasticsearch-setup to automatically create indices

This commit is contained in:
Kerem Sahin 2019-09-12 19:04:29 -07:00
parent 430f13108d
commit 1a3ddff4a4
4 changed files with 41 additions and 2 deletions

View File

@ -0,0 +1,17 @@
FROM openjdk:8
MAINTAINER Kerem Sahin <ksahin@linkedin.com>
RUN apt-get update && apt-get install -y wget && apt-get install -y curl
COPY corpuser-index-config.json dataset-index-config.json /
ENV DOCKERIZE_VERSION v0.6.1
RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
&& tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
&& rm dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz
CMD dockerize -wait http://$ELASTICSEARCH_HOST:$ELASTICSEARCH_PORT \
-timeout 60s; \
curl -XPUT $ELASTICSEARCH_HOST:$ELASTICSEARCH_PORT/corpuserinfodocument --data @corpuser-index-config.json; \
curl -XPUT $ELASTICSEARCH_HOST:$ELASTICSEARCH_PORT/datasetdocument --data @dataset-index-config.json

View File

@ -20,6 +20,18 @@ services:
depends_on:
- elasticsearch
# This "container" is a workaround to pre-create search indices
elasticsearch-setup:
build:
context: .
hostname: elasticsearch-setup
container_name: elasticsearch-setup
depends_on:
- elasticsearch
environment:
- ELASTICSEARCH_HOST=elasticsearch
- ELASTICSEARCH_PORT=9200
networks:
default:
name: datahub_network

View File

@ -1,2 +0,0 @@
curl -XPUT localhost:9200/corpuserinfodocument --data @corpuser-index-config.json
curl -XPUT localhost:9200/datasetdocument --data @dataset-index-config.json

View File

@ -109,6 +109,18 @@ services:
depends_on:
- elasticsearch
# This "container" is a workaround to pre-create search indices
elasticsearch-setup:
build:
context: ../elasticsearch
hostname: elasticsearch-setup
container_name: elasticsearch-setup
depends_on:
- elasticsearch
environment:
- ELASTICSEARCH_HOST=elasticsearch
- ELASTICSEARCH_PORT=9200
datahub-gms:
image: keremsahin/datahub-gms:latest
hostname: datahub-gms