When starting a new project, this command runs relatively fast. As the project grows, the quantity of files inevitably grows, increasing the execution time.
The recursive flag -R should be removed and the same result would be achieved:
RUN chown django:django ${APP_HOME}
Rationale
I currently maintain a mature project that was started with an earlier version of this cookiecutter. I often update the project with the patterns found in the upstream, to keep up with the current standards. Now, recursively changing the owner of the WORKDIR directory takes 2 minutes to complete.
On the preceding lines, both commands use the --chown=django:django argument to copy all files and directories with the django user as the owner:
In both cases, the /app directory itself is owned by root while its subdirectories and subfiles are all owned by the django user. Removing the recursive flag -R to only change the owner of /app will drastically reduce the execution time and achieve the same result as before.
Description
The production Dockerfile uses a
chown
command to recursively change the owner of theWORKDIR
directory:https://github.com/cookiecutter/cookiecutter-django/blob/ed59d08ec31b05b672c05f2c8e24e263aa9c7402/%7B%7Bcookiecutter.project_slug%7D%7D/compose/production/django/Dockerfile#L120
When starting a new project, this command runs relatively fast. As the project grows, the quantity of files inevitably grows, increasing the execution time.
The recursive flag
-R
should be removed and the same result would be achieved:RUN chown django:django ${APP_HOME}
Rationale
I currently maintain a mature project that was started with an earlier version of this cookiecutter. I often update the project with the patterns found in the upstream, to keep up with the current standards. Now, recursively changing the owner of the
WORKDIR
directory takes 2 minutes to complete.On the preceding lines, both commands use the
--chown=django:django
argument to copy all files and directories with thedjango
user as the owner:https://github.com/cookiecutter/cookiecutter-django/blob/ed59d08ec31b05b672c05f2c8e24e263aa9c7402/%7B%7Bcookiecutter.project_slug%7D%7D/compose/production/django/Dockerfile#L113-L117
In both cases, the
/app
directory itself is owned byroot
while its subdirectories and subfiles are all owned by thedjango
user. Removing the recursive flag-R
to only change the owner of/app
will drastically reduce the execution time and achieve the same result as before.