Skip to content
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

Implement Dockerization #69

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 11 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
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 https://github.com/biopragmatics/biomappings.git && \
cthoyt marked this conversation as resolved.
Show resolved Hide resolved
cd biomappings && \
sed -i 's/https:\/\/github.com\//[email protected]:/g' .git/config && \
pip install -e .[web]

COPY startup.sh /startup.sh
ENTRYPOINT ["/startup.sh"]
59 changes: 59 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# 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:

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:

- 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. 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
environment variable.

```shell
docker run -it -p 5000:5000 -v ~/.ssh:/root/.ssh:ro -v ~/.gitconfig:/root/.gitconfig:ro -e GITHUBUSER=<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
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.

# Building the docker image

To build the image, run the following

```shell
docker build --tag biomappings:latest .
```
6 changes: 6 additions & 0 deletions docker/startup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
cd /biomappings
git remote set-url origin [email protected]:$GITHUBUSER/biomappings.git
git checkout -b curation
biomappings --version
biomappings web --host "0.0.0.0"
2 changes: 1 addition & 1 deletion src/biomappings/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,4 +357,4 @@ def _go_home():


if __name__ == "__main__":
app.run()
app.run(host="0.0.0.0")