我有一个Django作为后端,而React作为前端项目运行在Docker容器中。
目前,我拥有所有Django,并且在同一存储库中对代码全部做出反应。并且项目在http://localhost:8000/frontend进行测试时按预期工作,它将按模板(在index.html
下的/frontend/templates/frontend
下依次引用/frontend/static/dist/main.js
)
目前,该项目可与Docker一起使用。
项目的结构如下:
project_root
|
|---frontend (this is a Django app which contains the react files)
| |--- static
| | |--- dist
| | |--- main.js
| |
| |--- templates
| |--- frontend
| |--- index.html (this references the static/dist/main.js)
|
|
|---... more Django apps
|
|--- compose
|
|---local
|
|---- django
|---- Dockerfile
|---- start
当前,我在/compose/local/django
下的Dockerfile如下所示:
FROM python:3.6-alpine
ENV PYTHONUNBUFFERED 1
RUN apk update \
# psycopg2 dependencies
&& apk add --virtual build-deps gcc python3-dev musl-dev \
&& apk add postgresql-dev \
# Pillow dependencies
&& apk add jpeg-dev zlib-dev freetype-dev lcms2-dev openjpeg-dev tiff-dev tk-dev tcl-dev \
# CFFI dependencies
&& apk add libffi-dev py-cffi \
# Translations dependencies
&& apk add gettext \
# https://docs.djangoproject.com/en/dev/ref/django-admin/#dbshell
&& apk add postgresql-client \
# git
&& apk add --no-cache git
# Requirements are installed here to ensure they will be cached.
COPY ./requirements /requirements
RUN pip install -r /requirements/project.local.txt
COPY ./compose/production/django/entrypoint /entrypoint
RUN sed -i 's/\r//' /entrypoint
RUN chmod +x /entrypoint
COPY ./compose/local/django/start /start
RUN sed -i 's/\r//' /start
RUN chmod +x /start
WORKDIR /app
ENTRYPOINT ["/entrypoint"]
我想将我的react代码和Django代码作为单独的存储库。因为对前端React代码和后端Django代码进行单独的CI / CD和单元测试会更容易。
/frontend/static/dist
指向具有相同文件夹名称的React项目我从浏览器中收到的投诉是/frontend/static/dist/main.js
丢失。
当我检查符号链接时,main.js肯定在那里。因此,我认为在构建Docker容器时,文件没有被复制过来吗?
我该如何解决?