Skip to content

Fix media folder ownership in production Dockerfile - #7003

Merged
browniebroke merged 1 commit into
cookiecutter:mainfrom
charan-rathore:fix/6999-media-dir-ownership
Nov 3, 2026
Merged

browniebroke merged 1 commit into
cookiecutter:mainfrom
charan-rathore:fix/6999-media-dir-ownership

Conversation

@charan-rathore

Copy link
Copy Markdown
Contributor

Description

When cloud_provider is None, the production django Dockerfile creates the media folder with RUN mkdir -p, which runs as root. The chown django:django ${APP_HOME} below it is not recursive (on purpose, to keep the build fast), so it never reaches the new directory and uploads fail with Permission denied.

This chowns only the newly created media directory and leaves the non-recursive chown of the WORKDIR as it is.

Checklist:

  • I've made sure that tests are updated accordingly (especially if adding or updating a template option)
  • I've updated the documentation or confirm that my change doesn't require any updates

Rationale

Fix #6999

The new test bakes the project with use_docker=y and checks the generated Dockerfile: with cloud_provider=None the media dir must be created and chowned to django, with AWS it must not appear. It fails on current master and passes with this change. I did not build the image or run the container; the check is on the rendered Dockerfile.

When cloud_provider is None the media folder is created with RUN mkdir, which runs as root. The non-recursive chown of APP_HOME below does not touch it, so django cannot write uploads. Chown the new directory only and keep the non-recursive chown of the WORKDIR.

Fix cookiecutter#6999

Signed-off-by: Charan Rathore <[email protected]>
@browniebroke
browniebroke merged commit b1563df into cookiecutter:main Nov 3, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Permission denied for media folder

2 participants