在GAE flex/custom for django API中应用自定义nginx.conf

在GAE flex/custom for django API中应用自定义nginx.conf,django,google-app-engine,nginx,dockerfile,Django,Google App Engine,Nginx,Dockerfile,我试图在nginx的自定义运行时上运行django,以便能够与nginx.conf文件交互。使用以下文件将SSH绑定到已部署的实例中表明,我为nginx创建的文件夹不是在appengine上创建的。为了定制nginx以在appengine上部署django,是否还有其他方法可以实现这一点?我能够成功地部署django API,但我希望我的租户的nginx路由从我的前端路由 dockerfile: FROM python:3.7 AS build-stage ENV PYTHONUNBUFFERE

我试图在nginx的自定义运行时上运行django,以便能够与nginx.conf文件交互。使用以下文件将SSH绑定到已部署的实例中表明,我为nginx创建的文件夹不是在appengine上创建的。为了定制nginx以在appengine上部署django,是否还有其他方法可以实现这一点?我能够成功地部署django API,但我希望我的租户的nginx路由从我的前端路由

dockerfile:

FROM python:3.7 AS build-stage
ENV PYTHONUNBUFFERED 1
ENV PORT 8080
ENV DATABASE_URL postgres://$CREDS
RUN mkdir /sd
WORKDIR /sd
ADD requirements.txt postgres_credential.json ./
RUN pip3 install -r requirements.txt
ADD . /sd/

FROM nginx:1.19.0-alpine

RUN rm /etc/nginx/conf.d/default.conf
COPY nginx-custom.conf /etc/nginx/conf.d

RUN mkdir -p /var/log/app_engine

# Create a simple file to handle heath checks. Health checking can be disabled
# in app.yaml, but is highly recommended. Google App Engine will send an HTTP
# request to /_ah/health and any 2xx or 404 response is considered healthy.
# Because 404 responses are considered healthy, this could actually be left
# out as nginx will return 404 if the file isn't found. However, it is better
# to be explicit.
RUN mkdir -p /usr/share/nginx/www/_ah && \
    echo "healthy" > /usr/share/nginx/www/_ah/health

# Finally, all static assets.
ADD template/ /usr/share/nginx/template/
RUN chmod -R a+r /usr/share/nginx/template

#CMD python3 ./manage.py runserver 0.0.0.0:$PORT
GAE实例上的bash命令

alex@aef-back /usr/share $ cd /var/nginx
-bash: cd: /var/nginx: No such file or directory
alex@aef-back /usr/share $ cd /etc/nginx
-bash: cd: /etc/nginx: No such file or directory
alex@aef-back /usr/share $ cd /var/log/app_engine/
alex@aef-back /var/log/app_engine $ pwd
/var/log/app_engine
alex@aef-back /var/log/app_engine $ ls
app  health_check  health_check.202012050634_0.log
alex@aef-back /var/log/app_engine $ cd /usr/share/nginx/www/_ah
-bash: cd: /usr/share/nginx/www/_ah: No such file or directory
alexmacdon94@aef-back-20201204t072728-9236 /var/log/app_engine $ 
nginx-custom.conf

server_name _;
        location / {
                proxy_pass http://127.0.0.1:8080/;
        }
云构建日志

Step #1: Step 11/16 : RUN rm /etc/nginx/conf.d/default.conf
Step #1:  ---> Running in c48758488e52
Step #1: Removing intermediate container c48758488e52
Step #1:  ---> d5b17f9f8874
Step #1: Step 12/16 : COPY nginx-custom.conf /etc/nginx/conf.d
Step #1:  ---> 22fbfb3ddfda
Step #1: Step 13/16 : RUN mkdir -p /var/log/app_engine
Step #1:  ---> Running in 695f94769a04
Step #1: Removing intermediate container 695f94769a04
Step #1:  ---> 9ed88f52cf17
Step #1: Step 14/16 : RUN mkdir -p /usr/share/nginx/www/_ah &&     echo "healthy" > /usr/share/nginx/www/_ah/health
Step #1:  ---> Running in 5b8e2448d194
Step #1: Removing intermediate container 5b8e2448d194
Step #1:  ---> 73a48dccb523
Step #1: Step 15/16 : ADD template/ /usr/share/nginx/template/
Step #1:  ---> 8be309b7b146
Step #1: Step 16/16 : RUN chmod -R a+r /usr/share/nginx/template
Step #1:  ---> Running in 2f4f07a124ee
Step #1: Removing intermediate container 2f4f07a124ee
Step #1:  ---> 364d25299630
Step #1: Successfully built 364d25299630
app.yaml

env: flex
runtime: custom
#entrypoint: python3 ./manage.py runserver 0.0.0.0:8080
#entrypoint: gunicorn -b :$8080 sd.wsgi.dev
service: back


handlers:
- url: /static
  static_dir: static
- url: .*
  script: sd.wsgi.dev
  #secure: always

只是猜测一下-也许您需要将所需的整个文件路径传递到
COPY
?与中一样,
COPY nginx-custom.conf/etc/nginx/conf.d/nginx custom.conf
谢谢,但问题仍然存在-该文件夹仍然不在那里我在这里尝试了解决方案:但是/usr/share/nginx文件夹没有被创建,
/etc/nginx
目录不存在,这很奇怪,我想是的,因为您使用的是nginx图像。也许你必须先去mkdir?你看过复印命令的文档了吗?它们可能很有用:我也会尝试创建目录,但是在dockerfile中的nginx之后删除2个run和copy命令确实会导致整个站点出现502错误,所以看起来这些命令正在做一些事情。