Skip to content

Commit

Permalink
[import_dockerfile] Add a option (in DockerMake.yml file) to import D…
Browse files Browse the repository at this point in the history
…ockerfile directely from a (text) file. By default, this option search for a inside the build_directory. We can specify a other name for the Dockerfile. If a Dockerfile is found, we import the content of this file into (before the option).
  • Loading branch information
ATTYLionelIGN committed Feb 27, 2017
1 parent 2d12a77 commit 57a8462
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions docker-make.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,20 @@ def generate_build_order(self, image):
step.build_dir = mydir

step.images.append(d)
from_dockerfile = dep_definition.get('import_dockerfile', 'Dockerfile')
from_dockerfile = os.path.join(step.build_dir, from_dockerfile)
# print('from_dockerfile: %s' % from_dockerfile)
if os.path.exists(from_dockerfile):
try:
with open(from_dockerfile, 'r') as import_dockerfile:
step.dockerfile.append('\n#Commands from %s' % from_dockerfile)
dockerfile = import_dockerfile.read()
# print('dockerfile: %s' % dockerfile)
step.dockerfile.append(dockerfile)
except IOError:
print("IOError -> Can't import `%s`" % from_dockerfile)
if 'build' in dep_definition:
# print("dep_definition['build']: %s" % dep_definition['build'])
step.dockerfile.append('\n#Commands for %s' % d)
step.dockerfile.append(dep_definition['build'])
else:
Expand Down

6 comments on commit 57a8462

@owbear
Copy link

@owbear owbear commented on 57a8462 Mar 18, 2017

Choose a reason for hiding this comment

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

I had to revert this to get the example working

@yoyonel
Copy link
Contributor

Choose a reason for hiding this comment

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

What example do you talking about ?

@owbear
Copy link

@owbear owbear commented on 57a8462 Mar 19, 2017

Choose a reason for hiding this comment

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

@yoyonel There's an example DockerMake.yml in the folder 'example'. Running it now gives me:

READING DockerMake.yml
WARNING: Key error 'tls'
READING buildargs.yml
Traceback (most recent call last):
  File "../docker-make.py", line 536, in <module>
    main()
  File "../docker-make.py", line 305, in main
    buildargs=args.buildargs)
  File "../docker-make.py", line 73, in __init__
    with open(fname, 'r') as yaml_file:
IOError: [Errno 2] No such file or directory: 'buildargs.yml'

@yoyonel
Copy link
Contributor

@yoyonel yoyonel commented on 57a8462 Mar 19, 2017

Choose a reason for hiding this comment

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

Mmmmm strange i catch this exception in my pull ... Need to test the exemple to understand. Keep in touch (tonight)

@owbear
Copy link

@owbear owbear commented on 57a8462 Mar 19, 2017

Choose a reason for hiding this comment

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

@yoyonel I created a pull request for it (#10)

@owbear
Copy link

@owbear owbear commented on 57a8462 Mar 30, 2017

Choose a reason for hiding this comment

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

@yoyonel Look at pull request #11 instead

Please sign in to comment.