0
votes

I am at a loss for what the problem is when deploying my app to Google Cloud. Here I run the Docker container on my own system:

$ docker run 829c6a550061
[2020-09-01 15:08:37 +0000] [6] [INFO] Starting gunicorn 20.0.4
[2020-09-01 15:08:37 +0000] [6] [INFO] Listening at: http://0.0.0.0:8080 (6)
[2020-09-01 15:08:37 +0000] [6] [INFO] Using worker: threads
[2020-09-01 15:08:37 +0000] [8] [INFO] Booting worker with pid: 8

when I click on the 'http://0.0.0.0:8080' it successfully launches the site. When I deploy to Cloud Run it gives a URL at the end and says "serving 100% traffic at such and such URL" but when I click on the URL it is a 404 error. Cloud Run says that by default the app listens on 8080. Am I missing something? Below is my Dockerfile and I attached a screenshot of Cloud Run's logs.

FROM node:13.12.0-alpine as react-build
WORKDIR /ChessKingsCouncil/react_frontend
RUN mkdir public src
COPY ./react_frontend/public ./public
COPY ./react_frontend/src ./src
COPY ./react_frontend/package.json ./
COPY ./react_frontend/package-lock.json ./
RUN npm install
RUN npm run-script build


FROM python:3.8.2
WORKDIR /ChessKingsCouncil/python_backend
ENV PYTHONPATH "${PYTHONPATH}:/app"
RUN pip install Flask
RUN pip install firebase-admin
RUN pip install gunicorn
RUN pip install termcolor
COPY ./python_backend ./
RUN mkdir build
COPY --from=react-build /ChessKingsCouncil/react_frontend/build ./build
ENV PORT 8080
CMD gunicorn --bind :$PORT --workers 1 --threads 8 app:app

Cloud Run deploy logs here

1
Can you try the steps listed at cloud.google.com/run/docs/testing/… to run locally instead? Does it still work when you do that?Dustin Ingram
@DustinIngram I will try that. Thank yousymLogicDMUS
Can you check on your computer that all your local test of the app are stopped? Indeed, with your command "docker run 829c6a550061" you start the container but you don't forward the port. Add the paramater -p 8080:8080 for this. I'm pretty sure that the 0.0.0.0:8080 isn't served by the container, but by another local execution!guillaume blaquiere
@guillaume blaquiere I don't why I didn't see anything about forwarding the port before. I will try this and get back to yousymLogicDMUS
ok so when I run '$ PORT=8080 && docker run -p 9090:${PORT} -e PORT=${PORT} gcr.io/chess-king-council/council-kings' and the go to localhost:9090 like it says to do, it is a 404 not found, same as following the link when I deploy.symLogicDMUS

1 Answers

0
votes

It seems you run ‘$ docker run 829c6a550061’ it is a pure docker command. However you deploy to Cloud Run which may observe different behavior. Before you deploy to the Cloud Run, I recommend you to test the container image locally. Also, it seems the Web server has not been installed. Nginx should be installed as a web server to respond to HTTP requests. You can follow this documentation for the Nginx configuration.

please note that by default the container listens to 0.0.0.0:8080, however, the documentation testing command access port is 9090, container port configuration is required before run the local testing command.