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-compose --build support #78

Conversation

jtanios
Copy link

@jtanios jtanios commented Mar 23, 2020

This PR adds support to build the containers before starting the services.
Resolves #76

Also, there's an enhancement to the tests to make them run from anywhere, it doesn't have to be project root. This was an issue when running the tests from an IDE, like PyCharm.

@codecov-io
Copy link

codecov-io commented Mar 23, 2020

Codecov Report

Merging #78 into master will increase coverage by 0.18%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #78      +/-   ##
==========================================
+ Coverage   84.94%   85.13%   +0.18%     
==========================================
  Files          19       19              
  Lines         392      397       +5     
  Branches       25       26       +1     
==========================================
+ Hits          333      338       +5     
  Misses         43       43              
  Partials       16       16              
Impacted Files Coverage Δ
testcontainers/compose.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 70b142e...0f8f9d2. Read the comment docs.

@jtanios
Copy link
Author

jtanios commented Mar 24, 2020

@tillahoffmann , would you like to review?



def test_can_build_images_before_spawning_service_via_compose():
with DockerCompose(TESTS_DIR, build=True) as compose:
Copy link
Collaborator

Choose a reason for hiding this comment

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

What does docker-compose do when --build is passed but the docker-compose.yml file doesn't contain any reference to a locally-built image?

Copy link
Author

Choose a reason for hiding this comment

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

Good question!

I just tried it with the tests/docker-compose.yml and it had no effect; it worked exactly as it would without it.

Copy link
Author

Choose a reason for hiding this comment

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

@tillahoffmann ☝️ is this good enough?

@tillahoffmann
Copy link
Collaborator

tillahoffmann commented Jun 19, 2020

Closing for now as wontfix (see #83 for details), but thank you for the contribution!

This is a bit of a tricky one: it's somewhat easier to argue for supporting --build in docker compose because it's a single flag, whereas adding build functionality in general is probably beyond the scope of this library. Let's see whether this continues to be a need (as opposed to running docker compose --build prior to running the tests), and we can reconsider.

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.

Option to build the docker containers before starting
3 participants