-
Notifications
You must be signed in to change notification settings - Fork 16
[DEPRECATED] 8. Docker and AWS ElasticBeanStalk
Ajit Singh edited this page Sep 23, 2019
·
1 revision
We have significantly reviewed the architecture of our Knetminer for Docker and this is documented in this page.
This page will be removed in future.
It is now possible to spin up a new dedicated Knetminer instance with a custom OXL file using Docker, or to the cloud using AWS ElasticBeanStalk.
Follow the simple instructions below to see how:
- You will need to have your OXL file, your SemanticMotifs.txt, and any other files required by the configuration (see below) accessible via an HTTP URL, i.e. saved on a web server or in an S3 bucket. They must be publicly accessible for the duration of the deployment but can be hidden or deleted once deployment is complete
- If using Docker, you will need to install Docker locally
- If using AWS ElasticBeanStalk, you will need an AWS account. The instructions below assume you will deploy KnetMiner using the ElasticBeanStalk command-line interface (eb-cli), but you can also achieve the same results through the AWS console web interface
- Into an empty folder download the Dockerfile
- Edit the downloaded Dockerfile and in the first ENV section at the top update the settings:
- Note that this includes the branch of the KnetMiner GitHub repository to use, and in most circumstances this should be the same branch that you got the
Dockerfile
from in the first place (knetminer-3.0
in this example) otherwise behaviour could be unpredictable - The defaults shown in the file will also work if you just want to try it and see - the example URLs it references are in a public S3 bucket in the KnetMiner AWS account
- Note that this includes the branch of the KnetMiner GitHub repository to use, and in most circumstances this should be the same branch that you got the
- On the command line inside the folder where you downloaded the Dockerfile, type:
docker image build --squash -t knetminer .
docker run -p8080:8080 -it --rm knetminer
- After waiting about ten minutes for the previous step to complete you’ll be able to access KnetMiner at
http://localhost:8080/client/
- Into an empty folder download two files:
- Edit the downloaded Dockerfile and in the first ENV section at the top update the settings
- Note that this includes the branch of the knetminer Git repository to use, and in most circumstances this should be the same branch that you got the Dockerfile from in the first place (
knetminer-3.0
in this example) otherwise behaviour could be unpredictable - The defaults shown in the file will also work if you just want to try it and see - the example URLs it references are in a public S3 bucket in the Knetminer AWS account
- Note that this includes the branch of the knetminer Git repository to use, and in most circumstances this should be the same branch that you got the Dockerfile from in the first place (
- If you are using the AWS ElasticBeanStalk web interface, zip the folder containing the two files into a single zip archive, then go to the AWS console to upload and deploy it (the type is Generic->Docker, and your source bundle is the zip file you just created)
- If you are using the ElasticBeanStalk command-line method instead, then from within the folder containing the two files type the following commands and follow any instructions they give you:
eb init
eb create
- After waiting about ten minutes for it to start up, scan the output of the commands for the details of the load balancer it has created, or otherwise go to the AWS console in your web browser and look for the load balancer details there. Make a note of the load balancer's hostname (public DNS)
- You can now access KnetMiner at:
http://\<your-load-balancer-hostname\>/client/
To install using Docker on a VM (e.g., CentOS) with locally stored OXL/files, for production instances:
- Create a folder for your KnetMiner species, and copy into it the species OXL file, SemanticMotifs.txt, basemap.xml and other required files (e.g.,
build-docker.sh
). - Also copy Dockerfile-local to this folder
- You can edit the GitHub repo and branch to use in Dockerfile-local
- Run
build-docker.sh
in this folder. This takes all the local data in this folder and invokes Dockerfile-local (with somebuild-args
) which pulls code from GitHub and builds a Docker image, e.g, knetminer-arabidopsis-v3.0 using a specific OXL and on a specific port. - Once built, use
docker run -p8080:8080 -it --rm knetminer-arabidopsis-v3.0
to run it onlocalhost:8080
(change port number & image_name as defined inbuild-docker.sh
). Note: when container is starting up Tomcat and deploying OXL, press Ctrl+P and Ctrl+Q to exit to terminal while keeping interactive container running. - Access the deployed KnetMiner GUI on
localhost:8080/client
and back-end API (api_url) vialocalhost:8080/ws/
. Note: These can later be re-directed in organisation/group's external DNS to generic url's to mask thehost
andport
. -
Debugging: Check logs inside the running container via
docker exec -it containerID /bin/sh
. You will be at/root
which has:data.oxl
and Tomcat logs at/usr/local/tomcat/logs/
(seen via, e.g.,tail -f /usr/local/tomcat/logs/ws.log
). Docker logs can also be followed via:docker logs -f containerID
.
To install using Docker on a VM, with locally stored data (OXL/files) + application code (useful for debug mode), for test/dev instances:
- Clone KnetMiner code on the VM in a new folder (e.g., in /home/usern/), e.g, clone latest branch manually from GitHub via:
git clone --single-branch -b knetminer-3.0 https://github.com/Rothamsted/knetminer.git
- For a particular species, e.g., Arabidopsis, ensure the latest files (semantic motifs, image, example queries) are in the correct species/ folder locally, e.g., at species-arabidopsis-url
- Upload your latest species OXL into this folder as well.
- Run
build-docker-dev.sh
in this folder (knetminer/species/arabidopsis/
). This takes all the local data in this folder and invokes Dockerfile-dev (with somebuild-args
) which builds a Docker image, e.g, knetminer-arabidopsis-v3.0 using a specific OXL and on a specific port, using KnetMiner code you pulled on this VM. - Once built, use
docker run -p8080:8080 -it --rm knetminer-arabidopsis-v3.0
to run it onlocalhost:8080
(change port number & image_name as defined inbuild-docker-dev.sh
). Note: when container is starting up Tomcat and deploying OXL, press Ctrl+P and Ctrl+Q to exit to terminal while keeping interactive container running. - Access the deployed KnetMiner GUI on
localhost:8080/client
and back-end API (api_url) vialocalhost:8080/ws/
. Note: These can later be re-directed in organisation/group's external DNS to generic url's to mask thehost
andport
. -
Debugging: Check logs inside the running container via
docker exec -it containerID /bin/sh
. You will be at/root
which has:knetminer/common/
code anddata.oxl
while Tomcat logs will be at/usr/local/tomcat/logs/
(seen via, e.g.,tail -f /usr/local/tomcat/logs/ws.log
). Docker logs can also be followed via:docker logs -f containerID
.
- To view all images on a VM, use
docker images
- To view all containers on a VM, use
docker ps
- To follow logs:
docker logs -f containerID
- To stop/remove a running container, use
docker stop containerID
(containerID
can be listed first viadocker ps
). - To delete an old image, use
docker image rm imageID
(imageID
can be listed first viadocker images
). - To remove "dangling images" (after image deletion), use
docker image prune
-
Optional: To clean-up a VM, use
docker system prune
and then enter 'y' (removes all stopped containers, dangling images and unused volumes to free up max. space). -
Optional: To delete an old, stopped container, use
docker container rm containerID
- further info. at: linux-Docker-cleanup and cleanup-dangling-containers-images