Skip to content

Commit

Permalink
Merge pull request #329 from pbashyal-nmdp/docker-no-version
Browse files Browse the repository at this point in the history
pyard-service Docker changes
  • Loading branch information
mmaiers-nmdp authored Sep 11, 2024
2 parents 2c570be + 2c95a0d commit 3624cc8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
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

0 comments on commit 3624cc8

Please sign in to comment.