社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  Django

TemplateDoesNotExist位于/index。Docker中的html |与django反应

Sreebash Chandra Das • 4 年前 • 336 次点击  

为什么我的react build文件夹在运行后无法使用 python manage.py collectstatic 指挥 Dockerfile ? 我已经尝试了很长一段时间,以停靠我的整个项目,但我没有收集静态文件。我想念的地方请看一下。

***这是我的 backend/Dockerfile 在…内 django 计划***

FROM python:3.9.5-slim

ENV PYTHONUNBUFFERED 1

RUN pip install --upgrade pip

RUN apt-get update && apt-get install build-essential python-dev -y

COPY requirements.txt requirements.txt

RUN pip3 install -r requirements.txt && pip3 install uwsgi

WORKDIR /django

COPY . .

CMD ['RUN', 'python', 'manage.py', 'collectstatic', '--noinput']


EXPOSE 8000


CMD ["uwsgi", "--http", ":9090", "--wsgi-file", "IMS/wsgi.py", "--master", "--processes", "4", "--threads", "2"]

这是我的 frontend/Dockerfile 在我的文件夹里

FROM node:13.12.0-alpine
WORKDIR /react

COPY . .

RUN npm install

RUN npm run build

EXPOSE 3000

最后,这是我的docker compose。我在其中设置3个服务的yml文件

version: "3.3"
services:
  backend:
    build:
      context: ./backend/
    command: gunicorn IMS.wsgi --bind 0.0.0.0:8000
    container_name: ims-backend
    restart: always
    ports:
      - "8000:8000"
    networks:
      - ims-network


  ims-postgres:
    image: "postgres:14beta2-alpine3.14"
    restart: always
    container_name: ims-postgres
    hostname: emrdsaws.czlz2b677ytu.ap-south-1.rds.amazonaws.com
    environment:
      - POSTGRES_PASSWORD=zkf!%uW_?&UG%4
      - POSTGRES_DB=imsrds
      - POSTGRES_USER=dbrdsubuntume12
    ports:
      - 5432



  frontend:
    build:
      context: ./frontend/
    volumes:
      - react_build:/react/build
    expose:
      - 3000
    stdin_open: true

  nginx:
    image: nginx:latest

    ports:
      - "8080:8080"
    volumes:
      - ./nginx/nginx-setup.conf:/etc/nginx/conf.d/default.conf:ro
      - react_build:/var/www/react
    depends_on:
      - backend
      - frontend
      - ims-postgres

volumes:
  react_build:

networks:
  ims-network:
    driver: bridge
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/132367