Skip to content

Commit 4c8c414

Browse files
sjudengAlexander Patrikalakis
authored andcommitted
Use Docker Compose to manage JanusGraph Gremlin Server and Elasticsearch containers
Signed-off-by: sjudeng <[email protected]>
1 parent 8ea98ff commit 4c8c414

File tree

8 files changed

+69
-21
lines changed

8 files changed

+69
-21
lines changed

BUILDING.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,18 @@ To build with only the TinkerPop tests\*:
3030
mvn clean install -Dtest.skip.tp=false -DskipTests=true
3131
```
3232

33-
To build and run a docker image with JanusGraph and Gremlin Server, configured
34-
to run the berkeleyje backend with an embedded ElasticSearch instance:
33+
## Building Docker Image for JanusGraph Gremlin Server
34+
35+
To build and run Docker images with JanusGraph and Gremlin Server, configured
36+
to run the BerkeleyJE backend and Elasticsearch (requires [Docker Compose](https://docs.docker.com/compose/)):
3537

3638
```bash
37-
mvn clean package -Pjanusgraph-release -Dgpg.skip=true -DskipTests=true
38-
cd janusgraph-hbase-parent/janusgraph-hbase-core && mvn install -DskipTests=true && cd ../..
39-
cd janusgraph-dist && mvn install -Pjanusgraph-docker -DskipTests=true docker:build
40-
docker run -d -p 8182:8182 --name janusgraph janusgraph/server:latest
39+
mvn clean install -Pjanusgraph-release -Dgpg.skip=true -DskipTests=true && mvn docker:build -Pjanusgraph-docker -pl janusgraph-dist
40+
docker-compose -f janusgraph-dist/janusgraph-dist-hadoop-2/docker-compose.yml up
4141
```
4242

43+
Note the above `docker-compose` call launches containers in the foreground and is convenient for monitoring logs but add "-d" to instead run in the background.
44+
4345
To connect to the server in the same container on the console:
4446

4547
```bash
Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
FROM openjdk:8
22

3-
ENV PATH "$JAVA_HOME/bin:$PATH"
4-
RUN apt-get update -y && apt-get install -y zip
5-
WORKDIR /var
6-
73
ARG server_zip
8-
ARG server_base
94
ADD ${server_zip} /var
10-
RUN unzip -q ${server_base}.zip && ln -s ./${server_base} ./janusgraph
5+
6+
RUN apt-get update -y && apt-get install -y zip && \
7+
server_base=`basename ${server_zip} .zip` && \
8+
unzip -q /var/${server_base}.zip -d /var && \
9+
ln -s /var/${server_base} /var/janusgraph
10+
1111
WORKDIR /var/janusgraph
12-
EXPOSE 8182
13-
CMD ["./bin/gremlin-server.sh", "./conf/gremlin-server/gremlin-server-berkeleyje.yaml"]
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
version: '2'
2+
services:
3+
janusgraph:
4+
image: janusgraph/server:latest
5+
container_name: janusgraph
6+
ports:
7+
- "8182:8182"
8+
volumes:
9+
- ./es/wait-for-es.sh:/usr/bin/wait-for-es.sh
10+
depends_on:
11+
- "elasticsearch"
12+
command: ["wait-for-es.sh", "elasticsearch", "./bin/gremlin-server.sh", "./conf/gremlin-server/gremlin-server-berkeleyje.yaml"]
13+
14+
elasticsearch:
15+
image: docker.elastic.co/elasticsearch/elasticsearch:5.3.2
16+
environment:
17+
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
18+
- "http.host=0.0.0.0"
19+
- "transport.host=127.0.0.1"
20+
ports:
21+
- "9200"
22+
volumes:
23+
- ./es/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
24+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
cluster.name: "docker-cluster"
2+
network.host: 0.0.0.0
3+
4+
# minimum_master_nodes need to be explicitly set when bound on a public IP
5+
# set to 1 to allow single node clusters
6+
# Details: https://github.com/elastic/elasticsearch/pull/17288
7+
discovery.zen.minimum_master_nodes: 1
8+
9+
xpack.security.enabled : false
10+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
host="$1"
6+
7+
shift
8+
cmd="$@"
9+
10+
until $(curl --output /dev/null --silent --head --fail http://$host:9200); do
11+
printf '.'
12+
sleep 5
13+
done
14+
15+
>&2 echo "Elasticsearch is up"
16+
17+
exec $cmd
18+

janusgraph-dist/pom.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -633,10 +633,9 @@
633633
<artifactId>docker-maven-plugin</artifactId>
634634
<version>${docker.maven.version}</version>
635635
<configuration>
636-
<dockerDirectory>janusgraph-dist-hadoop-2</dockerDirectory>
636+
<dockerDirectory>${project.basedir}/janusgraph-dist-hadoop-2</dockerDirectory>
637637
<buildArgs>
638638
<server_zip>target/janusgraph-${project.version}-hadoop2.zip</server_zip>
639-
<server_base>janusgraph-${project.version}-hadoop2</server_base>
640639
</buildArgs>
641640
<forceTags>true</forceTags>
642641
<imageName>janusgraph/server</imageName>

janusgraph-dist/src/assembly/static/conf/gremlin-server/gremlin-server-berkeleyje.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,4 @@ maxAccumulationBufferComponents: 1024
3636
resultIterationBatchSize: 64
3737
writeBufferLowWaterMark: 32768
3838
writeBufferHighWaterMark: 65536
39-
ssl: {
40-
enabled: false}
39+

janusgraph-dist/src/assembly/static/conf/gremlin-server/janusgraph-berkeleyje-es-server.properties

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,4 @@ gremlin.graph=org.janusgraph.core.JanusGraphFactory
99
storage.backend=berkeleyje
1010
storage.directory=db/berkeley
1111
index.search.backend=elasticsearch
12-
index.search.directory=db/es
13-
index.search.elasticsearch.client-only=false
14-
index.search.elasticsearch.local-mode=true
12+
index.search.hostname=elasticsearch

0 commit comments

Comments
 (0)