-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dockerize #97
Dockerize #97
Changes from all commits
5da2fd5
626770a
5035cf7
57aff94
02d72b1
df918cc
515b28f
b85604d
86dcdfb
3789531
a05c959
ba3f96b
89dc6b1
35cf215
d9b68aa
d2322b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.git | ||
.github | ||
.gitignore | ||
.travis.yml | ||
mkdocs.yml | ||
docs | ||
tests | ||
Dockerfile | ||
docker-compose.yml |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "1.2" | ||
__version__ = "1.3" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
version: '3' | ||
northwestwitch marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# usage: | ||
# sudo docker-compose build | ||
# sudo docker-compose up | ||
services: | ||
mongodb: | ||
image: mvertes/alpine-mongo | ||
container_name: mongodb | ||
ports: | ||
- '27017:27017' | ||
expose: | ||
- '27017' | ||
|
||
beacon-cli: | ||
environment: | ||
MONGODB_HOST: mongodb | ||
image: northwestwitch/cgbeacon2 | ||
container_name: beacon-cli | ||
links: | ||
- mongodb | ||
command: bash -c 'cgbeacon2 add demo' | ||
|
||
beacon-web: | ||
environment: | ||
MONGODB_HOST: mongodb | ||
image: northwestwitch/cgbeacon2 | ||
container_name: beacon-web | ||
links: | ||
- mongodb | ||
expose: | ||
- '5000' | ||
ports: | ||
- '5000:5000' | ||
command: bash -c 'cgbeacon2 run --host 0.0.0.0' |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,120 @@ | ||||||
## Setting up a server from a Docker image | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Very nice! Again the test data would be nice here as well There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||||||
|
||||||
The beacon app is consisting of a **backend** that is used for: | ||||||
- Creating and removing datasets | ||||||
- Adding or removing variants for one of more samples of a dataset | ||||||
- Loading demo data (not used in production, just in a test server) | ||||||
- Updating the genes in the database | ||||||
|
||||||
At the same time, the command `cgbeacon run` starts a **frontend** server with the following API endpoints: | ||||||
``` | ||||||
Endpoint Methods Rule | ||||||
----------------- --------- ------------------------------ | ||||||
api_v1.add POST /apiv1.0/add | ||||||
api_v1.delete POST /apiv1.0/delete | ||||||
api_v1.info GET /apiv1.0/ | ||||||
api_v1.query GET, POST /apiv1.0/query | ||||||
api_v1.query_form GET, POST /apiv1.0/query_form | ||||||
``` | ||||||
|
||||||
A Docker image for creating both backend and frontend containers is available on [Docker Hub](https://hub.docker.com/repository/docker/northwestwitch/cgbeacon2). | ||||||
Alternatively the Dockerfile used for creating the image is available in this repositiory, under containers/base/Dockerfile. | ||||||
|
||||||
A local image of the repository can be created by moving the Dockerfile in the root folder of the app and from the same location, in a terminal, running the following command: | ||||||
|
||||||
``` | ||||||
docker build -t cgbeacon2 . | ||||||
``` | ||||||
|
||||||
The container with the docker image contains only the beacon app and its required libraries. In order to work the container must be connected with at least one other container hosting a running mongodb instance. | ||||||
|
||||||
|
||||||
## Setting up the app backend: | ||||||
|
||||||
A simple running instance of the app backend connected to the database and ready to execute commands could be created in different ways. This is an example using docker-compose: | ||||||
|
||||||
Create a file docker-compose.yml containing the following code: | ||||||
|
||||||
``` | ||||||
version: '3' | ||||||
# usage: | ||||||
# sudo docker-compose build | ||||||
# sudo docker-compose up | ||||||
services: | ||||||
mongodb: | ||||||
image: mvertes/alpine-mongo | ||||||
container_name: mongodb | ||||||
ports: | ||||||
- '27017:27017' | ||||||
expose: | ||||||
- '27017' | ||||||
|
||||||
beacon-cli: | ||||||
environment: | ||||||
MONGODB_HOST: mongodb | ||||||
image: northwestwitch/cgbeacon2 | ||||||
container_name: beacon-cli | ||||||
links: | ||||||
- mongodb | ||||||
stdin_open: true # docker run -i | ||||||
tty: true # docker run -t | ||||||
``` | ||||||
|
||||||
Run the containers and open an interactive shell for the backend by typing: | ||||||
``` | ||||||
docker-compose run beacon-cli /bin/bash | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
You can use
to the Dockerfile instead There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I include the CMD command in the Dockerfile it's not usable any more for launching the server. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can't use -d here because then it won't be interactive any more. I'd just get the ID of the image and I won't be able to type and run commands in the shell |
||||||
``` | ||||||
|
||||||
To populate the database with demo data (dataset + case variants) type: | ||||||
``` | ||||||
cgbeacon2 add demo | ||||||
``` | ||||||
|
||||||
Exit from the execution of the images by typing `exit` | ||||||
|
||||||
## Starting an app server connected to the database | ||||||
|
||||||
An app server instance connected to the server might be started in a similar way using Docker Compose. This is an example of a such server, listening for incoming requests on port 5000, from hosts outside the container. | ||||||
|
||||||
Example of docker-compose.yml file: | ||||||
|
||||||
``` | ||||||
version: '3' | ||||||
|
||||||
services: | ||||||
mongodb: | ||||||
image: mvertes/alpine-mongo | ||||||
container_name: mongodb | ||||||
ports: | ||||||
- '27017:27017' | ||||||
expose: | ||||||
- '27017' | ||||||
|
||||||
beacon-web: | ||||||
environment: | ||||||
MONGODB_HOST: mongodb | ||||||
image: northwestwitch/cgbeacon2 | ||||||
container_name: beacon-web | ||||||
links: | ||||||
- mongodb | ||||||
expose: | ||||||
- '5000' | ||||||
ports: | ||||||
- '5000:5000' | ||||||
command: bash -c 'cgbeacon2 run --host 0.0.0.0' | ||||||
``` | ||||||
|
||||||
Run the server as a service (detached mode) by typing | ||||||
``` | ||||||
docker.compose up -d | ||||||
``` | ||||||
|
||||||
The server should be now listing for requests. Test that it is working by sending a request to the beacon info endpoint from another terminal window: | ||||||
``` | ||||||
curl -X GET 'http://127.0.0.1:5000/apiv1.0/' | ||||||
``` | ||||||
|
||||||
Stop the server by typing: | ||||||
``` | ||||||
docker.compose down | ||||||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice if there was some test data and instruction for how to populate the database for testing only
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, I'll add the command to load the demo data!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The command to load the data is actually already included in the demo, but I'll comment about it in the readme and the docs