Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
197 views
in Technique[技术] by (71.8m points)

python - Django / uwsgi / Docker Configuration

I have a working implementation of a Nginx, Uwsgi, and Django application running on a local server. I am trying to recreate the application minus the Nginx portion inside of a docker container, so that I can easily port it to a system like AWS. I am getting the following error message with the following configuration files.

unable to load configuration from www-data

I believe that this is due to a permissions error, as when I remove the --gid www-data flag, the process starts, but running in root mode, which curses the process. I have tried the following commands to no avail, with repo being the project folder.

chown -R myuser:www-data Repo/
chmod -R 744 Repo/

Dockerfile

FROM python:3.8
FROM node:12

RUN apt-get update && 
    apt-get upgrade -y && 
    apt-get clean -y && 
    apt-get install -y --no-install-recommends apt-utils tar git build-essential python3 python3-pip python3-setuptools python3-dev net-tools

RUN mkdir /var/log/uwsgi /shared

COPY . /app
WORKDIR /app

RUN pip3 install --upgrade pip virtualenv
RUN virtualenv venv
RUN /bin/bash -c "source venv/bin/activate"
RUN pip3 install --no-cache-dir -r requirements.txt

RUN npm install --prefix frontend
RUN npm run build --prefix frontend

RUN ln -sf /dev/stdout /var/log/uwsgi/djangoapp.log && ln -sf /dev/stdout /var/log/uwsgi/emperor.log

VOLUME /shared

EXPOSE 29000

CMD uwsgi --emperor --gid www-data --logto /var/log/uwsgi/emperor.log uwsgi.ini

uwsgi.ini

[uwsgi]

chdir = /app
home = /app/venv/

wsgi-file = /app/main_control/wsgi.py

master = True
processes = 2
threads = 1
enable-threads = true

max-requests = 1000
max-worker-lifetime = 3600
reload-on-rss = 2048
worker-reload-mercy = 60

single-interpreter = true
die-on-term = true
need-app = true

socket_dir = /shared
socket = /shared/app.sock
chmod-socket = 666
vacuum = True

pidfile = /var/run/%n.pid
logto = /var/log/uwsgi/%n.log

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...