Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Multiple dockerfiles #6

Merged
merged 27 commits into from
Jul 5, 2017
Merged

Multiple dockerfiles #6

merged 27 commits into from
Jul 5, 2017

Conversation

hunterloftis
Copy link
Contributor

@hunterloftis hunterloftis commented Oct 4, 2016

Okay @tt and @jbyrum, got a preliminary implementation of the multiple dockerfiles UX. To test:

  1. pull this branch
  2. npm install
  3. heroku plugins:link
  4. push @jbyrum's test apps (https://github.com/jbyrum/multidockerfiles-1, https://github.com/jbyrum/multidockerfiles-2)

Should go something like:

v6.2.0:~/test/multidockerfiles-1 (master)$ heroku container:push
 ▸    Using nearest match for the 'web' process:
 ▸    /Users/hloftis/test/multidockerfiles-1/Dockerfile (used)
 ▸    /Users/hloftis/test/multidockerfiles-1/webapp/Dockerfile.web
Building web (/Users/hloftis/test/multidockerfiles-1/Dockerfile)
Sending build context to Docker daemon 135.2 kB
Step 1 : FROM alpine:latest
 ---> ee4603260daa
Step 2 : RUN apk add --update python py-pip bash
 ---> Using cache
 ---> 3af33f3fbfa2
Step 3 : ADD ./webapp/requirements.txt /tmp/requirements.txt
 ---> Using cache
 ---> b054ad539efe
Step 4 : RUN pip install -qr /tmp/requirements.txt
 ---> Using cache
 ---> 47810befab5f
Step 5 : ADD ./webapp /opt/webapp/
 ---> Using cache
 ---> 656348035406
Step 6 : WORKDIR /opt/webapp
 ---> Using cache
 ---> aba264f7e49d
Step 7 : CMD python app.py
 ---> Using cache
 ---> f056bba8f77f
Successfully built f056bba8f77f
Building image (/Users/hloftis/test/multidockerfiles-1/image-processing/Dockerfile.image)
Sending build context to Docker daemon 3.072 kB
Step 1 : FROM alpine:latest
 ---> ee4603260daa
Step 2 : RUN apk add --update python py-pip bash
 ---> Using cache
 ---> 3af33f3fbfa2
Step 3 : ADD . /opt/image-processing/
 ---> Using cache
 ---> 6edebd0cda1d
Step 4 : WORKDIR /opt/image-processing
 ---> Using cache
 ---> 0b000098e489
Step 5 : CMD python image-processing.py
 ---> Using cache
 ---> 7aca76942497
Successfully built 7aca76942497
Building worker (/Users/hloftis/test/multidockerfiles-1/worker/Dockerfile.worker)
Sending build context to Docker daemon 3.072 kB
Step 1 : FROM alpine:latest
 ---> ee4603260daa
Step 2 : RUN apk add --update python py-pip bash
 ---> Using cache
 ---> 3af33f3fbfa2
Step 3 : ADD . /opt/worker/
 ---> Using cache
 ---> 69dfae0635ad
Step 4 : WORKDIR /opt/worker
 ---> Using cache
 ---> cae090ddea7e
Step 5 : CMD python worker.py
 ---> Using cache
 ---> 565ef506cb42
Successfully built 565ef506cb42
Pushing 3 images...
Pushing web (/Users/hloftis/test/multidockerfiles-1/Dockerfile)
The push refers to a repository [registry.heroku.com/whispering-beyond-11493/web]
ba6984bf4df2: Layer already exists
62affd5f66a7: Layer already exists
be752c7999c0: Layer already exists
e577649c1afa: Layer already exists
9007f5987db3: Layer already exists
latest: digest: sha256:72bf59ac080eca6f22e4a38e7b67f6a6df1af71fce065a537749a2d5d7147773 size: 1366
Pushing image (/Users/hloftis/test/multidockerfiles-1/image-processing/Dockerfile.image)
The push refers to a repository [registry.heroku.com/whispering-beyond-11493/image]
2504e8086f59: Layer already exists
e577649c1afa: Layer already exists
9007f5987db3: Layer already exists
latest: digest: sha256:bb726cb810be83c542877c940d4109c90f7e2f16cdd1bf44671cdc1fda1e47df size: 947
Pushing worker (/Users/hloftis/test/multidockerfiles-1/worker/Dockerfile.worker)
The push refers to a repository [registry.heroku.com/whispering-beyond-11493/worker]
3d3bf091d8a8: Layer already exists
e577649c1afa: Layer already exists
9007f5987db3: Layer already exists
latest: digest: sha256:89f2bef3c07ef8ca1ab155de03ce3d08db11448dff7f107ce3dc5d6a1bcb0447 size: 947

