hirosystems / clarinet

Write, test and deploy high-quality smart contracts to the Stacks blockchain and Bitcoin.
https://hiro.so/clarinet
GNU General Public License v3.0
298 stars 132 forks source link

fix: introduce create-only-if-needed functions for containers and images #1493

Open tippenein opened 3 months ago

tippenein commented 3 months ago

closes #1455

The main addition here is create_image_if_needed and the container_if_needed is seemingly only needed for postgres. There is a bit of a discrepancy with what to do when we hit already existing containers. Currently it uses it, but alternatively we could drop and recreate for postgres..

this current functionality allows me to clarinet devnet start with wifi off.

codecov[bot] commented 3 months ago

Codecov Report

Attention: Patch coverage is 0% with 193 lines in your changes missing coverage. Please review. Files Patch % Lines
components/stacks-network/src/orchestrator.rs 0.00% 193 Missing :warning:

:loudspeaker: Thoughts on this report? Let us know!

hugocaillard commented 3 months ago

@tippenein Regarding the original issue (#1455), I was wondering if you could make it work with native docker behaviors, either by building images with --pull false (docker build --pull=false <...> ) or when starting the container docker run --pull=never <....>

With this in mind, I wonder if any code change if needed

tippenein commented 3 months ago

You would still need to list out the existing images/containers to see if a pull=false would even work, right? Like, if you are running this for the first time, the pull=false build would just fail.

hugocaillard commented 3 months ago

@tippenein If we build our images with --pull false, I think it would still try to pull it it doesn't exist. The documentation says that --pull: _Always_ attempt to pull all referenced images, I'm assuming that pull false only make it so docker pulls it only if it needs to

tippenein commented 3 months ago

I'll experiment with this a little and see if we can simplify. I think you're right

hugocaillard commented 3 months ago

Switching to draft for now will it's still wip