-
Notifications
You must be signed in to change notification settings - Fork 71
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
Add a dev target to Dockerfile, add a dev compose file #836
base: main
Are you sure you want to change the base?
Conversation
- Add a dev target to Dockerfile which will install dev and static-check dependencies - Set up a volume that syncs local changes into the running containers - Create a new compose service for barebones development and running tests
@@ -53,3 +53,32 @@ USER karapace | |||
|
|||
HEALTHCHECK --interval=10s --timeout=30s --retries=3 --start-period=60s \ | |||
CMD python3 healthcheck.py http://localhost:$KARAPACE_PORT/_health || exit 1 | |||
|
|||
|
|||
FROM builder AS dev-builder |
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.
issue: Introducing the new stages means we must update the release flow so that we don't start publishing dev images: https://github.com/Aiven-Open/karapace/blob/main/.github/workflows/container.yml.
Similarly, I think if we're to keep the two compose files, target must be specified in the existing one.
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.
Simple solution for this is simply to have the actual production stage come after the dev
stage. This way, the default will always be the production one. And by correctly using dependencies, when building for the prod stage (implicitly or not), docker won't run any of the build code for dev.
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.
That sounds like the best solution 👍
… prod is default.
Funny logs from the smoke test ... 🤪
|
Hmm why did that happen. Is the test checking if the services run indefinitely or something like that? So if they end, it fails |
No, the test just checks a single basic API call returns successfully, but the CI flow did not reach the test stage, it fails at the build stage. I think the logs just looks funny because of concurrency. I think because we introduce the special dev service in the compose file, let's leave It could perhpas also make sense to add something like this to the smoke test to give confidence test dependencies aren't installed in the default target: if ! docker compose exec karapace-registry which pytest >/dev/null; then
echo 'Error: test dependencies found in production image'
exit 1
fi |
The main issue with that for me is the development cycle, as you will be required to rebuild the image every time you make a change on the code. I guess theoretically I could just move the PYTHONPATH setting to the compose file, I'll see if that works fine |
But wouldn't you always develop locally against the new dev service? The smoke test must run the production target. If we introduce some separate means to achieve that, it's completely fine either way IMO (separate service, or separate compose file). |
I'm not sure, perhaps you want to make changes and quickly check them in the running REST or registry services? The dev service doesn't contain any of the env vars, etc which are present in the other services That's why I'd say it could be useful to have the |
@gpkc I think your reasoning is sound, my knee-jerk reaction against multiple compose files was just for attempting to keeping things simpler. |
About this change - What it does
What this enables:
docker-compose -f compose.yml -f compose-dev.yml run karapace-dev pytest -s -vvv tests/unit
docker-compose down
followed bydocker-compose up
is enough)Why this way
See #585.
dev-builder
anddev
.python-dev
dependency among others.dev
target is needed for isolation. It will have the development deps installed and also changesPYTHONPATH
to point to the synced folder.volumes
in the dev compose file.PYTHONPATH
being set to this folder, every instance of e.g.python3 -m karapace ...
orimport karapace
will be seeing the synced folder.karapace-dev
karapace-registry
andkarapace-rest
, but that would require overriding their configurations in a manner that would mix things up too much. Instead, I've opted to create a new service that has the clear purpose of being used directly in the test-develop cycle.In the future, one can also add a watcher to the running servers, so that not even restarting the container is necessary.