Skip to content
This repository has been archived by the owner on Mar 27, 2023. It is now read-only.

Easier deployment #21

Merged
merged 49 commits into from
Jul 8, 2020
Merged

Easier deployment #21

merged 49 commits into from
Jul 8, 2020

Conversation

Baschdl
Copy link
Contributor

@Baschdl Baschdl commented Jun 15, 2020

Problems:

  • compilemessages changes .mo file and triggers invalidation of docker cache despite of no source code changes

EDIT by malte:

  • Fix DB startup race condition causing error FATAL: the database system is starting up
  • Address Bastis remarks about gosu
  • Add sample gateway error pages & nginx configuration (copy from m4h PR 538)
  • Make docker container bind to localhost (see m4h PR 540)
  • Fix backup script (implement match4everyone/match4healthcare@f0737b2)

Closes #57

backend/Dockerfile Outdated Show resolved Hide resolved
@maltezacharias maltezacharias self-assigned this Jun 15, 2020
@Baschdl

This comment has been minimized.

Copy link
Contributor

@maltezacharias maltezacharias left a comment

Choose a reason for hiding this comment

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

Looks good, I'll test tomorrow and approve after

@maltezacharias

This comment has been minimized.

@maltezacharias

This comment has been minimized.

@Baschdl
Copy link
Contributor Author

Baschdl commented Jun 20, 2020

Is it possible for us to hook into that command and just remove the damn ChangedAt line?

compilemessages or better GNU gettext doesn't provide a way, it's discussed a lot online but I couldn't find a solution

@Baschdl

This comment has been minimized.

@bjrne

This comment has been minimized.

@bjrne

This comment has been minimized.

@Baschdl

This comment has been minimized.

@maltezacharias
Copy link
Contributor

Actually makemessages introduces the constant changes.
I have overridden the command to always set the same POT-Creation-Date. Now the file should only be detected as changed when there are actual changes to the content

@maltezacharias
Copy link
Contributor

Is it possible for us to hook into that command and just remove the damn ChangedAt line?

compilemessages or better GNU gettext doesn't provide a way, it's discussed a lot online but I couldn't find a solution

I made one. It's pretty easy actually, you can simply create a new command with the same name which will override the default one. I inherited my implementation from the original makemessages and modify the POT header. (POTs are only temporarily created but the POT-Created Header is copied to the final .po file.

This way we can avoid accidentally starting the container as root which
would lead to permission errors on next container
run as a non-root user
Fixed container name can lead to conflicts when trying to
run multiple instances of our app on the same system.

Removing the name definition allows for autogeneration by docker-compose.
Management can still be done using docker-compose .... exec <service>
using the service names from the compose YAML
This should probably extended later and use a separate directory for
logs (and backups as well)
This was necessary because the collection of statics depends on the
BACKEND configuration. We only have that in production config right
now. A (better?) alternative would be to add whitenoise in dev
configuration and collect statics during the build process.
Need to test if this will cause problems in dev as runserver
is used to serve the files and I need to check if that honors
the configured backend
This way the development docker container can also run as a non-root
user to be closer to the production setup
The previous version would detect the container as running too early. Need to check the logfile of the backend docker until gunicorn signals that it's ready and listening. Otherwise the website will not yet be up for the next script.
@maltezacharias
Copy link
Contributor

@kevihiiin please have a go and test it thoroughly. It works nicely here, but @Baschdl found some strange bugs the last time I thought that.

@maltezacharias
Copy link
Contributor

I consider this PR complete and ready for review+merge. Bastis points about gosu are valid and merit further consideration. I suggest tackling that in a new PR as this PR already got a lot more complicated than we thought.

I am convinced though that we have resolved some hard to track down possible problems here and will also backport to m4h

@maltezacharias
Copy link
Contributor

c458215 closes #57

backend/entrypoint.sh Show resolved Hide resolved
docker-compose.yml Outdated Show resolved Hide resolved
backend/run/.gitignore Outdated Show resolved Hide resolved
backend/Dockerfile Outdated Show resolved Hide resolved
backend/Dockerfile Outdated Show resolved Hide resolved
.env.example Show resolved Hide resolved
README.md Show resolved Hide resolved
backup.sh Outdated Show resolved Hide resolved
backup.sh Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
@Baschdl
Copy link
Contributor Author

Baschdl commented Jul 7, 2020

@maltezacharias can be merged after addressing the comments I also commented

@maltezacharias
Copy link
Contributor

Thx for the review

@Baschdl
Copy link
Contributor Author

Baschdl commented Jul 8, 2020

We have to also create a backend.dev.env for travis

Baschdl and others added 5 commits July 8, 2020 22:59
With whitenoise in both dev & prod configurations collectstatic will
work as expected and perform post processing when run from
either configuration.

Before it was easy to mistakenly run collectstatic
in the development context. Missing manifests and hard to understand
errors were caused by this setup. Now running collectstatic always
produces the expected results.

Running python manage.py runserver does not used the collected
static files, running in dev context does *not* require the use
of collectstatic.
@maltezacharias maltezacharias merged commit b8bf8d1 into staging Jul 8, 2020
@maltezacharias maltezacharias deleted the easier-deploy branch July 8, 2020 23:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

backend errors (again) when database is starting the first time
4 participants