-
Notifications
You must be signed in to change notification settings - Fork 26
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
Build images in the presence of a Dockerfile, when "from" is omitted #88
Conversation
Codecov Report
@@ Coverage Diff @@
## master #88 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 10 11 +1
Lines 305 373 +68
=====================================
+ Hits 305 373 +68
Continue to review full report at Codecov.
|
A couple notes just from my immediate look at this:
|
README.md
Outdated
|
||
For testing different images easily, the `-f <alternate-image>` argument can be called during execution. | ||
|
||
Omitting this property will cause Binci to build a container from your project's Dockerfile. This container will be |
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.
perhaps instead we assume an image pull, if the desire is to build, from goes from from: some-image:latest
to from: file://path/to/Dockerfile
.
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.
See top-level comment!
*/ | ||
deleteImage: (imageName) => Promise.resolve().then(() => { | ||
const delSpinner = output.spinner(`Deleting old image: ${imageName}`) | ||
const cmd = `docker rmi ${imageName}` |
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.
-f
in here may prevent some issues...
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.
I played with this when I was using the image ID to do deletes -- the issue with -f is that it forces a delete even when it's an intermediate of another container. It's not the smoothest move in the world for someone to base a new container on top of a binci build, but if someone did, throwing in -f
would delete their work. That's why I went with the only-delete-the-most-recent model -- if one fails to delete (because someone referenced it elsewhere) then that will be the only time it fails.
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.
Since you'll be working with this feature most directly I assume you'll catch if there is a benefit in the -f
flag down the road (just assuming no one would be strangely building off binci-gen'd images). I just remember how stubborn Docker is on some environments (cough cough OSX) with things like stop
and rm
.
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.
hahaha, thankfully I've not seem the same hangup on the images side compared to the container side. It just seems to bitch (Without the -f) if you're trying to delete an image with dependents, or if you're trying to delete an ID that has multiple tags.
The Dockerfile-in-root thing is a fallback -- it only checks for that if a
Either way, I think it's a good move to, if I'm personally more a fan of the first option (:thumbsup: to avoiding string processing where possible) but I'd be open to the second if you think a second optional parameter is too much complexity. |
I'm fine with it. Probably just being picky about things, but realistically it makes it easier to fallback if no |
👍 Added TODO item |
Still no love on the e2e tests after trying your suggestion... I keep running into:
And that's the result of pretty much every test :-/ |
All other WIP items completed |
README.md
Outdated
@@ -124,11 +124,13 @@ binci -e "/bin/sh" | |||
|
|||
The above would start the container using the configuration, call the `before` task, then start the `sh` shell. The container will then remain in the shell until an `exit` command is sent by the user. | |||
|
|||
## Container Image (`from <string>`) | |||
## Container Image (`dockerfile <string>` or `from <string>`) |
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.
This is going to seem so nit-picky it's gross, but can you reverse this so from
is the first topic, dockerfile
the second. My reasoning is; 1. binci init
creates with from
, and 2. there hasn't been a voiced need for this until now (at least not one acted upon) so I think the majority use-case is from
.
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.
Hahaha, flipped in latest push. Though, to counterpoint (because I have to :D)
- init also writes
dockerfile
now in addition tofrom
. - I think the only reason the majority use case is
from
is because that's the habit we instilled. Testing your own Dockerfile/running tasks against a prod-like build is a generally Good Thing (how many times did we forget to update something in our Dockerfile in the past couple years and not figure it out until it got all the way to staging and crashed), and needing an extra step of maintaining an external base image for a project that requires anything custom at all is a step we got used to/comfortable with, but it's additional work that's now solved by just putting that Dockerfile in your project repo and not usingfrom
anymore. This repo right here is a great example. The repos at our former employer could have made sense under this model too, considering some of them had to runapk add
before most tasks and others just included their deps in the image we maintained globally even if other projects didn't need them. I think it's friggin phenomenal that Binci doesn't force you to build if you don't want to, but I think building by default is one of the things Compose got right. Handling how and when that happens, not so much... but the build is good.
Looks good to me (minus the nit fix). If you're good with it, I am. |
I've been out all day, but I can pull it and run E2E's to see what's up. |
Snuck in one more feature... Since Dockerfiles generally copy the codebase in to the image at a specific path, I added the If we're throwing in the towel on making sure this didn't break e2e, I'm good with a merge after this! |
To date, one of the defining points of Binci vs Compose was that Binci never built images. Getting its legs, this was a huge advantage as it significantly improved iteration time. In practice, this sucks for everything but Node (and sometimes also for Node) because project-specific (and usually native) dependencies either need to be re-installed with every run which takes an incredible amount of time, or managed in a separate Dockerfile built specifically for that project, which is an incredible pain in the ass.
Case and point: Binci requires this repo, and after this update, that Dockerfile can just be moved into the root of this project. 💥
With this update, Binci will:
from
to be omitted from the configdockerfile
is specified in the configbc_12charHashOfDockerfile
Design notes:
Still TODO:Modify theinit
command to not force afrom
selection if a Dockerfile is present in the cwdAdd a dockerfile override arg to the CLI parserFix the system tests? (@Fluidbytebinci e2e
is failing for me in the master -- did this work at all?)Make the readme clearer about this change? It currently takes the tack that image building is a fringe feature that happens if you don't take the default path of specifying afrom
. But this may be a big enough deal to make specifying afrom
the exception.