@jbyrum
Copy link
Contributor

jbyrum commented May 3, 2017

@KarateCowboy -- Does this need to be merged before I can play with it?

cc @tt

1 similar comment
@jbyrum
Copy link
Contributor

jbyrum commented May 3, 2017

@KarateCowboy -- Does this need to be merged before I can play with it?

cc @tt

@KarateCowboy KarateCowboy requested review from jdx and jbyrum May 3, 2017 18:24
@jdx
Copy link
Contributor

jdx commented May 3, 2017

you can run the plugins locally by checking out the code and running heroku plugins:link .

@KarateCowboy
Copy link
Contributor

@jbyrum no just check out the multiple-dockerfiles branch, then do as @dickeyxxx just suggested with heroku plugins:link

@jdx
Copy link
Contributor

jdx commented May 3, 2017

multiple stuff seems good, I was able to get inquirer to at least prompt but it would probably be good to have @jbyrum do a more thorough test

expect(results.web[1]).to.have.property('depth', 2, 'dockerfile', './Nested/Dockerfile.web', 'postfix', 1)
})
it('filters out by process type', () => {
const dockerfiles = ['./Dockerfile.web', './Nested/Dockerfile.worker']
Copy link
Contributor

Choose a reason for hiding this comment

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

these should use path.join() so they could work on windows

commands/push.js Outdated

try {
let build = yield buildImage(resource, context.cwd, context.flags.verbose);
for (let job of jobs) {
cli.log(`\n=== Building ${ job.name } (${ job.dockerfile })`)
Copy link
Contributor

Choose a reason for hiding this comment

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

cli.header might be preferable

commands/push.js Outdated
let herokuHost = process.env.HEROKU_HOST || 'heroku.com'
let registry = `registry.${ herokuHost }`
let dockerfiles = Sanbashi.getDockerfiles(process.cwd(), recurse)
let possibleJobs = Sanbashi.getJobs(`${ registry }/${ context.app }`, context.args, dockerfiles)
Copy link
Contributor

Choose a reason for hiding this comment

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

path.join here

Copy link
Member

Choose a reason for hiding this comment

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

Is this a path?

Copy link
Contributor

Choose a reason for hiding this comment

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

whoops, no it isn't

Copy link
Member

Choose a reason for hiding this comment

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

So we should concat manually?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah this code is fine

commands/push.js Outdated
let jobs = yield Sanbashi.chooseJobs(possibleJobs)
if (!jobs.length) {
cli.warn('No images to push')
process.exit()
Copy link
Contributor

Choose a reason for hiding this comment

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

this is an error to me not a place for a warning

@hunterloftis
Copy link
Contributor Author

If the CLI uses the latest version of node now there's a good opportunity to use modern async constructs as well (like async/await instead of co).

package.json Outdated
"is-there": "4.0.0",
"lodash": "3.3.1",
"mkdirp": "^0.5.0",
"node-uuid": "^1.4.3",
"node-uuid": "1.4.3",
Copy link
Contributor

Choose a reason for hiding this comment

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

this package is deprecated

package.json Outdated
@@ -19,28 +19,29 @@
"license": "ISC",
"dependencies": {
"camelcase": "1.0.2",
"chalk": "1.1.3",
Copy link
Contributor

Choose a reason for hiding this comment

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

use cli.color not chalk directly

commands/push.js Outdated
if (context.args.length === 0 && !recurse) {
cli.error(`Error: Requires either --recursive or one or more process types
${Chalk.bold.underline.magenta('Usage:')}
${ Chalk.white(' heroku container:push web')} # Pushes Dockerfile in current directory
Copy link
Contributor

Choose a reason for hiding this comment

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

we have a style for this: cli.color.cmd() check out the style guide

@KarateCowboy KarateCowboy force-pushed the multiple-dockerfiles branch from 0eedbe1 to 434c6c4 Compare May 5, 2017 19:55
use Path.join
some formatting changes
@KarateCowboy KarateCowboy force-pushed the multiple-dockerfiles branch from 434c6c4 to 9522087 Compare May 5, 2017 21:08
jdx
jdx previously requested changes May 23, 2017
}
catch (err) {
cli.error(`Error: docker login exited with ${ err }`);
cli.error(`Error: docker login exited with ${ err }`)
cli.hush(err.stack || err)
Copy link
Contributor

Choose a reason for hiding this comment

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

this should exit with a nonzero code, it looks like it's exiting with 0

Copy link
Contributor

Choose a reason for hiding this comment

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

fixed

commands/push.js Outdated
const child = require('child_process');
let usage = `
${cli.color.bold.underline.magenta('Usage:')}
${ cli.color.white('heroku container:push web')} # Pushes Dockerfile in current directory to web process type
Copy link
Contributor

Choose a reason for hiding this comment

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

use cli.color.cmd

commands/push.js Outdated
}

try {
let push = yield pushImage(resource, context.flags.verbose);
for (let job of jobs) {
cli.styledHeader(`Pushing ${job.name} (${job.dockerfile })`)
Copy link
Contributor

Choose a reason for hiding this comment

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

there are a lot of little style issues like the indentation on this line. It's probably too much work to put it in for the whole project, but it would be good to run it at least on the new code


module.exports = function(topic) {
return {
topic: topic,
command: 'logout',
flags: [{ name: 'verbose', char: 'v', hasValue: false }],
description: 'Logs out from the Heroku Docker registry',
description: 'logs out from the Heroku Container Registry',
help: `Usage:
Copy link
Contributor

Choose a reason for hiding this comment

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

the CLI already automatically adds a "usage" help bit. Just take the help attribute out here since it's not adding anything useful

Copy link
Contributor

@jbyrum jbyrum left a comment

Choose a reason for hiding this comment

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

I ran heroku container:push web -a alpine-helloworld-dogwood

The header said "=== Building standard" rather than "=== Building web"

It is also pushing to a process type called 'standard':
v50 Deployed standard (701dbd3a2818) [email protected] 2017/05/23 15:31:20 -0700 (~ 7s ago)

@KarateCowboy KarateCowboy requested a review from jdx May 25, 2017 18:49
@KarateCowboy
Copy link
Contributor

@jbyrum fixed that issue

@jbyrum
Copy link
Contributor

jbyrum commented Jun 12, 2017

This is now working for me -- I don't see any additional bugs.

What's next? @dickeyxxx @tt

@KarateCowboy KarateCowboy dismissed jdx’s stale review June 13, 2017 16:05

Code updated. please look again

@KarateCowboy
Copy link
Contributor

@dickeyxxx poke poke. Please review

jdx
jdx previously requested changes Jun 15, 2017
flags: [{name: 'verbose', char: 'v', hasValue: false}],
description: 'logs in to the Heroku Container Registry',
help: `Usage:
heroku container:login`,
Copy link
Contributor

Choose a reason for hiding this comment

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

missing the $ sign and this example shold show some output

flags: [{ name: 'verbose', char: 'v', hasValue: false }],
description: 'Logs in to the Heroku Docker registry',
flags: [{name: 'verbose', char: 'v', hasValue: false}],
description: 'logs in to the Heroku Container Registry',
Copy link
Contributor

Choose a reason for hiding this comment

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

"logs into"

Copy link
Contributor

Choose a reason for hiding this comment

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

"logs in to" is actually correct. "in" is part of the verb phase

Copy link
Contributor

Choose a reason for hiding this comment

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

so I recently ran through our entire help and audited everything: heroku/cli-engine#196

What I found was there is a mix of using present tense and another type that I think might be "imperative mood" but I'm not sure. Anyways, this "imperative mood" (if that is the correct term) is used much more commonly and I think makes more sense.

So in this case it would be "log in to the Heroku Container Registry". Not "logs in to the Heroku Container Registry". I plan to add this to the style guide.

Also, I'm not sure what language we use elsewhere in documentation, but I'm pretty sure in the CLI we never use "log in" as 2 words, it's always "login" and "logout". So I think my first comment here was wrong for a few reasons.

commands/push.js Outdated

let possibleJobs = Sanbashi.getJobs(`${ registry }/${ context.app }`, dockerfiles)
let jobs = []
if(recurse){
Copy link
Contributor

Choose a reason for hiding this comment

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

can you run standard on this file at least to fix the formatting?

child.spawn('docker', args, { stdio: 'inherit' })
]
log(verbose, args)
child.spawn('docker', args, {stdio: 'inherit'})
Copy link
Contributor

Choose a reason for hiding this comment

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

we should abstract this into 1 spawn function that returns a promise

lib/sanbashi.js Outdated
}

Sanbashi.pushImage = function (resource, verbose) {
console.dir(resource, { colors:true, depth: null })
Copy link
Contributor

Choose a reason for hiding this comment

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

is this supposed to be in here?

Copy link
Contributor

Choose a reason for hiding this comment

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

removed it

commands/push.js Outdated
let usage = `
${cli.color.bold.underline.magenta('Usage:')}
${ cli.color.cmd('heroku container:push web')} # Pushes Dockerfile in current directory to web process type
${ cli.color.cmd('heroku container:push web worker --recursive')} # Pushes Dockerfile.web and Dockerfile.worker found in current & subdirectories
Copy link
Contributor

Choose a reason for hiding this comment

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

these lines are far too long

Copy link
Contributor

Choose a reason for hiding this comment

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

should show output too if possible

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the feedback -- @KarateCowboy, can we update with this text? It adds new help text to -R and new text for the heroku container:push examples

https://docs.google.com/document/d/1DbuvumF3aerFqO-1h0W0evuVLFmV9XOp5bEXEnvSi3Y/edit#heading=h.kme0kogsywhu

Copy link
Contributor

Choose a reason for hiding this comment

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

soon(-ish) we plan to have a format for examples since we use them so much: heroku/cli-engine#190

flags: [{ name: 'verbose', char: 'v', hasValue: false }],
description: 'Logs out from the Heroku Docker registry',
flags: [{name: 'verbose', char: 'v', hasValue: false}],
description: 'logs out from the Heroku Container Registry',
needsApp: false,
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add help with an output example?

return {
topic: pkg.topic,
description: pkg.description,
help: pkg.description,
Copy link
Contributor

Choose a reason for hiding this comment

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

can you put the help back in with an output example?

Copy link
Contributor

Choose a reason for hiding this comment

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

To which command are you referring? the basic heroku containers just prints the version. What would you like added -- the sum of all the help for the other commands?

Copy link
Contributor

Choose a reason for hiding this comment

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

an example of it printing the version then, we're supposed to have output examples for every command. I realize that isn't the most useful thing in the world, but it clearly demonstrates what a command is for.

this is the (soon-to-be enforced) rule for core plugins anyways, but we should do it on any plugin we can

jbyrum and others added 5 commits June 19, 2017 09:57
the same code was repeated in several places to spawn docker
commands. Consolidated this into a helper method
@KarateCowboy KarateCowboy dismissed jdx’s stale review June 30, 2017 19:47

changes addressed please review again

@KarateCowboy KarateCowboy merged commit 36cb431 into master Jul 5, 2017
@KarateCowboy KarateCowboy deleted the multiple-dockerfiles branch July 5, 2017 21:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants