Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Setup noroot users in examples#65

Merged
zanieb merged 2 commits intomainfrom
zb/no-root
Sep 24, 2025
Merged

Setup noroot users in examples#65
zanieb merged 2 commits intomainfrom
zb/no-root

Conversation

@zanieb
Copy link
Member

@zanieb zanieb commented Sep 23, 2025

Closes #32
Closes #39
Closes #29

Comment on lines -37 to +44
CMD ["fastapi", "dev", "--host", "0.0.0.0", "/app/src/uv_docker_example"]
CMD ["fastapi", "run", "--host", "0.0.0.0", "/app/src/uv_docker_example"]
Copy link
Member Author

@zanieb zanieb Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes errors reading /etc/ssl/private and /proc/tty/driver which seem specific to the dev command — I'm not really sure why this isn't a problem in the Dockerfile, presumably it's a difference of base image, but we use dev there since it's an example of a local development image.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's weird, is fastapi trying to generate dev certificates?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm I tried it with dev rather than run but I can't repro the issue

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you just do the build? The error is on run.

docker build -f multistage.Dockerfile . -t uv-multistage     
docker run --rm -it --publish 8000:8000 uv-multistage

Copy link
Contributor

@samypr100 samypr100 Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed (I had built and ran it), no errors 😅

Copy link
Contributor

@samypr100 samypr100 Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe try fastapi dev --no-reload?

I noticed Will watch for changes in these directories: ['/'] rather than /app.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't that sort of defeat the point of using dev? :D

I think I prefer run for these images anyway, since they're more production focused with the staged build.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only use dev in Dockerfile because it's linked to the compose example.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea I think thats it, workdir is missing in the multistage/standalone versions

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh that's interesting, thanks!

@zanieb zanieb merged commit 9ea88bf into main Sep 24, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

User and group app:app does not exist in multistage.Dockerfile

2 participants