Create docker temp files under packer.d when TMPDIR is not set #2846
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Packer uses a docker bind mount to upload files into the docker image via a temp directory. When run on a Mac with docker-machine (using vmware/virtualbox) the VM will only mount the /Users directory by default. This causes mounts using the temp directory to silently fail and cause packer to hang waiting for the Upload to finish which can't succeed.
A previous PR #2807 attempted to fix this by creating the temp dir in the CWD of the packer invocation. This caused an issue when a provisioner tried uploading "." and it recursively tried to copy up the intermediate upload directory.
This PR now creates the intermediate upload directory under the packer configuration directory (~/.packer.d/tmp). The ConfigDir()/ConfigFile() code has been moved from package main to package packer to allow the docker code to call it.
Note: the real fix for this issue is to switch to using the latest docker API directly suck as through go-dockerclient. However, this would require upgrading the minimum requirement for docker to version 1.8 which would need consensus before moving forward.