-
Notifications
You must be signed in to change notification settings - Fork 17
Move django migrations to dokku release phase #2736
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Removed the existing `prod.sh` file which ran migrations and executed the gunicorn command as part of the `ENTRYPOINT` docker command. This caused the migrations to run every time the container was run. - Created a shell script `release.sh` which currently just does the migrations, but could do anything we need during the dokku release phase - Added a Procfile to run the release script in the release phase, and the gunicorn web application in the web phase
a3d336a to
5d23f6b
Compare
docker_prod_1 seems to now be docker-prod-1, so changed this to spit out all docker logs on smoke test failure. In practice this will just be the prod image created in the `just docker-serve prod -d` line.
- Now that migrations are not run when the container is created, but in dokku, if we ever use the container outside of dokku it fails. - The only place this seems to be is in the smoke test which attempts to start the docker container, and check that the app is served correctly - Updated the smoke test to call the migration (release) script - Also parameterized it so you can run it with different environments (dev, prod)
- previously if docker/storage already existed, but with a different owner, then the chown was never run and the db could not be accessed
5d23f6b to
28c1e03
Compare
lucyb
approved these changes
Jul 17, 2025
Contributor
lucyb
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great. Thanks again for picking it up. Please feel free to ignore the more pedantic comments if you'd prefer.
- Removed redundant comments (where there was also an `echo` message to the same effect - Removed comment that likely to go out of date - Clarified in the ADR the circumstances that led to us changing
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #2393.
This has been tested by using the functionality in #2738 - the dokku deployment test branch
rw/dokku-deploy-test.Steps were as follows:
This creates a dokku container and deploys opencodelists to it - available at localhost:7000
Note that we get:
In particular note the lack of a dokku release task:
but that migrations are run because that's how the current docker file works.
We still get the message about no release task, and the migrations are run just before gunicorn starts. The site is available at localhost:7000 and the changes in main but not in the test branch are visible - e.g. the "Development" banner and the better screenshots in the docs.
We now get the following logs:
This shows that the release task is run, and that the migrations are run as part of that task, rather than when the container starts