From 81f218509f5faedc0affdd46f7e2d40ab65223da Mon Sep 17 00:00:00 2001 From: Ben Gyori Date: Wed, 13 Oct 2021 19:57:17 -0400 Subject: [PATCH 01/13] Add initial dockerfile --- docker/Dockerfile | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 docker/Dockerfile diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 00000000..d7c1cc8e --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.9 + +RUN git clone https://github.com/biopragmatics/biomappings.git && \ + cd biomappings && \ + pip install -e .[web] + +ENTRYPOINT ["biomappings", "web"] From 12854da69ca3ac1e872070c3576dcdffc9758846 Mon Sep 17 00:00:00 2001 From: Ben Gyori Date: Wed, 13 Oct 2021 19:58:03 -0400 Subject: [PATCH 02/13] Make host visible from outside --- docker/Dockerfile | 2 +- src/biomappings/wsgi.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index d7c1cc8e..a3264860 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,6 +1,6 @@ FROM python:3.9 -RUN git clone https://github.com/biopragmatics/biomappings.git && \ +RUN git clone --branch dockerize https://github.com/biopragmatics/biomappings.git && \ cd biomappings && \ pip install -e .[web] diff --git a/src/biomappings/wsgi.py b/src/biomappings/wsgi.py index 321f50b0..a66e8f80 100644 --- a/src/biomappings/wsgi.py +++ b/src/biomappings/wsgi.py @@ -357,4 +357,4 @@ def _go_home(): if __name__ == "__main__": - app.run() + app.run(host='0.0.0.0') From 67f05b47147489330ee4bc555df42743a11f0bb3 Mon Sep 17 00:00:00 2001 From: Ben Gyori Date: Wed, 13 Oct 2021 20:53:27 -0400 Subject: [PATCH 03/13] Implement sed replacement to SSH --- docker/Dockerfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index a3264860..cb5dbbc1 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,7 +1,10 @@ FROM python:3.9 -RUN git clone --branch dockerize https://github.com/biopragmatics/biomappings.git && \ +# Note: you can only clone HTTP anonymously so we clone using HTTPs +# and then use sed to rewrite the remote to be SSH-based +RUN git clone --branch dockerize https://github.com/biopragmatics/biomappings.git && \ cd biomappings && \ + sed -i 's/https:\/\/github.com\//git@github.com:/g' .git/config && \ pip install -e .[web] ENTRYPOINT ["biomappings", "web"] From f56df925642ae1e2c43d41120bdaa66172d0cbfb Mon Sep 17 00:00:00 2001 From: Ben Gyori Date: Wed, 13 Oct 2021 21:00:21 -0400 Subject: [PATCH 04/13] Add custom startup script --- docker/Dockerfile | 3 ++- docker/startup.sh | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100755 docker/startup.sh diff --git a/docker/Dockerfile b/docker/Dockerfile index cb5dbbc1..4d508219 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -7,4 +7,5 @@ RUN git clone --branch dockerize https://github.com/biopragmatics/biomappings. sed -i 's/https:\/\/github.com\//git@github.com:/g' .git/config && \ pip install -e .[web] -ENTRYPOINT ["biomappings", "web"] +COPY startup.sh /startup.sh +ENTRYPOINT ["/startup.sh"] diff --git a/docker/startup.sh b/docker/startup.sh new file mode 100755 index 00000000..5da370a7 --- /dev/null +++ b/docker/startup.sh @@ -0,0 +1,5 @@ +#!/bin/bash +cd /biomappings +git remote set-url origin git@github.com:$GITHUBUSER/biomappings.git +git checkout -b curation +biomappings web From 22b955fbb4db798d6d1c600c559fce245f8219a4 Mon Sep 17 00:00:00 2001 From: Ben Gyori Date: Wed, 13 Oct 2021 21:11:27 -0400 Subject: [PATCH 05/13] Add README for Docker use --- docker/README.md | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 docker/README.md diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 00000000..1e9c5216 --- /dev/null +++ b/docker/README.md @@ -0,0 +1,42 @@ +# Running Biomappings via Docker for curation + +1. Fork the Biomappings repository + +To preform curations using the Biomappings web interface, and contribute +these back through Github, you first have to fork the biomappings repository +as follows. + +Go to https://github.com/biopragmatics/biomappings, and click on the Fork +button in the right upper corner of the page. Assuming your user name is +GITHUBUSER, this will create a forked repository at +https://github.com/GITHUBUSER/biomappings. + +2. Run the Biomappings Docker + +Since contributions are pushed to Github, when running the Docker locally, +the Docker needs to have (read only) access to: +- The host machine's git configuration (which contains the name and email of +the contributor) and is typically stored in ~/.gitconfig +- The host machine's SSH key which provides push access to GITHUBUSER's +fork of the biomappings repo. This is typically stored in the ~/.ssh folder. + +In the run command below, these two paths are mounted into the container. +Further the GITHUBUSER value described above has to be provided as an +environment variable. + +``` +docker run -d -it -p 5000:5000 -v ~/.ssh:/root/.ssh:ro -v ~/.gitconfig:/root/.gitconfig:ro -e GITHUBUSER= biomappings:latest +``` + +3. Launch the website and curate + +Once the Docker container is running, you can open a browser and go to +http://localhost:5000, and start curating. Once done with a batch of curations, +click on the Commit button to have these committed and pushed to +the `curation` branch of https://github.com/GITHUBUSER/biomappings. + +4. Submit a pull request + +To contribute curations back to the main Biomappings repository, +go to https://github.com/biopragmatics/biomappings, and open a +pull request from the GITHUBUSER/curation branch. From 69ccaca876fb51f7e83dc1f8cc464977ce356f0b Mon Sep 17 00:00:00 2001 From: Ben Gyori Date: Wed, 13 Oct 2021 21:12:40 -0400 Subject: [PATCH 06/13] Add more documentation --- docker/Dockerfile | 2 +- docker/README.md | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 4d508219..52ec9ce7 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -2,7 +2,7 @@ FROM python:3.9 # Note: you can only clone HTTP anonymously so we clone using HTTPs # and then use sed to rewrite the remote to be SSH-based -RUN git clone --branch dockerize https://github.com/biopragmatics/biomappings.git && \ +RUN git clone https://github.com/biopragmatics/biomappings.git && \ cd biomappings && \ sed -i 's/https:\/\/github.com\//git@github.com:/g' .git/config && \ pip install -e .[web] diff --git a/docker/README.md b/docker/README.md index 1e9c5216..f2d23fe2 100644 --- a/docker/README.md +++ b/docker/README.md @@ -40,3 +40,10 @@ the `curation` branch of https://github.com/GITHUBUSER/biomappings. To contribute curations back to the main Biomappings repository, go to https://github.com/biopragmatics/biomappings, and open a pull request from the GITHUBUSER/curation branch. + +# Building the docker image + +To build the image, run the following +``` +docker build --tag biomappings:latest . +``` From 5f46ee9fc6648675f25cdd050ec3ef087c4b6c9c Mon Sep 17 00:00:00 2001 From: Charles Tapley Hoyt Date: Thu, 14 Oct 2021 11:30:04 +0200 Subject: [PATCH 07/13] Remove docker folder from manifest --- MANIFEST.in | 1 + 1 file changed, 1 insertion(+) diff --git a/MANIFEST.in b/MANIFEST.in index 08a19dbf..2b248ece 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -3,6 +3,7 @@ graft tests prune docs prune scripts prune docs/_data +prune docker global-exclude *.py[cod] __pycache__ *.so *.dylib .DS_Store *.gpickle From 436eb190419acea237860bff563f8fb1306a25aa Mon Sep 17 00:00:00 2001 From: Charles Tapley Hoyt Date: Thu, 14 Oct 2021 11:30:09 +0200 Subject: [PATCH 08/13] Blacken --- src/biomappings/wsgi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/biomappings/wsgi.py b/src/biomappings/wsgi.py index a66e8f80..ec87c10c 100644 --- a/src/biomappings/wsgi.py +++ b/src/biomappings/wsgi.py @@ -357,4 +357,4 @@ def _go_home(): if __name__ == "__main__": - app.run(host='0.0.0.0') + app.run(host="0.0.0.0") From f8f2a55a727dceccf9b7220c2983935307f2388f Mon Sep 17 00:00:00 2001 From: Charles Tapley Hoyt Date: Thu, 14 Oct 2021 11:33:23 +0200 Subject: [PATCH 09/13] Update README.md --- docker/README.md | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/docker/README.md b/docker/README.md index f2d23fe2..2b5a636c 100644 --- a/docker/README.md +++ b/docker/README.md @@ -1,41 +1,42 @@ # Running Biomappings via Docker for curation -1. Fork the Biomappings repository +## 1. Fork the Biomappings repository To preform curations using the Biomappings web interface, and contribute -these back through Github, you first have to fork the biomappings repository +these back through GitHub, you first have to fork the Biomappings repository as follows. Go to https://github.com/biopragmatics/biomappings, and click on the Fork -button in the right upper corner of the page. Assuming your user name is +button in the right upper corner of the page. Assuming your username is GITHUBUSER, this will create a forked repository at https://github.com/GITHUBUSER/biomappings. -2. Run the Biomappings Docker +## 2. Run the Biomappings Docker -Since contributions are pushed to Github, when running the Docker locally, +Since contributions are pushed to GitHub, when running the Docker locally, the Docker needs to have (read only) access to: + - The host machine's git configuration (which contains the name and email of -the contributor) and is typically stored in ~/.gitconfig + the contributor) and is typically stored in `~/.gitconfig` - The host machine's SSH key which provides push access to GITHUBUSER's -fork of the biomappings repo. This is typically stored in the ~/.ssh folder. + fork of the Biomappings repo. This is typically stored in the `~/.ssh` folder. In the run command below, these two paths are mounted into the container. -Further the GITHUBUSER value described above has to be provided as an +Further, the `GITHUBUSER` value described above has to be provided as an environment variable. -``` +```shell docker run -d -it -p 5000:5000 -v ~/.ssh:/root/.ssh:ro -v ~/.gitconfig:/root/.gitconfig:ro -e GITHUBUSER= biomappings:latest ``` -3. Launch the website and curate +## 3. Launch the website and curate Once the Docker container is running, you can open a browser and go to http://localhost:5000, and start curating. Once done with a batch of curations, click on the Commit button to have these committed and pushed to the `curation` branch of https://github.com/GITHUBUSER/biomappings. -4. Submit a pull request +## 4. Submit a pull request To contribute curations back to the main Biomappings repository, go to https://github.com/biopragmatics/biomappings, and open a @@ -44,6 +45,7 @@ pull request from the GITHUBUSER/curation branch. # Building the docker image To build the image, run the following -``` + +```shell docker build --tag biomappings:latest . ``` From 26c7163f8105160243f8c6416ecc068a3babf01c Mon Sep 17 00:00:00 2001 From: Charles Tapley Hoyt Date: Thu, 14 Oct 2021 11:35:15 +0200 Subject: [PATCH 10/13] Update README.md --- docker/README.md | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/docker/README.md b/docker/README.md index 2b5a636c..c07582ed 100644 --- a/docker/README.md +++ b/docker/README.md @@ -2,24 +2,27 @@ ## 1. Fork the Biomappings repository -To preform curations using the Biomappings web interface, and contribute -these back through GitHub, you first have to fork the Biomappings repository -as follows. +To preform curations using the Biomappings web interface, and contribute these +back through GitHub, you first have to fork the Biomappings repository as +follows: -Go to https://github.com/biopragmatics/biomappings, and click on the Fork -button in the right upper corner of the page. Assuming your username is -GITHUBUSER, this will create a forked repository at -https://github.com/GITHUBUSER/biomappings. +1. Go to https://github.com/biopragmatics/biomappings +2. Click on the Fork button in the right upper corner of the page. Assuming your + username is GITHUBUSER, this will create a forked repository at + https://github.com/GITHUBUSER/biomappings. + +See also the GitHub [Fork a Repo](https://docs.github.com/en/get-started/quickstart/fork-a-repo) +tutorial. ## 2. Run the Biomappings Docker -Since contributions are pushed to GitHub, when running the Docker locally, -the Docker needs to have (read only) access to: +Since contributions are pushed to GitHub, when running the Docker locally, the +Docker needs to have (read only) access to: -- The host machine's git configuration (which contains the name and email of - the contributor) and is typically stored in `~/.gitconfig` -- The host machine's SSH key which provides push access to GITHUBUSER's - fork of the Biomappings repo. This is typically stored in the `~/.ssh` folder. +- The host machine's git configuration (which contains the name and email of the + contributor) and is typically stored in `~/.gitconfig` +- The host machine's SSH key which provides push access to GITHUBUSER's fork of + the Biomappings repo. This is typically stored in the `~/.ssh` folder. In the run command below, these two paths are mounted into the container. Further, the `GITHUBUSER` value described above has to be provided as an @@ -33,14 +36,14 @@ docker run -d -it -p 5000:5000 -v ~/.ssh:/root/.ssh:ro -v ~/.gitconfig:/root/.gi Once the Docker container is running, you can open a browser and go to http://localhost:5000, and start curating. Once done with a batch of curations, -click on the Commit button to have these committed and pushed to -the `curation` branch of https://github.com/GITHUBUSER/biomappings. +click on the Commit button to have these committed and pushed to the `curation` +branch of https://github.com/GITHUBUSER/biomappings. ## 4. Submit a pull request -To contribute curations back to the main Biomappings repository, -go to https://github.com/biopragmatics/biomappings, and open a -pull request from the GITHUBUSER/curation branch. +To contribute curations back to the main Biomappings repository, go +to https://github.com/biopragmatics/biomappings, and open a pull request from +the GITHUBUSER/curation branch. # Building the docker image From 701a7941190e7e5b32baa956bbe5eb32cff774be Mon Sep 17 00:00:00 2001 From: Charles Tapley Hoyt Date: Thu, 14 Oct 2021 11:37:55 +0200 Subject: [PATCH 11/13] Update README.md --- docker/README.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/docker/README.md b/docker/README.md index c07582ed..7663f17e 100644 --- a/docker/README.md +++ b/docker/README.md @@ -8,10 +8,11 @@ follows: 1. Go to https://github.com/biopragmatics/biomappings 2. Click on the Fork button in the right upper corner of the page. Assuming your - username is GITHUBUSER, this will create a forked repository at + username is `GITHUBUSER`, this will create a forked repository at https://github.com/GITHUBUSER/biomappings. -See also the GitHub [Fork a Repo](https://docs.github.com/en/get-started/quickstart/fork-a-repo) +See also the +GitHub [Fork a Repo](https://docs.github.com/en/get-started/quickstart/fork-a-repo) tutorial. ## 2. Run the Biomappings Docker @@ -22,7 +23,9 @@ Docker needs to have (read only) access to: - The host machine's git configuration (which contains the name and email of the contributor) and is typically stored in `~/.gitconfig` - The host machine's SSH key which provides push access to GITHUBUSER's fork of - the Biomappings repo. This is typically stored in the `~/.ssh` folder. + the Biomappings repo. This is typically stored in the `~/.ssh` folder. If you + don't have one already, follow GitHub's guide + to [making an SSH key](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account) In the run command below, these two paths are mounted into the container. Further, the `GITHUBUSER` value described above has to be provided as an From 42cf220d447ef18d378294281b5fb8dbfdc2c747 Mon Sep 17 00:00:00 2001 From: Charles Tapley Hoyt Date: Thu, 14 Oct 2021 12:32:40 +0200 Subject: [PATCH 12/13] Update example for running docker Rather than including detach by default, I added a note below. --- docker/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docker/README.md b/docker/README.md index 7663f17e..b69badf1 100644 --- a/docker/README.md +++ b/docker/README.md @@ -32,9 +32,11 @@ Further, the `GITHUBUSER` value described above has to be provided as an environment variable. ```shell -docker run -d -it -p 5000:5000 -v ~/.ssh:/root/.ssh:ro -v ~/.gitconfig:/root/.gitconfig:ro -e GITHUBUSER= biomappings:latest +docker run -it -p 5000:5000 -v ~/.ssh:/root/.ssh:ro -v ~/.gitconfig:/root/.gitconfig:ro -e GITHUBUSER= biomappings:latest ``` +Add `-d` to detach. + ## 3. Launch the website and curate Once the Docker container is running, you can open a browser and go to From 7298926fde29bf9e290f6934b75f790eeedd9412 Mon Sep 17 00:00:00 2001 From: Charles Tapley Hoyt Date: Thu, 14 Oct 2021 12:33:45 +0200 Subject: [PATCH 13/13] Add small amount of logging to startup.sh The --version got added in master but should be able to print out this info The --host option should also be available --- docker/startup.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docker/startup.sh b/docker/startup.sh index 5da370a7..6e6414ed 100755 --- a/docker/startup.sh +++ b/docker/startup.sh @@ -2,4 +2,5 @@ cd /biomappings git remote set-url origin git@github.com:$GITHUBUSER/biomappings.git git checkout -b curation -biomappings web +biomappings --version +biomappings web --host "0.0.0.0"