xxddpac
xxddpac

Reputation: 63

django uwsgi logto function not work in docker

dockerizing a django app with uwsgi

uwsgi.ini

[uwsgi]
chdir = /app
http = :12345
socket=127.0.0.1:8002
wsgi-file=leak/wsgi.py
static-map = /static=static
processes=4
threads=2
master=True
log-master = true
threaded-logger = true
logto=/var/log/leak.log
log-maxsize = 100000
threaded-logger = true
pidfile=uwsgi.pid
env = DJANGO_SETTINGS_MODULE=leak.settings.development

Dockerfile

FROM python:3.6.8-alpine
COPY requirements /app/requirements
WORKDIR /app
RUN apk update 
        && apk add make \
        && apk add --virtual mysqlclient-build gcc python3-dev musl-dev \
        && apk add --no-cache mariadb-dev \
        && apk add --virtual system-build linux-headers libffi-dev \
        && apk add --no-cache jpeg-dev zlib-dev freetype-dev lcms2-dev openjpeg-dev tiff-dev tk-dev tcl-dev \
        && apk add --no-cache bash bash-doc bash-completion libxml2-dev libxslt-dev \
        && pip install --upgrade pip setuptools wheel \
        && pip install -r requirements
COPY . /app 
CMD ["sh","run.sh"]

run.sh

#!/usr/bin/env sh
uwsgi --ini uwsgi.ini

after docker build && docker run the logpath "/var/log/leak.log" not create and without any errors. but its worked without docker. how can i fix it

Upvotes: 1

Views: 318

Answers (1)

Matzy
Matzy

Reputation: 363

a few suggestions:

  • do not run uwsgi as root
  • threaded-logger = true is defined 2 times
  • log under /app/log, and mount it as a volume, with the proper permissions for the user
  • alpine images can run #!/bin/sh

regards, matzy

Upvotes: 1

Related Questions