From 30f9ea872e55b0e4d48db2ad7f342475731341f6 Mon Sep 17 00:00:00 2001 From: Drew Bednar Date: Sun, 28 Nov 2021 19:31:16 -0500 Subject: [PATCH] Additional gunicorn exec improvements --- Makefile | 4 ++-- api/.dockerignore | 3 ++- api/Dockerfile | 3 +-- api/bin/demo-helm-api | 18 ++++++++++++++++++ charts/demo-helm/values.yaml | 4 ++-- 5 files changed, 25 insertions(+), 7 deletions(-) create mode 100755 api/bin/demo-helm-api diff --git a/Makefile b/Makefile index 82b0085..060d240 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ REGISTRY_NAME=registry.runcible.io FRONTEND_IMAGE_NAME=$(REGISTRY_NAME)/demo-helm-frontend -FRONTEND_IMAGE_VERSION=1.3.0 +FRONTEND_IMAGE_VERSION=1.4.0-dev API_IMAGE_NAME=$(REGISTRY_NAME)/demo-helm-api -API_IMAGE_VERSION=1.3.0 +API_IMAGE_VERSION=1.4.0-dev push-app-image: build-app-image docker push $(FRONTEND_IMAGE_NAME):$(FRONTEND_IMAGE_VERSION) diff --git a/api/.dockerignore b/api/.dockerignore index 9e050ed..c70d962 100644 --- a/api/.dockerignore +++ b/api/.dockerignore @@ -2,4 +2,5 @@ requirements.in .env tests/ Dockerfile -./api/.env \ No newline at end of file +./api/.env +.git \ No newline at end of file diff --git a/api/Dockerfile b/api/Dockerfile index 774652c..9c298fc 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -28,5 +28,4 @@ USER app ENTRYPOINT ["./entrypoint.sh"] -CMD ["gunicorn", "--worker-tmp-dir", "/dev/shm", "--workers=2", "--log-level=-", "--threads=4", \ - "--worker-class", "gthread", "--bind", "0.0.0.0:5000", "wsgi:app"] +CMD ["./bin/demo-helm-api"] diff --git a/api/bin/demo-helm-api b/api/bin/demo-helm-api new file mode 100755 index 0000000..70887e8 --- /dev/null +++ b/api/bin/demo-helm-api @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +# TODO add logic to always run from root api application directory + +API_LOG_LEVEL="${API_LOG_LEVEL:-info}" +API_WORKER_CLASS="${API_WORKER_CLASS:-gthread}" +API_WORKER_COUNT="${API_WORKER_COUNT:-2}" +API_THREAD_COUNT="${API_THREAD_COUNT:-4}" + +if [ -f /.dockerenv ]; then + WORKER_TEMP_DIR="/dev/shm" +else + WORKER_TEMP_DIR="/tmp" +fi + +exec python3 -m gunicorn.app.wsgiapp --worker-tmp-dir "$WORKER_TEMP_DIR" --workers "$API_WORKER_COUNT" --access-logfile "-" \ + --log-level "$API_LOG_LEVEL" --error-logfile "-" --threads "$API_THREAD_COUNT" \ + --worker-class "$API_WORKER_CLASS" --bind 0.0.0.0:5000 wsgi:app \ No newline at end of file diff --git a/charts/demo-helm/values.yaml b/charts/demo-helm/values.yaml index 05ca1f4..5782995 100644 --- a/charts/demo-helm/values.yaml +++ b/charts/demo-helm/values.yaml @@ -3,10 +3,10 @@ image_pull_secret: regcred services: frontend: image_name: "registry.runcible.io/demo-helm-frontend" - image_version: "1.3.0" + image_version: "1.4.0" replicas: 1 backend: image_name: "registry.runcible.io/demo-helm-api" - image_version: "1.3.0" + image_version: "1.4.0" replicas: 1 random: "tis-random-default" \ No newline at end of file