Skip to content

Commit 296d296

Browse files
authored
Dockerfile for building images for Docker and Kubernetes (#145)
1 parent f394ae3 commit 296d296

File tree

4 files changed

+296
-19
lines changed

4 files changed

+296
-19
lines changed

src/main/docker/Dockerfile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
FROM fabric8/java-jboss-openjdk8-jdk:1.2
1+
FROM tomcat:8.0-jre8
22
MAINTAINER Eiffel-Community
3-
USER root
4-
ENV JAVA_APP_DIR=/deployments
5-
ENV JAVA_APP_JAR=eiffel-intelligence-frontend.war
6-
EXPOSE 8092 8778 9779
73

8-
# Create image with existing war file. User need to execute 'mvn package -DskipTest' before 'docker build'
9-
COPY ./target/eiffel-intelligence-frontend-*.war /deployments/eiffel-intelligence-frontend.war
4+
ARG URL
5+
RUN echo Building Eiffel-Intelligence Front-end image based on artifact url: ${URL}
106

11-
CMD /deployments/run-java.sh
7+
# Create image with existing war file. User need to execute 'mvn package -DskipTest' before 'docker build'
8+
RUN ["rm", "-fr", "/usr/local/tomcat/webapps/ROOT"]
9+
ADD ${URL} /usr/local/tomcat/webapps/ROOT.war
1210

11+
EXPOSE 8080
1312

13+
CMD ["catalina.sh", "run"]

src/main/docker/README.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
A: Build Eiffel-Intelligence Front-end Docker image based on Eiffel-Intelligence Front-end from an Artifactory, e.g. Jitpack:
2+
cd (git root dir)
3+
docker build -t eiffel-intelligence-frontend:0.0.19 --build-arg URL=https://jitpack.io/com/github/eiffel-community/eiffel-intelligence-frontend/0.0.19/eiffel-intelligence-frontend-0.0.19.war -f src/main/docker/Dockerfile .
4+
5+
6+
B: Build Eiffel-Intelligence Front-end based on local Eiffel-Intelligence Front-end source code changes
7+
1. Build Eiffel-Intelligence Front-end artifact:
8+
cd (git root dir)
9+
mvn package -DskipTests
10+
11+
2. Build Eiffel-Intelligence Front-end Docker image:
12+
cd (git root dir)/
13+
docker build -t eiffel-intelligence-frontend:0.0.19 --build-arg URL=./target/eiffel-intelligence-frontend-0.0.19.war -f src/main/docker/Dockerfile .

src/main/docker/docker-compose.yml

Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
#################################################################################################
2+
#
3+
# Copyright 2019 Ericsson AB.
4+
# For a full list of individual contributors, please see the commit history.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
##################################################################################################
19+
# docker-compose commands
20+
#
21+
# run: docker-compose up
22+
# stop: docker-compose stop
23+
# stop/remove: docker-compose down --volumes
24+
#
25+
# Cleanup/Remove (if needed):
26+
# Dangling Volumes: docker volume rm `docker volume ls -q -f dangling=true`
27+
# Unused Images: docker images -q | xargs docker rmi
28+
# Stopped containers: docker rm `docker ps -a -q`
29+
#
30+
# Maintainer: Eiffel-Community
31+
##################################################################################################
32+
version: "2.1"
33+
services:
34+
mongodb:
35+
restart: always
36+
image: mongo:latest
37+
expose:
38+
- "27017"
39+
ports:
40+
- "27017:27017"
41+
healthcheck:
42+
test: ["CMD-SHELL","echo", "'db.stats().ok' | mongo localhost:27017/test", "--quiet"]
43+
interval: 30s
44+
timeout: 10s
45+
retries: 5
46+
networks:
47+
eiffel_2.0_1:
48+
aliases:
49+
- mongodb
50+
51+
rabbitmq:
52+
restart: always
53+
image: rabbitmq:3.6.2-management
54+
expose:
55+
- "15672"
56+
- "5672"
57+
ports:
58+
- "15672:15672"
59+
- "5672:5672"
60+
healthcheck:
61+
test: ["CMD-SHELL", "if rabbitmqctl status; then \nexit 0 \nfi \nexit 1"]
62+
interval: 30s
63+
timeout: 10s
64+
retries: 5
65+
networks:
66+
eiffel_2.0_1:
67+
aliases:
68+
- rabbitmq
69+
environment:
70+
- RABBITMQ_DEFAULT_PASS=myuser
71+
- RABBITMQ_DEFAULT_USER=myuser
72+
- RABBITMQ_DEFAULT_VHOST=/
73+
74+
eiffel-er:
75+
restart: always
76+
image: eiffelericsson/eiffel-er:0.0.60
77+
expose:
78+
- "8080"
79+
ports:
80+
- "8082:8080"
81+
depends_on:
82+
- rabbitmq
83+
- mongodb
84+
networks:
85+
eiffel_2.0_1:
86+
aliases:
87+
- eiffel-er
88+
environment: # Overrides settings in config file in catalina folder. OBS --> skip quotes for rabbitmq.bindingKey value
89+
# No config file copied to catalina folder in Dockerfile, only uses env vars below ;-)
90+
# /eventrepository removed in contextpath
91+
- server.contextPath=/
92+
- server.port=8080
93+
- rabbitmq.host=rabbitmq
94+
- rabbitmq.componentName=eventrepository
95+
- rabbitmq.port=5672
96+
- rabbitmq.domainId=ei-domain
97+
- rabbitmq.durable=true
98+
- rabbitmq.user=myuser
99+
- rabbitmq.password=myuser
100+
- rabbitmq.exchangeName=ei-exchange
101+
- rabbitmq.bindingKey=#
102+
- rabbitmq.autoDelete=false
103+
- rabbitmq.createExchangeIfNotExisting=true
104+
- rabbitmq.consumerName=messageConsumer
105+
- mongodb.host=mongodb
106+
- mongodb.port=27017
107+
- mongodb.database=eiffel
108+
- mongodb.collection=events
109+
- mongodb.user
110+
- mongodb.password
111+
- mongodb.indexes=meta.id,links.target,links.type,meta.time,data.gav.groupId,data.gav.artifactId
112+
- mongodb.externalERs
113+
- search.limit=100
114+
- search.levels=10
115+
- eventrepo2.URL=
116+
- index.staticIndex.indexOn=false
117+
- index.staticIndex.filePath=src/main/resources/static_indexes.json
118+
- index.dynamicIndex.indexOn=false
119+
- index.dynamicIndex.indexCreationDay=SUNDAY
120+
- index.dynamicIndex.indexCreationTime=11:50:00
121+
- index.dynamicIndex.maxIndexesCount=5
122+
- index.dynamicIndex.filePath=src/main/resources/dynamic_indexing.json
123+
- index.dynamicIndex.fileUpdatePeriod=30
124+
125+
ei_backend:
126+
restart: always
127+
image: eiffelericsson/eiffel-intelligence-backend:0.0.18
128+
expose:
129+
- "8080"
130+
ports:
131+
- "8080:8080"
132+
depends_on:
133+
- mongodb
134+
- rabbitmq
135+
networks:
136+
eiffel_2.0_1:
137+
aliases:
138+
- ei-backend
139+
environment: # Overrides settings in application config file
140+
- SpringApplicationName=ei-backend
141+
- server.port=8080
142+
- rules.path=src/main/resources/ArtifactRules_new.json
143+
- rabbitmq.host=rabbitmq
144+
- rabbitmq.port=5672
145+
- rabbitmq.domainId=ei-domain
146+
- rabbitmq.componentName=ei-backend
147+
- rabbitmq.waitlist.queue.suffix=waitlist
148+
- rabbitmq.exchange.name=ei-exchange
149+
- rabbitmq.user=myuser
150+
- rabbitmq.password=myuser
151+
- spring.data.mongodb.host=mongodb
152+
- spring.data.mongodb.port=27017
153+
- spring.data.mongodb.database=eiffel2_intelligence
154+
- missedNotificationDataBaseName=eiffel2_intelligence_MissedNotification
155+
- search.query.prefix=object
156+
- aggregated.object.name=aggregatedObject
157+
- spring.mail.host=
158+
- spring.mail.port=
159+
- spring.mail.username=
160+
- spring.mail.password=
161+
- spring.mail.properties.mail.smtp.auth=false
162+
- spring.mail.properties.mail.smtp.starttls.enable=false
163+
- er.url=eiffel-er:8082
164+
- logging.level.root=OFF
165+
- logging.level.org.springframework.web=ERROR
166+
- logging.level.com.ericsson.ei=ERROR
167+
- WAIT_MB_HOSTS=rabbitmq:15672
168+
- WAIT_DB_HOSTS=mongodb:27017
169+
170+
ei_frontend:
171+
restart: always
172+
image: eiffel-intelligence-frontend:0.0.19
173+
expose:
174+
- "8080"
175+
ports:
176+
- "8081:8080"
177+
depends_on:
178+
- ei_backend
179+
networks:
180+
eiffel_2.0_1:
181+
aliases:
182+
- ei-frontend
183+
environment: # Overrides settings in application config file
184+
- spring.application.name=ei-frontend
185+
- server.port=8080
186+
- ei.frontendServiceHost=${HOST}
187+
- ei.frontendServicePort=8081
188+
- ei.backendInstancesListJsonContent=${EIFFEL2_EI_FRONTEND_EI_INSTANCES_LIST}
189+
- ei.backendInstancesFilePath=/tmp/ei-instances-list.conf
190+
191+
networks:
192+
eiffel_2.0_1:

wiki/markdown/docker.md

Lines changed: 83 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,36 +12,38 @@ With the Docker image user can try-out the Eiffel-Intelligence frontend on a Doc
1212

1313
Windows: https://docs.docker.com/docker-for-windows/install/
1414

15+
- Docker Compose
16+
17+
Linux and Windows: https://docs.docker.com/compose/install/
18+
1519
## Follow these step to build the Docker image.
1620

1721
1. Build the Eiffel-Intelligence frontend war file:
22+
1823
`mvn package -DskipTests`
1924

2025

2126
This will produce a war file in the "target" folder.
2227

23-
2428
2. Build the Docker image with the war file that was produced from previous step:
2529

30+
`docker build -t eiffel-intelligence-frontend:0.0.19 --build-arg URL=./target/eiffel-intelligence-frontend-0.0.19.war -f src/main/docker/Dockerfile .`
2631

27-
`docker build -f src/main/docker/Dockerfile -t eiffel-intelligence-frontend:0.1 .`
28-
29-
30-
Now docker image has build with tag "eiffel-intelligence-frontend:0.1"
32+
Now docker image has build with tag "eiffel-intelligence-frontend:0.0.19"
3133

3234
## Run Docker image on local Docker Host
3335
To run the produced docker image on the local Docker host, execute this command:
3436

3537

36-
`docker run -p 8034:8091 --expose 8091 -e server.port=8091 -e logging.level.root=DEBUG -e logging.level.org.springframework.web=DEBUG -e logging.level.com.ericsson.ei=DEBUG eiffel-intelligence-backend:0.1`
38+
`docker run -p 8071:8080 --expose 8080 -e server.port=8080 -e logging.level.log.level.root=DEBUG -e logging.level.org.springframework.web=DEBUG -e logging.level.com.ericsson.ei=DEBUG eiffel-intelligence-frontend:0.0.19`
3739

3840
# Some info of all flags to this command
3941

4042

4143
## Eiffel Intelligence Spring Properties
4244

4345

44-
<B>"-e server.port=8091"</B> - Is the Spring property setting for Eiffel-Intelligence applications web port.
46+
<B>"-e server.port=8080"</B> - Is the Spring property setting for Eiffel-Intelligence applications web port.
4547

4648

4749
<B>"-e logging.level.root=DEBUG -e logging.level.org.springframework.web=DEBUG -e
@@ -57,17 +59,87 @@ It is possible to set all Spring available properties via docker environment "-e
5759
## Docker flags
5860

5961

60-
<B>"--expose 8091"</B> - this Docker flag tells that containers internal port shall be exposed to outside of the Docker Host. This flag do not set which port that should be allocated outside Docker Host on the actual server/machine.
62+
<B>"--expose 8080"</B> - this Docker flag tells that containers internal port shall be exposed to outside of the Docker Host. This flag do not set which port that should be allocated outside Docker Host on the actual server/machine.
6163

6264

63-
<B>"-p 8034:8091"</B> - this Docker flag is mapping the containers external port 8034 to the internal exposed port 8091. Port 8034 will be allocated outside Docker host and user will be able to access the containers service via port 8034.
65+
<B>"-p 8071:8080"</B> - this Docker flag is mapping the containers external port 8071 to the internal exposed port 8080. Port 8071 will be allocated outside Docker host and user will be able to access the containers service via port 8071.
6466

6567

66-
When Eiffel-Intelligence container is running on your local Docker host Eiffel-Intelligence should be reachable with address "localhost:8091/\<Rest End-Point\>" or "\<docker host ip\>:8091/\<Rest End-Point\>"
68+
When Eiffel-Intelligence container is running on your local Docker host Eiffel-Intelligence should be reachable with address "localhost:8071/\<Rest End-Point\>" or "\<docker host ip\>:8071/\<Rest End-Point\>"
6769

6870

69-
In web-browser use url with docker host ip number: "\<docker host ip\>:8091/"
71+
In web-browser use url with docker host ip number: "\<docker host ip\>:8071/"
7072

7173
Switch-backend functionality do not work when "localhost" address is used.
7274

75+
Another option to configure Eiffel-Intelligence Front-end is to provide the application properties file into the container, which can be made in two ways:
76+
1. Put application.properties file in Tomcat Catalina config folder in container and run Eiffe-Intelligence Front-end:
77+
78+
`docker run -p 8070:8080 --expose 8080 --volume /path/to/application.properties:/usr/local/tomcat/config/application.properties eiffel-intelligence-frontend:0.0.19`
79+
80+
2. Put application.properties file in a different folder in container and tell EI where the application.properties is located in the container:
81+
82+
`docker run -p 8070:8080 --expose 8080 --volume /path/to/application.properties:/tmp/application.properties -e spring.config.location=/tmp/application.properties eiffel-intelligence-frontend:0.0.19`
83+
84+
85+
# Run Docker image with provided docker-compose file
86+
This docker-compose file includes these components, [docker-compose.yml](https://github.com/Ericsson/eiffel-intelligence-frontend/blob/master/src/main/docker/docker-compose.yml):
87+
- MongoDb
88+
- RabbitMq
89+
- ER
90+
- EI-Backend
91+
- EI-Frontend (Using the local EI-Frontend Docker image build from previous steps)
92+
93+
If you have used a different image tag when you build the EI Frontend docker image, then you need to update docker-compose.yml file.
94+
95+
This line need to changed, in ei_backend service section:
96+
97+
"image: eiffel-intelligence-frontend:0.0.19"
98+
99+
To:
100+
101+
"image: \<your image tag\>"
102+
103+
Two variables need to be set before we can start up all services with docker-compose tool.
104+
Set Docker host ip to the HOST variable.
105+
If on Linux:
106+
107+
`export HOST=$(hostname -I | tr " " "\n"| head -1)`
108+
109+
If on Windows, get Docker Host ip with command: `dockermachine ip`
110+
111+
Set that Docker host ip to HOST environment varaible.
112+
113+
Currently we need to provide EI Back-end instances list outside of docker-compose.yml file.
114+
115+
`export EIFFEL2_EI_FRONTEND_EI_INSTANCES_LIST=$(echo [{ \"contextPath\": \"\", \"port\": \"8080\", \"name\": \"EI-Backend\", \"host\": \"ei-backend\", \"https\": false, \"defaultBackend\": true}])`
116+
117+
Then run following docker-compose command to startup all components:
118+
119+
`docker-compose -f src/main/docker/docker-compose.yml up -d`
120+
121+
It will take some minutes until all components has started. When all components has loaded, you should be able to access EI Front-end web page with address:
122+
http://\<docker host ip\>:8081/
123+
124+
Curl command can be used to make request via EI Front-end bridge to EI Back-end Rest-Api, example for getting all subscriptions:
125+
126+
127+
`curl -X GET http://localhost:8081/subscriptions`
128+
129+
It is also possible to access these Rest-Api addresses in web-browser and get result presented in a Json view in web-browser.
130+
131+
Following command can be used to get the logs from the EI Front-end container/service:
132+
133+
`docker-compose -f src/main/docker/docker-compose.yml logs ei_frontend`
134+
135+
All service names can be retreived with following command:
136+
137+
`docker-compose -f src/main/docker/docker-compose.yml config --services`
138+
139+
It is also possible to retrieve the logs by only using "docker logs <container_id or container_name>" command:
140+
141+
`docker logs <container_id or container_name>`
142+
143+
Container id can be retrieved with docker command:
73144

145+
`docker ps`

0 commit comments

Comments
 (0)