pythondockerdockerfilequart

Dockerfile for azure-search-openai-demo App


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.


Solution

  • ├── 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