testcontainers-python icon indicating copy to clipboard operation
testcontainers-python copied to clipboard

feat(new): add a new Docker Registry test container

Open max-pfeiffer opened this issue 2 years ago • 9 comments

I added a new test container for spinning up a Docker registry.

max-pfeiffer avatar Oct 29 '23 18:10 max-pfeiffer

Hi @max-pfeiffer I'm grooming the ongoing issues for the project (we're rebooting the maintenance, see #405) and I'd like to know more about your test case!

It's nice to have many flavours of containers, but it also means exponentially increasing complexity and cost of running the tests for this project! Therefore we're trying to stick to the most commonly used containers for now.

totallyzen avatar Feb 29 '24 18:02 totallyzen

Since 2024 I think the case may (!) actually be stronger than ever to support it(??)

alexanderankin avatar Feb 29 '24 21:02 alexanderankin

Hi @totallyzen, when building Docker containers with Docker Buildx there is currently no option to test your containers locally without a local registry. Otherwise Buildx pushes your image to Docker Hub, which is not what you want in a test case. More and more you need to use Buildx for effienciently building images and especially multi arch images.

When you use Docker Python libraries like docker-py or python-on-whales to build and test Docker images, what a lot of persons and DevOps engineers like me nowadays do, a test container comes in very handy.

BTW: I use the testcontainers package quite a bit and have time to spare. If you still need a helping hand I would be happy to jump in.

max-pfeiffer avatar Mar 01 '24 07:03 max-pfeiffer

@max-pfeiffer thanks, exactly what I meant to express! :smile: Not to push back, but to explain why this is useful (and put it in the readme of the module) :pray:

@alexanderankin indeed, I meant more the "average developer" use case rather than the specialised use case of the Docker company testing/building their own software! :) If it's only the latter, there would have been arguments that they have been successful without AND they develop their software in Go these days.

Having said that,

Max you're very welcome to join! You can start by rebasing your own PR to match the new project structure:

  • put your source-code in modules/* - basically copy/paste except NO setup.py
  • you put your package in pyproject.toml in here
  • you need to declare an extra even if you don't have any current deps (for future-proofing and making CI code simpler to write) like nginx for example
  • instead of main.yml you put your module in ci-community.yml

After that happy to review your PR and see what you'd like to work on next! :pray:

totallyzen avatar Mar 01 '24 07:03 totallyzen

@totallyzen Thanks for the info. I will work on it this weekend.

BTW: I just stumbled across that page: https://github.com/testcontainers/testcontainers-python/contribute It seemed to be outdated as you guys just refactor the project.

max-pfeiffer avatar Mar 01 '24 07:03 max-pfeiffer

It seemed to be outdated as you guys just refactor the project.

Yes, very much, sorry about that. We're both operating on spare time and energy. Fixes to the docs are highly appreciated! :heart:

totallyzen avatar Mar 01 '24 07:03 totallyzen

@totallyzen I just rebased my PR with main branch and did the refactoring to match the new project setup.

Nice work, I like that setup with Poetry. Also I think it's good to switch to Ruff for code formatting and linting. Ruff is much more performant and easier to configure as all the other common tools.

I struggle to understand what I need to do in ci-community.yml. Looking at that workflow there seems to be nothing to add for me as module changes are tracked automatically.

max-pfeiffer avatar Mar 02 '24 12:03 max-pfeiffer

hey @max-pfeiffer indeed, ci-community.yml is auto-tracking modules as long as you add them in the pyproject.toml, which you did!

I ran the checks for you, seems like some docs and linting errors were made. I think you should be able to see the output and fix them! I can also highly recommend installing pre-commit and running it so you get early feedback! :)

Other than that, you're almost done here! Thanks for the effort!

totallyzen avatar Mar 02 '24 15:03 totallyzen

Hi @totallyzen , hmm I saw that that pre-commit config in project root, but pyproject.toml was missing the pre-commit dependencies (pre-commit, black, ruff). So I would say the pre-commit setup is not really there and ready to use for software engineers. :smiley:

I quickly fixed that in this PR: https://github.com/testcontainers/testcontainers-python/pull/438 Is this something you think we could merge in for completing this PR?

max-pfeiffer avatar Mar 02 '24 16:03 max-pfeiffer