Skip to content

Commit

Permalink
Dev env QOL improvements (#70)
Browse files Browse the repository at this point in the history
* use nginx for local dev revproxy

* redirect results if loaded first

* simplify build commands in task
  • Loading branch information
kvdomingo committed Jan 29, 2022
1 parent 7d56201 commit cbd5922
Show file tree
Hide file tree
Showing 19 changed files with 640 additions and 463 deletions.
122 changes: 55 additions & 67 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,67 +1,55 @@
FROM python:3.9.7-bullseye as base

ENV PYTHONUNBUFFERED 1

COPY requirements.txt /tmp/requirements.txt

RUN python -m pip install -U pip setuptools

RUN pip install --no-cache-dir -r /tmp/requirements.txt

FROM base as dev

COPY requirements.dev.txt /tmp/requirements.dev.txt
COPY requirements.txt /tmp/requirements.txt

RUN pip install --no-cache-dir -r /tmp/requirements.dev.txt

RUN sed -i "s/'_headers'/'headers'/" /usr/local/lib/python3.9/site-packages/revproxy/utils.py
RUN sed -i "s/'_headers'/'headers'/" /usr/local/lib/python3.9/site-packages/revproxy/response.py

WORKDIR /primerdriver

ENTRYPOINT python manage.py migrate \
&& SHORT_SHA=$(git show --format="%h" --no-patch) gunicorn primerx.wsgi -b 0.0.0.0:$PORT --log-file - --reload

FROM base as make-linux

RUN apt-get update
RUN apt-get install upx-ucl libgfortran-10-dev libquadmath0 -y

ENV PYTHONDONTWRITEBYTECODE 1

COPY requirements.dev.txt /tmp/requirements.dev.txt
COPY requirements.txt /tmp/requirements.txt

RUN pip install --no-cache-dir -r /tmp/requirements.dev.txt

WORKDIR /primerdriver

ENTRYPOINT [ "sh", "build.sh" ]

FROM node:16-alpine as build

WORKDIR /web

COPY ./web/app/ ./

RUN yarn install --prod

RUN yarn build

FROM base as prod

WORKDIR /primerdriver

COPY ./primerdriver/ ./primerdriver/
COPY ./primerx/ ./primerx/
COPY ./sdm/ ./sdm/
COPY ./manage.py ./manage.py
COPY ./runserver.sh ./runserver.sh
COPY --from=build /web/build ./web/app/

ARG SHORT_SHA=$SHORT_SHA

ENV SHORT_SHA $SHORT_SHA

ENTRYPOINT [ "sh", "runserver.sh" ]
FROM python:3.9.7-bullseye as base

ENV PYTHONUNBUFFERED 1

COPY requirements.txt /tmp/requirements.txt

RUN python -m pip install -U pip setuptools

RUN pip install --no-cache-dir -r /tmp/requirements.txt

FROM base as dev

COPY requirements.dev.txt /tmp/requirements.dev.txt
COPY requirements.txt /tmp/requirements.txt

RUN pip install --no-cache-dir -r /tmp/requirements.dev.txt

WORKDIR /primerdriver

ENTRYPOINT python manage.py migrate && \
SHORT_SHA=$(git show --format="%h" --no-patch) gunicorn primerx.wsgi \
-b 0.0.0.0:5000 \
--workers 2 \
--threads 4 \
--log-file - \
--capture-output \
--reload

FROM node:16-alpine as build

WORKDIR /web

COPY ./web/app/ ./

RUN yarn install --prod

RUN yarn build

FROM base as prod

WORKDIR /primerdriver

COPY ./primerdriver/ ./primerdriver/
COPY ./primerx/ ./primerx/
COPY ./sdm/ ./sdm/
COPY ./manage.py ./manage.py
COPY --from=build /web/build ./web/app/

ARG SHORT_SHA=$SHORT_SHA

ENV SHORT_SHA $SHORT_SHA

ENTRYPOINT python manage.py collectstatic --noinput && \
python manage.py migrate && \
gunicorn primerx.wsgi -b 0.0.0.0:$PORT --workers 1 --threads 2 --log-file -
18 changes: 18 additions & 0 deletions Dockerfile.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM python:3.9.7-bullseye

RUN apt-get update
RUN apt-get install upx-ucl libgfortran-10-dev libquadmath0 -y

ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWRITEBYTECODE 1

COPY requirements.dev.txt /tmp/requirements.dev.txt
COPY requirements.txt /tmp/requirements.txt

RUN pip install --no-cache-dir -r /tmp/requirements.dev.txt

RUN sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b /bin

WORKDIR /primerdriver

ENTRYPOINT [ "/bin/task", "build" ]
198 changes: 103 additions & 95 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,95 +1,103 @@
# PrimerDriver: Automated design of mutagenic PCR primers
![PrimerDriver](https://res.cloudinary.com/kdphotography-assets/image/upload/v1587460290/primerdriver/PrimerDriver_logo.png)

![GitHub](https://img.shields.io/github/license/kvdomingo/primerdriver)
![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/kvdomingo/primerdriver?include_prereleases)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/django)

## CLI

You can access and download the CLI from the
[releases page](https://github.com/kvdomingo/primerdriver/releases).
Run the program in a terminal using
```shell
primerdriver -h
```

This will run the help program. For first-time users, the program can be run in
interactive mode by passing the `-i` flag:
```shell
primerdriver -i
```

This will walk you through each option step-by-step.
Batch design can be performed by including
[`primerdriver`](primerdriver/__main__.py) as part of a shell script.

## Web application
For a more interactive experience, visit the
[web application](https://primerdriver.kvdstudio.app).

## Documentation
The documentation is available at https://kvdomingo.github.io/primerdriver/.

## Contributing
Open a PR or raise an
[issue](https://github.com/kvdomingo/primerdriver/issues).
You may also email Nomer or Kenneth, depending on the nature of the issue.

## Developing locally

### Prerequisites
- Python 3.9 or above
- Node.js LTS 14 or above
- Docker

### Installing
A step by step series of examples that tell you how to get a
development environment running

1. Clone and extract the repo.
2. Create a virtual environment and install backend dependencies:
```shell
pip install -r requirements.dev.txt
```

### Running local server

Setup the Docker containers:
```shell
docker compose up --build
```

Wait a few minutes for all the containers to start, then access the
local server in your browser at http://localhost:8000.

### Building from source
Run the script:
```shell
./build.sh
```

### Deployment
```shell
git add .
git commit -m "DESCRIPTIVE_COMMIT_MESSAGE"
git push origin your_feature_branch
```

where `your_feature_branch` should summarize the changes you are implementing
(e.g., `feature/implementing-xxxx-feature`, `bugfix/crush-critical-yyyy-bug`).


## Authors
- **Numeriano Amer "Nomer" E. Gutierrez** - Project Lead, Molecular Biologist - [Email](mailto:[email protected]) | [GitHub](https://github.com/nomgutierrez)
- **Kenneth V. Domingo** - Lead Developer, Technical Consultant - [Email](mailto:[email protected]) | [Website](https://kvdomingo.xyz) | [GitHub](https://github.com/kvdomingo)
- **Shebna Rose D. Fabilloren** - Technical Consultant - [Email](mailto:[email protected])
- **Carlo M. Lapid** - Project Adviser - [Email](mailto:[email protected])

## Versioning
This project complies with [SemVer](https://semver.org) for versioning. For
all available versions, see
[tags](https://github.com/kvdomingo/primerdriver/tags).

## License
This project is licensed under the [GPLv3 License](./LICENSE).
# PrimerDriver: Automated design of mutagenic PCR primers
![PrimerDriver](https://res.cloudinary.com/kdphotography-assets/image/upload/v1587460290/primerdriver/PrimerDriver_logo.png)

![GitHub](https://img.shields.io/github/license/kvdomingo/primerdriver)
![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/kvdomingo/primerdriver?include_prereleases)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/django)

## CLI

You can access and download the CLI from the
[releases page](https://github.com/kvdomingo/primerdriver/releases).
Run the program in a terminal using
```shell
primerdriver -h
```

This will run the help program. For first-time users, the program can be run in
interactive mode by passing the `-i` flag:
```shell
primerdriver -i
```

This will walk you through each option step-by-step.
Batch design can be performed by including
[`primerdriver`](primerdriver/__main__.py) as part of a shell script.

## Web application
For a more interactive experience, visit the
[web application](https://primerdriver.kvdstudio.app).

## Documentation
The documentation is available at https://kvdomingo.github.io/primerdriver/.

## Contributing
Open a PR or raise an
[issue](https://github.com/kvdomingo/primerdriver/issues).
You may also email Nomer or Kenneth, depending on the nature of the issue.

## Developing locally

### Prerequisites
- [Python](https://www.python.org/downloads/) 3.9 or above
- [Node.js](https://nodejs.org/en/download/) LTS 14 or above
- [Docker](https://www.docker.com/get-started)
- [Task](https://taskfile.dev/#/installation)

### Installing
A step by step series of examples that tell you how to get a
development environment running

1. Clone and extract the repo.
2. Create a virtual environment and install backend dependencies:
```shell
pip install -r requirements.dev.txt
```

### Running local server

Setup the Docker containers:
```shell
task

# To see log stream
task logs
```

Wait a few minutes for all the containers to start, then access the
local server in your browser at http://localhost:8000.

### Building from source
Run the script:
```shell
# Build for Windows on a Windows machine / for Linux on a Linux machine
task build

# Build for Linux on a Windows machine with Docker
task build-linux
```

### Deployment
```shell
git add .
git commit -m "DESCRIPTIVE_COMMIT_MESSAGE"
git push origin your_feature_branch
```

where `your_feature_branch` should summarize the changes you are implementing
(e.g., `feature/implementing-xxxx-feature`, `bugfix/crush-critical-yyyy-bug`).


## Authors
- **Numeriano Amer "Nomer" E. Gutierrez** - Project Lead, Molecular Biologist - [Email](mailto:[email protected]) | [GitHub](https://github.com/nomgutierrez)
- **Kenneth V. Domingo** - Lead Developer, Technical Consultant - [Email](mailto:[email protected]) | [Website](https://kvdomingo.xyz) | [GitHub](https://github.com/kvdomingo)
- **Shebna Rose D. Fabilloren** - Technical Consultant - [Email](mailto:[email protected])
- **Carlo M. Lapid** - Project Adviser - [Email](mailto:[email protected])

## Versioning
This project complies with [SemVer](https://semver.org) for versioning. For
all available versions, see
[tags](https://github.com/kvdomingo/primerdriver/tags).

## License
This project is licensed under the [GPLv3 License](./LICENSE).
42 changes: 42 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
version: '3'

tasks:
default:
cmds:
- docker compose up -d --build --remove-orphans

logs:
cmds:
- docker compose logs --follow

make-builder:
cmds:
- docker build -t kvdomingo/primerdriver-makelinux:latest -f Dockerfile.build .

publish-builder:
cmds:
- docker push kvdomingo/primerdriver-makelinux:latest

build-linux:
cmds:
- docker run -v "$(pwd)":/primerdriver --rm --name primerdriver-makelinux kvdomingo/primerdriver-makelinux:latest

build:
cmds:
- pyinstaller --clean -F --name primerdriver setup.py

shutdown:
cmds:
- docker compose stop

restart:
cmds:
- docker compose restart

restart-proxy:
cmds:
- docker compose restart proxy

clean:
cmds:
- docker compose down -v --remove-orphans
3 changes: 0 additions & 3 deletions build.sh

This file was deleted.

Loading

0 comments on commit cbd5922

Please sign in to comment.