Skip to content
\n

Description

\n

I'm struggling to understand the sequence of commands in backend dockerfile

\n

the Dockerfile runs uvicorn main:app --reload when importing the Dockerfile from FROM tiangolo/uvicorn-gunicorn-fastapi:python3.10
\n
with command CMD [\"/start.sh\"] is there!

\n

however `COPY ./app /app/app takes place till the end here .

\n

How is unicorn being executed without the app? does this mean CMD at the end of tiangolo/uvicorn-gunicorn-fastapi:python3.10 is somehow delayed?

\n

I see that docker-compose.override.yml has
\ncommand: /start-reload.sh
\nwhich executes uvicorn

\n

however I can't understand how does docker-compose.yml work in production

\n

Operating System

\n

macOS

\n

Operating System Details

\n

docker

\n

Python Version

\n

3.9

\n

Additional Context

\n

No response

","upvoteCount":1,"answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"

In current implementation, there is a command defined in in .Dockerfile:

\n
CMD [\"fastapi\", \"run\", \"--workers\", \"4\", \"app/main.py\"]`\n
\n

And for development, this command is overridden in docker-compose.override.yml:

\n
  backend:\n    ...\n    command:\n      - fastapi\n      - run\n      - --reload\n      - \"app/main.py\"\n
\n

So, in production, the command defined in .Dockerfile is used

","upvoteCount":1,"url":"https://github.com/fastapi/full-stack-fastapi-template/discussions/1177#discussioncomment-14342340"}}}
Discussion options

You must be logged in to vote

In current implementation, there is a command defined in in .Dockerfile:

CMD ["fastapi", "run", "--workers", "4", "app/main.py"]`

And for development, this command is overridden in docker-compose.override.yml:

  backend:
    ...
    command:
      - fastapi
      - run
      - --reload
      - "app/main.py"

So, in production, the command defined in .Dockerfile is used

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by YuriiMotov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
2 participants