Repository: cookiecutter/cookiecutter-django

Issue:
compilemessages not working in production using docker
## What happened?

Running `docker-compose -f production.yml run --rm django python manage.py compilemessages` does not produce any `.mo` file, whereas running `docker-compose -f local.yml run --rm django python manage.py compilemessages` does.

## What should've happened instead?

Running `docker-compose -f production.yml run --rm django python manage.py compilemessages` should produce `.mo` files at `locale/<locale>/LC_MESSAGES`.

## Additional details

Logs show no error, i.e. `processing file django.po in /app/locale/fr/LC_MESSAGES`.

I suppose that the issue comes from the fact that the `local.yml` compose setup [defines a volume for the django app](https://github.com/cookiecutter/cookiecutter-django/blob/master/%7B%7Bcookiecutter.project_slug%7D%7D/local.yml#L22-L23) whereas [the `production.yml` does not](https://github.com/cookiecutter/cookiecutter-django/blob/master/%7B%7Bcookiecutter.project_slug%7D%7D/production.yml#L9-L33).

* Host system configuration:
    * Version of cookiecutter CLI (get it with `cookiecutter --version`):
    * OS name and version: Ubuntu 22.04.2 LTS
    * Python version, run `python3 -V`: 3.10.10
    * Docker version (if using Docker), run `docker --version`: 23.0.1, build a5ee5b1
    * docker-compose version (if using Docker), run `docker-compose --version`: 2.16.0


Discussion:
> Running `docker-compose -f production.yml run --rm django python manage.py compilemessages` does not produce any `.mo` file, whereas running `docker-compose -f production.yml run --rm django python manage.py compilemessages` does.

I'm having a hard time spotting the difference between the 2 commands, did you mean to use `local.yml` in the 2nd one?

> I suppose that the issue comes from the fact that the `local.yml` compose setup [defines a volume for the django app](https://github.com/cookiecutter/cookiecutter-django/blob/master/%7B%7Bcookiecutter.project_slug%7D%7D/local.yml?rgh-link-date=2023-03-03T14%3A29%3A47Z#L22-L23) whereas [the `production.yml` does not](https://github.com/cookiecutter/cookiecutter-django/blob/master/%7B%7Bcookiecutter.project_slug%7D%7D/production.yml?rgh-link-date=2023-03-03T14%3A29%3A47Z#L9-L33).

That is correct, why do you need to compile messages on production?
I am sorry,  indeed I mean to use `local.yml`in the second command (I have amended the issue accordingly).

Maybe I am missing something about how django translations work, but I have some static pages that are manually translated using version-controlled .po files and which are not properly translated in the served website if the .mo files are not present. Am I not supposed to use compilemessages for that? what am I missing?

Thanks in advance! 
Right, the `.mo` files are ignored by git:

https://github.com/cookiecutter/cookiecutter-django/blob/6e7355a8c9a44926bc8456f722c9ed542ef8a7da/%7B%7Bcookiecutter.project_slug%7D%7D/.gitignore#L49-L51

I actually don't know how one is supposed to handle this. The way I usually do it is generate them locally, commit these files in source control and call it a day, but maybe there is a better way to do that. I found [this stackoverflow question](https://stackoverflow.com/questions/974645), where the "right" answer is no but the practical answer is more around the lines of maybe 😃 

To summarize:

- These files should not in git as they are generated
- We need to generate them before the application is started

That leaves 2 options (I think) to generate them:
1. when the Docker image is built
2. when the container starts

I feel like option 1 is better, as option 2 would mean we do the work multiple time (each time the container starts) and slow down start up time.

Resolving patch:
diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py
--- a/hooks/post_gen_project.py
+++ b/hooks/post_gen_project.py
@@ -96,10 +96,6 @@ def remove_heroku_files():
             # don't remove the file if we are using travisci but not using heroku
             continue
         os.remove(file_name)
-    remove_heroku_build_hooks()
-
-
-def remove_heroku_build_hooks():
     shutil.rmtree("bin")
 
 
@@ -444,8 +440,6 @@ def main():
 
     if "{{ cookiecutter.use_heroku }}".lower() == "n":
         remove_heroku_files()
-    elif "{{ cookiecutter.frontend_pipeline }}" != "Django Compressor":
-        remove_heroku_build_hooks()
 
     if "{{ cookiecutter.use_docker }}".lower() == "n" and "{{ cookiecutter.use_heroku }}".lower() == "n":
         if "{{ cookiecutter.keep_local_envs_in_vcs }}".lower() == "y":


Test patch: