Skip to content

Commit

Permalink
move from uwsgi to gunicorn in docker. fix pulling dynamic web tar
Browse files Browse the repository at this point in the history
  • Loading branch information
sadnub committed Oct 27, 2023
1 parent 12d4206 commit 01c4a85
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 15 deletions.
9 changes: 4 additions & 5 deletions docker/containers/tactical-frontend/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ function check_tactical_ready {
rm -rf ${PUBLIC_DIR}/env-config.js
touch ${PUBLIC_DIR}/env-config.js

# Add runtime base url assignment
echo "window._env_ = {PROD_URL: \"https://${API_HOST}\"}" >> ${PUBLIC_DIR}/env-config.js

nginx_config="$(cat << EOF
server {
listen 8080;
Expand Down Expand Up @@ -55,8 +52,10 @@ if [ -f "$URL_PATH" ]; then

rm -f /tmp/${webtar}
rm -rf /tmp/dist

chown -R nginx:nginx /etc/nginx && chown -R nginx:nginx ${PUBLIC_DIR}
echo "Success!"
fi
fi

# Add runtime base url assignment
echo "window._env_ = {PROD_URL: \"https://${API_HOST}\"}" > ${PUBLIC_DIR}/env-config.js
chown -R nginx:nginx /etc/nginx && chown -R nginx:nginx ${PUBLIC_DIR}
9 changes: 6 additions & 3 deletions docker/containers/tactical-nginx/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,13 @@ STATIC_ASSETS="
else
API_NGINX="
#Using variable to disable start checks
set \$api ${BACKEND_SERVICE}:${API_PORT};
set \$api http://${BACKEND_SERVICE}:${API_PORT};
include uwsgi_params;
uwsgi_pass \$api;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto \$scheme;
proxy_set_header Host \$http_host;
proxy_redirect off;
proxy_pass \$api;
"

STATIC_ASSETS="
Expand Down
8 changes: 4 additions & 4 deletions docker/containers/tactical/dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ COPY api/tacticalrmm/requirements.txt ${TACTICAL_TMP_DIR}/api/requirements.txt
RUN apt-get update && \
apt-get install -y --no-install-recommends gcc libc6-dev && \
pip install --upgrade pip && \
pip install --no-cache-dir setuptools wheel && \
pip install --no-cache-dir -r ${TACTICAL_TMP_DIR}/api/requirements.txt
pip install --no-cache-dir setuptools wheel gunicorn && \
pip install --no-cache-dir -r ${TACTICAL_TMP_DIR}/api/requirements.txt && \

# pulls community scripts from git repo
FROM python:3.11.6-slim AS GET_SCRIPTS_STAGE
# pulls community scripts from git repo
FROM python:3.11.6-slim AS GET_SCRIPTS_STAGE

RUN apt-get update && \
apt-get install -y --no-install-recommends git && \
Expand Down
26 changes: 23 additions & 3 deletions docker/containers/tactical/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,28 @@ EOF

echo "${localvars}" >${TACTICAL_DIR}/api/tacticalrmm/local_settings.py

gunicornconfig="$(cat << EOF
import multiprocessing
workers = multiprocessing.cpu_count() * 2 + 1
bind = "0.0.0.0:8080"
wsgi_app = "tacticalrmm.wsgi"
raw_env = ["DJANGO_SETTINGS_MODULE=tacticalrmm.settings"]
backlog = 2048
worker_connections = 1000
timeout = 300
graceful_timeout = 300
limit_request_line = 0
limit_request_fields = 500
limit_request_field_size = 0
max_requests = 50
max_requests_jitter = 8
loglevel = "info"
EOF
)"
echo "${gunicornconfig}" > ${TACTICAL_DIR}/api/gunicorn.conf.py

# run migrations and init scripts
python manage.py pre_update_tasks
python manage.py migrate --no-input
Expand All @@ -127,7 +149,6 @@ EOF
python manage.py load_community_scripts
python manage.py reload_nats
python manage.py create_natsapi_conf
python manage.py create_gunicorn_conf
python manage.py create_installer_user
python manage.py clear_redis_celery_locks
python manage.py post_update_tasks
Expand All @@ -149,8 +170,7 @@ fi
# backend container
if [ "$1" = 'tactical-backend' ]; then
check_tactical_ready

gunicorn -c ${TACTICAL_DIR}/api/gunicorn_config.py tacticalrmm.wsgi:application
gunicorn
fi

if [ "$1" = 'tactical-celery' ]; then
Expand Down

0 comments on commit 01c4a85

Please sign in to comment.