Skip to content

Commit

Permalink
Merge pull request #70 from databio/dev
Browse files Browse the repository at this point in the history
updated bedhost docs
  • Loading branch information
khoroshevskyi authored May 2, 2024
2 parents 2032ccc + b3e5282 commit 440869a
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 0 deletions.
38 changes: 38 additions & 0 deletions docs/bedhost/build_image.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Build the container locally

Running with `uvicorn` provides auto-reload. To configure, this assumes you have previously set up `databio/secrets`.

1. Source `.env` file to populate the environment variables referenced in the configuration file.
2. Start `bedhost` using `uvicorn` and pass the configuration file via the `BEDBASE_CONFIG` env var.


```console
source ../bedbase.org/environment/production.env
BEDBASE_CONFIG=../bedbase.org/config/api.bedbase.org.yaml uvicorn bedhost.main:app --reload
```

You can change the database you're connecting to by using a different config file:
- Using a local config: `BEDBASE_CONFIG=../bbconf/tests/data/config.yaml uvicorn bedhost.main:app --reload`
- With new database: `BEDBASE_CONFIG=../bedbase.org/config/bedbase2.yaml uvicorn bedhost.main:app --reload`

Now, you can access the service at [http://127.0.0.1:8000](http://127.0.0.1:8000). Example endpoints:
- http://127.0.0.1:8000/v1/bed/bbad85f21962bb8d972444f7f9a3a932/metadata?full=true
- http://127.0.0.1:8000/v1/bed/bbad85f21962bb8d972444f7f9a3a932/metadata/plots?full=true
- http://127.0.0.1:8000/v1/objects/bed.bbad85f21962bb8d972444f7f9a3a932.chrombins
- http://127.0.0.1:8000/v1/bed/list?limit=10&offset=0


## Running the server in Docker

### Building image

- Primary image: `docker build -t databio/bedhost -f .Dockerfile .`
- Dev image `docker build -t databio/bedhost:dev -f dev.Dockerfile .`
- Test image: `docker build -t databio/bedhost:dev -f test.Dockerfile .`

Existing images can be found [at dockerhub](https://hub.docker.com/r/databio/bedhost).


## Deploying updates automatically

- [Deploying bedbase](./deployment.md).
64 changes: 64 additions & 0 deletions docs/bedhost/deployment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Deploying bedbase.org

This repository deploys the API for bedbase. It will run these services:

1. production API: https://api.bedbase.org/
2. dev API: https://api-dev.bedbase.org/

This repo will deploy a new service by following these steps:

1. Build an image by packaging the bedhost image (from dockerhub) with the bbconf file in this repository.
2. Push that image to AWS.
3. Deploy it to yeti cluster with aws task def.

## Build the container

Here we use the `databio/bedhost` container on dockerhub, and just add the configuration file in this repo to it, so build is super fast.

```
docker build -t databio/bedhost-configured -f Dockerfiles/primary.Dockerfile .
```

Or for dev:

```
docker build -t databio/bedhost-configured-dev -f Dockerfiles/dev1.Dockerfile .
```

## Run it locally to test

First, source the .env file to set env vars in the calling environment.
Then, use `--env-file` to pass those env vars through to the container

```
source environment/production.env
docker run --rm --network="host" \
--env-file environment/docker.env \
databio/bedhost-configured-dev
```

Here's another example for running the container:

```
docker run --rm --init -p 8000:8000 --name bedstat-rest-server \
--network="host" \
--volume ~/code/bedbase.org/config/api.bedbase.org.yaml:/bedbase.yaml \
--env-file ../bedbase.org/environment/docker.env \
--env BEDBASE_CONFIG=/bedbase.yaml \
databio/bedhost uvicorn bedhost.main:app --reload
```

## Building the Amazon-tagged version

You could build and push to ECR like this if you need it... but the github action will do this for you.

Authenticate with AWS ECR:
```
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 235728444054.dkr.ecr.us-east-1.amazonaws.com
```

Build/tag/push image:
```
docker build -t 235728444054.dkr.ecr.us-east-1.amazonaws.com/bedhost -f Dockerfiles/primary.Dockerfile .
docker push 235728444054.dkr.ecr.us-east-1.amazonaws.com/bedhost
```
2 changes: 2 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ nav:
- BEDhost API guide:
- BEDhost: bedhost/README.md
- Developer Guide: bedhost/dev-guide.md
- Build image: bedhost/build_image.md
- Deploy API: bedhost/deployment.md
- Changelog: bedhost/changelog.md
- BBConf:
- BBConf: bbconf/README.md
Expand Down

0 comments on commit 440869a

Please sign in to comment.