There are two ways of running this application on your local machine:
- Start App with Node.js
- Start with Docker
cd services/service-ui/ && yarn && yarn start
- IF YOU WANT TO USE YOUR OWN DATABASE, it is important to change the API request urls from
api.elaisa.org
tolocalhost:8080
in the views:- Results.js
- SignIn/SignUp.js
- Account.js
- Profile.js
- Otherwise the API calls would use the production API on
api.elaisa.org
- IF YOU WANT TO USE YOUR OWN DATABASE, it is important to change the API request urls from
cd services/service-api && python api.py
- ONLY IF YOU WANT TO USE YOUR OWN DATABASE
- If you're on Windows, please check if you can start Python files with
python file.py
- Mongo DB should run on
localhost:27017
- You have to copy the
bin/globals.json
file to this two origins:services/service-api/bin
services/service-crawler/webcrawler
- Then you have to change the mongo path in the
globals.json
tomongodb://localhost:27017/
- You have to copy the
- In the
service-crawler
you have to change the following, too:- Go to
services/service-crawler/webcrawler/settings.py
and change theMONGO_URI
.- Uncomment the development mode line and comment the production one.
- Also go o
services/service-crawler/spider/categorizer.py
and uncommentclient
for development mode.
- Go to
cd services/service-cefr/en && python enHandler.py
cd services/service-crawler && scrapy crawl news_en_EN
- You are only able to fill the development database on
localhost:27017
- You are only able to fill the development database on
Now you can visit the application on localhost:3000
and search for english documents.
We use Docker Swarm as an orchestrator to manage the running containers, which are inlcuded in a stack. This stack could be named as the YAML file: elaisa. Therefore we have to tell our server to be a so called Swarm Manager; type in the following command:
docker swarm init
If an error occurs which says, that there are multiple IP addresses, USE THE INTERNAL IP since there would be a security risk for you if you use the public one.
If you use the server's public IP address for the swarm, other devs could use your server as a swarm worker in their own swarm. This would mean, that they would use your resources for their projects -- bad, right?
Build the images:
After defining the swarm manager, we have to build all containers, which are used by our application:
docker build -f build-utils/service-ui.Dockerfile -t service-ui:latest .
docker build -f build-utils/service-api.Dockerfile -t service-api:lastest .
docker build -f build-utils/service-crawler.Dockerfile -t service-crawler:lastest .
Create Networks:
Before we can start the stack, we have to define the networks for internal container communication and the mongo db volume to store the database, even if you upgrade or delete the stack.
Networks:
docker network create --driver overlay --attachable --opt encrypted=true frontend
docker network create --driver overlay --attachable --opt encrypted=true database
With these commands you create the frontend network for UI and API and the database network for the mongo db and the API. --opt encrypted=true
says, that all connections in the network are encrypted, which is another safety factor.
Mongo DB Volume:
The entire database is now stored in mongodb:/data/db
.
Create Docker Secrets:
You could deploy the elaisa stack without Docker Secrets, but then everyone could visit the mongo db without authenticating theirselves. Therefore, you have to create the following two secrets for the mongo db root user:
printf <secret> | docker secret create mongodb_root_username -
printf <secret> | docker secret create mongodb_root_password -
After defining these two secrets, you have to deploy the stack in the next step ->
Detailed Mongo DB configuration here
Deploy the Docker Stack:
Now wer're ready to deploy our application.
This will create the docker services, which are included in the stack called elaisa. You can check if everything is running by typing in:
You should see something similar to this:
NAME MODE REPLICAS PORTS
elaisa_api replicated 1/1
elaisa_db replicated 1/1 *:2717->27017/tcp
elaisa_traefik global 1/1 *:80->80/tcp...
elaisa_ui replicated 1/1
If every service says 1/1
in the REPLICAS column, everything is running. The NAME column tells you which stack is used but you can also check it by typing in:
This will show you the following.
NAME SERVICES ORCHESTRATOR
elaisa 4 Swarm
Note:
There are only two ports shown in the service ls column. This is caused be the use of traefik. All incoming requests are handled by this reverse-proxy server over port 80.
IMPORTANT
SINCE THE STACK IS ALREADY DEPLOYED ON A SERVER WITH THE DOMAIN ELAISA.ORG, YOU CANNOT USE EXACTLY THIS CONFIGURATION!