-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #70 from databio/dev
updated bedhost docs
- Loading branch information
Showing
3 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters