Dockerfile for azure-search-openai-demo App

56 views Asked by At

I am trying to Dockerise an app which uses the Quart package.

Dockerfile:

FROM python:3.11 AS backend-build

COPY backend /app/backend

WORKDIR /app/backend

RUN pip install -r requirements.txt

EXPOSE 5000

CMD ["python", "-m", "quart", "--app", "main:app", "run", "--port", "5000", "--host", "localhost", "--reload"]

Docker image gets built but when I start it and try to access the web at http://localhost:5000/ I see HTTP ERROR 403.

1

There are 1 answers

0
datawookie On BEST ANSWER
  • You need to change localhost to 0.0.0.0 in CMD. See this post for why.
  • Run the container with -p 5000:5000.
├── backend
│   ├── main.py
│   └── requirements.txt
└── Dockerfile

main.py

from quart import Quart, render_template, websocket

app = Quart(__name__)

@app.route("/")
async def hello():
    return "Hello, World!"

if __name__ == "__main__":
    app.run()

requirements.txt

Quart==0.19.4

Dockerfile

FROM python:3.11 AS backend-build

COPY backend /app/backend

WORKDIR /app/backend

RUN pip install -r requirements.txt

EXPOSE 5000

CMD ["python", "-m", "quart", "--app", "main:app", "run", "--host", "0.0.0.0", "--reload"]

Screenshot below shows container running and demo page being accessed on http://localhost:5000.

enter image description here