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

pyard-service Docker changes #329

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,9 @@ RUN pip install --no-cache-dir -r requirements-deploy.txt

RUN pip install --no-cache-dir py-ard==$PY_ARD_VERSION

RUN pyard-import && \
pyard --version && \
pyard-status

COPY app.py /app/
COPY api.py /app/
COPY api-spec.yaml /app/

CMD ["gunicorn", "--bind", "0.0.0.0:8080", "--worker-tmp-dir", "/dev/shm", "--timeout", "30", "app:app"]
COPY docker-entrypoint-flask.sh /usr/local/bin/
CMD ["/usr/local/bin/docker-entrypoint-flask.sh"]
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
PROJECT_NAME := $(shell basename `pwd`)
PACKAGE_NAME := pyard
PYARD_VERSION := 1.2.1

.PHONY: clean clean-test clean-pyc clean-build docs help
.DEFAULT_GOAL := help
Expand Down Expand Up @@ -98,10 +99,11 @@ dist: clean ## builds source and wheel package
ls -l dist

docker-build: ## build a docker image for the service
docker build --platform=linux/amd64 -t nmdpbioinformatics/pyard-service:latest .
docker build --platform=linux/amd64 -t nmdpbioinformatics/pyard-service:$(PYARD_VERSION).linux-amd64 .
docker tag nmdpbioinformatics/pyard-service:$(PYARD_VERSION) nmdpbioinformatics/pyard-service:latest

docker: docker-build ## build a docker image and run the service
docker run --platform=linux/amd64 --rm --name pyard-service -p 8080:8080 nmdpbioinformatics/pyard-service:latest
docker run --platform=linux/amd64 --rm --name pyard-service -p 8080:8080 nmdpbioinformatics/pyard-service:$(PYARD_VERSION).linux-amd64

install: clean ## install the package to the active Python's site-packages
pip install --upgrade pip
Expand Down
16 changes: 16 additions & 0 deletions docker-entrypoint-flask.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh
set -e

# A positive integer generally in the 2-4 x $(NUM_CORES) range.
WORKER_PROCESSES=${WORKERS:-4}

echo "Starting py-ard service with" "${WORKER_PROCESSES}" worker processes.

if [ "${WORKER_PROCESSES}" != "1" ]; then
WORKER_FLAG="--workers=${WORKER_PROCESSES}"
fi

# Import the latest pyard before starting the app
pyard-import

gunicorn --preload --bind 0.0.0.0:8080 --timeout 5000 --log-level info "${WORKER_FLAG}" app:app
Loading