Skip to content
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

Docker initcontainer #692

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Docker initcontainer #692

wants to merge 8 commits into from

Conversation

DrizzlyOwl
Copy link
Collaborator

Adds a new stage to the Dockerfile which allows us to isolate the Entity Framework database migrations.

When the initcontainer stage is built independently, it will allow us to run the EF migrations as an initContainer for the main web app

docker/Dockerfile Outdated Show resolved Hide resolved
RUN ["tdnf", "install", "-y", "mssql-tools18"]
RUN ["tdnf", "clean", "all"]
### Entity Framework: Migration Builder ###
FROM build AS efbuilder
Copy link
Collaborator

Choose a reason for hiding this comment

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

This efbuilder stage should be entirely independent to the build stage so it doesn't need to be re-run when an unrelated file changes

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As far as I understand it, the EF migration bundle command relies on the dotnet restore and build stage to have completed first. Allowing EF Builder to inherit the docker layer means it only has to be done once.

If we do not use the EF Migration bundle and instead just use the SQL Script file then we can likely refactor this to make it leaner

@DrizzlyOwl DrizzlyOwl force-pushed the docker-initcontainer branch from 6f5b663 to f93bbd3 Compare January 8, 2025 11:50
Base automatically changed from docker-speedifier to main January 10, 2025 15:28
* This entrypoint script will run both the academies db and the fiat db migrations using EF
* Generated an executable Entity Framework migration bundle that can be run as a standalone container
* This means we can build and test both the final runtime image but also the EF migration image used in the initContainer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants