Skip to content
This repository has been archived by the owner on Jan 5, 2023. It is now read-only.

Allow for setting context of Docker build #37

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion molecule_docker/playbooks/create.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
- not item.item.pre_build_image | default(false)
docker_image:
build:
path: "{{ molecule_ephemeral_directory }}"
path: "{{ item.item.context | default(molecule_ephemeral_directory) }}"
Copy link
Member

Choose a reason for hiding this comment

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

Why would this be called context and not path? I also do not find this documented anywhere, which worries me a little bit.

Choose a reason for hiding this comment

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

This is how docker is calling it. Because the image is built by the docker engine (that might not even run on the same host as the CLI command), this is what happens when we execute the build command (a bit simplified, but close enough):

  1. CLI tool packages the current directory into a build context and sends it to the engine.
  2. Engine executes instructions from the Dockerfile, taking any files required from the context that has been sent to it.

I hope this explains things a bit.

dockerfile: "{{ item.invocation.module_args.dest }}"
pull: "{{ item.item.pull | default(true) }}"
network: "{{ item.item.network_mode | default(omit) }}"
Expand Down