我在 Django 上有后端,在 React 上有店面/仪表板。
Docker 容器中的 Django。
Dockerfile (Django)
### Build and install packages
FROM python:3.8 as build-python
RUN apt-get -y update \
&& apt-get install -y gettext \
# Cleanup apt cache
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Install Python dependencies
COPY requirements_dev.txt /app/
WORKDIR /app
RUN pip install -r requirements_dev.txt
### Final image
FROM python:3.8-slim
RUN groupadd -r saleor && useradd -r -g saleor saleor
RUN apt-get update \
&& apt-get install -y \
libxml2 \
libssl1.1 \
libcairo2 \
libpango-1.0-0 \
libpangocairo-1.0-0 \
libgdk-pixbuf2.0-0 \
shared-mime-info \
mime-support \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN mkdir -p /app/media /app/static \
&& chown -R saleor:saleor /app/
COPY --from=build-python /usr/local/lib/python3.8/site-packages/ /usr/local/lib/python3.8/site-packages/
COPY --from=build-python /usr/local/bin/ /usr/local/bin/
COPY . /app
WORKDIR /app
ARG STATIC_URL
ENV STATIC_URL ${STATIC_URL:-/static/}
RUN SECRET_KEY=dummy STATIC_URL=${STATIC_URL} python3 manage.py collectstatic --no-input
EXPOSE 8000
ENV PYTHONUNBUFFERED 1
CMD ["gunicorn", "--bind", ":8000", "--workers", "4", "--worker-class", "uvicorn.workers.UvicornWorker", "saleor.asgi:application"]
当我转到仪表板并访问带有图片的对象时,出现错误:
谢谢你帮助我!