AmpliconSuite / AmpliconRepository

Website to host AmpliconSuite outputs, including AA outputs and resulting focal amplification classifications, such as ecDNA.
https://AmpliconRepository.org
BSD 3-Clause "New" or "Revised" License
1 stars 5 forks source link
bfb cancer ecdna genomics-data

AmpliconRepository

Authors: Forrest Kim, Jens Luebeck, Ted Liefeld, Edwin Huang, Gino Prasad, Rohil Ahuja, Rishaan Kenkre, Tushar Agashe, Devika Torvi, Madalina Giurgiu, Thorin Tabor, Vineet Bafna


This is the main repository for the AmpliconRepository website. The documentation below provides intsructions on deploying the site locally, for development purposes.

There are two options for running the server locally:

Option A: Manually install modules and configure the environment step-by-step.

Option B: Use Docker to deploy the server and its environment on your system.

Option A - install the development environment for AmpliconRepository:

Requirements

1. Clone the repository from GitHub

2. Set up the virtual environment and install packages:

3. Set up MongoDB locally (for development)

3a. View MongoDB data in MongoDB Compass

3b. Clearing your local DB

Periodically, you will want to purge old or excessively large accumulated data from you DB. You can do this using the provided script

python purge-local-db.py

4. Set up secret keys for OAuth2 and other environment variables

For local deployments, you will need to ensure that the following two variables are set to FALSE, as shown below

export S3_STATIC_FILES=FALSE
export S3_FILE_DOWNLOADS='FALSE'

IMPORTANT: After recieving your config.sh, please ensure you do not upload it to Github or make it available publicly anywhere.

5. Run development server (Django)

Option B - Local deployment with Docker:

These steps guide users on how to set up their development environment using Docker and docker compose as an alternative to python or conda-based package management and installation. This is the simplest way to locally deploy the server for new users.

Important: You first need to install docker>=20.10 on your machine.

To test the installation of Docker please do:

# check version: e.g. Docker version 20.10.8, build 3967b7d
docker --version

# check if compose module is present
docker compose --help

# check docker engine installation
sudo docker run hello-world

Quickstart

Build and run your development webserver and mongo db using docker:

cd AmpliconRepository
# place config.sh in caper/, and place .env in current dir
# change UID and GID in .env to match the host configuration
# create all folders which you want to expose to the container
mkdir -p logs tmp .aws .git
docker compose -f docker-compose-dev.yml build --no-cache --progress=plain
docker compose -f docker-compose-dev.yml up -d
# then visit http://localhost:8000/ in your web browser
# once finished, to shutdown:
docker compose -f docker-compose-dev.yml down

Complete steps

i. Start your docker daemon and make sure is running:

# for linux
sudo systemctl start docker
docker --help
docker compose --help

# or alternatively start manually from interface (macos or windows)

ii. Clone the repository (skip this if you have already done this):

git clone https://github.com/AmpliconSuite/AmpliconRepository.git

iii. Build a local Docker image:

This command will create a Docker image genepattern/amplicon-repo:dev-test with your environment, all dependencies and application code you need to run the webserver. Additionally, this command will pull a mongo:4 image for the test database.

First, obtain the secret files .env and config.sh from another developer. Do not share these files with others outside the project. Do not upload them anywhere. Keep them private.

Next, Place .env under AmpliconRepository/ and config.sh under AmpliconRepository/caper/.

You should see these required files:

cd AmpliconRepository
docker compose -f docker-compose-dev.yml build --progress=plain --no-cache

iv. Run webserver and mongo db instances:

This command will:

# create all folders exposed to container
mkdir -p logs tmp .aws .git
# start container using the host UID and GID (change in .env)
docker compose -f docker-compose-dev.yml up -d
#[+] Running 2/2
# ⠿ Container ampliconrepository-mongodb-1  Started                                                                                                                           0.3s
# ⠿ Container amplicon-dev                  Started                                                                                                                           1.1s

To check if your containers are running do:

docker ps

and you should see something like below:

# CONTAINER ID   IMAGE                                COMMAND                   CREATED         STATUS              PORTS                      NAMES
# 311a560ec20a   genepattern/amplicon-repo:dev   "/bin/sh -c 'echo \"H…"   3 minutes ago   Up About a minute   0.0.0.0:8000->8000/tcp     amplicon-dev
# deaa521621f1   mongo:4                              "docker-entrypoint.s…"    4 days ago      Up About a minute   0.0.0.0:27017->27017/tcp   ampliconrepository_mongodb_1

To view the site locally, visit http://localhost:8000/ in your web browser.

v. Stop webserver and mongodb

To stop the webserver and mongodb service:

docker compose -f docker-compose-dev.yml down
#[+] Running 3/2
# ⠿ Container amplicon-dev                  Removed                                                                                                                          10.3s
# ⠿ Container ampliconrepository-mongodb-1  Removed                                                                                                                           0.3s
# ⠿ Network ampliconrepository_default      Removed                                                                                                                           0.0s

vi. Check environment configuration of your docker-compose

Before you build your image you can check if the config.sh is set correctly by doing:

docker compose -f docker-compose-dev.yml config

This command will show you the docker-compose-dev.yml customized with your environment variables.

vii. Check environment variables for running container

You can check the environment variables which your running container uses:

docker inspect -f \
   '{{range $index, $value := .Config.Env}} {{$value}}{{println}}{{end}}' \
   container_id

viii. Debug

Testing datasets

These datasets are ready to upload to the site for testing purposes.

Pushing changes to GitHub and merging PRs

Using the development server

Logging in as admin

How to deploy and update the production server for AmpliconRepository

The server is currently running on an EC2 instance through Docker. The ports active on HTTP and HTTPS through AWS Load Balancer. There are two main scripts to start and stop the server.

Note: While we provide a Dockerfile, local deployment of the site using the docker will only properly work on AWS. Local deployment should be done with a local install using the steps above.

1. How to start the server

2. How to stop the server

3. How to update the server