GordonFleming / SAGTAwebsite

Website for SAGTA using Wagtail CMS

Home Page:https://sagta.org.za

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

List of issues I found with the containers

lucernae opened this issue · comments

There are several issues with the containers itself:

The image used is not a clean build

When I go inside the container in rancher, the /code directory has a .git index folder. While it is okay to include the git directory, it is not advised to do that if it is conflicted with the repo state in the image. Choose one of the alternative path:

  1. Exclude .git from docker image by adding it in .dockerignore
  2. Include .git into the docker image, but do not include unclean git state in the image

This is what happens if you choose approach 2, but failed to make the git repo clean:

image

Person who are doing the deployment will be confused about the state and wonder if the files are correct and up to date.

Media folder is conflicted with media folder in the git repo

In general, you should not include media folder in git repo due to it's size. However depending on circumstances, it's also possible to include it because you need it. Choose one of the alternative path to fix it:

  1. Exclude media folder from your git repo (by adding it into .gitignore) and add it to .dockerignore

In general you want the media folder decoupled from your code. You don't want to manage it inside git (unless your CMS is serverless git based). When you exclude it in git and docker build, remember to delete it from the git index too (via git rm) so git will no longer remember those files. This needs to be taken into account because in the server side deployment, there will be confusion on which media files is the correct one, because it will conflicts, like in the above image. It's not clear who is deleting those images.

  1. It is sometimes makes sense to put your media folders in git repo. But this means user upload must go straight into the git repo instead of media volume in docker/container

Serverless git based CMS (commonly called headless CMS) like netlify use this approach. If you allow user to upload into your site, this is probably not the correct approach.

Python package identifier init.py are ignored

Your .gitignore contains __* which is ignoring many new __init__.py file so it doesn't get included in the git repo. Your migrations package in contact/migrations doesn't include __init__.py so python will not read the content and will assume no migrations exists, causing the error in the admin page when you want to add new page.

If you need to ignore __pycache__, do so by adding __pycache__ into your gitignore, because __init__.py is an absolute necessity and there's no reason to have it ignored.

Do not forget to add all those missing __init__.py in your package. Every python package should have it (and also in it subdir if it contains python code).

Migrations folders are not detected.

Migrations folders are not detected due to missing __init__.py file. To fix this, you need to carefully do these steps one by one to make sure migrations are note regenerated from scratch (and losing it's history).

  1. Add __init__.py in your migrations folder and python package of the parent (so python will traverse the package) until the root of the package.
  2. Check that the migrationfolders are detected by using ./manage.py showmigrations <app name>
  3. Create new migration files ./manage.py makemigrations <app name>
  4. Perform migrations ./manage.py migrate <app name>
  5. Commit the migrations file git add <location of migration folder> ; git commit -m 'Add migrations folder'

For example the full command if your app name is contact (from the contact app)

./manage.py showmigrations contact
./manage.py makemigrations contact
./manage.py migrate contact

File organization are not quite right

If I understand it correctly, there are several django app in the root project repo: contact, flex, home.
While this is perfectly fine, however due to the logical dependency (contact app is part of mysite), you should put it inside mysite because that is your project app. Then in INSTALLED_APPS refer to the contact app as mysite.contact .

This is just a suggestion and not an error. I am suggesting this because you put the templates inside mysite and all these app contact, flex, home will not work without mysite.