diff --git a/README.md b/README.md index 49b3b41..bac8361 100644 --- a/README.md +++ b/README.md @@ -68,9 +68,12 @@ DAZEL_DOCKERFILE="Dockerfile.dazel" # in DAZEL_DIRECTORY # The repository to pull the dazel image from. DAZEL_REPOSITORY="dazel" -# The directory to build the dazel image in. +# The directory containing the bazel workspace DAZEL_DIRECTORY=$PWD +# The directory to build the docker image in +DAZEL_BUILD_DIRECTORY=$PWD + # The command to run inside the container. # NOTE: You should add flags to the .bazelrc file instead of here, since it is # also shared in the volume and it is a much cleaner way. diff --git a/README.rst b/README.rst index 81108ed..ee8351a 100644 --- a/README.rst +++ b/README.rst @@ -89,9 +89,12 @@ The possible parameters to set are (with their defaults): # The repository to pull the dazel image from. DAZEL_REPOSITORY="dazel" - # The directory to build the dazel image in. + # The directory containing the bazel workspace DAZEL_DIRECTORY=$PWD + # The directory to build the docker image in + DAZEL_BUILD_DIRECTORY=$PWD + # The command to run inside the container. # NOTE: You should add flags to the .bazelrc file instead of here, since it is # also shared in the volume and it is a much cleaner way. diff --git a/dazel.py b/dazel.py index d644e21..9541eda 100644 --- a/dazel.py +++ b/dazel.py @@ -55,8 +55,8 @@ class DockerInstance: """ def __init__(self, instance_name, image_name, run_command, docker_command, dockerfile, - repository, directory, command, volumes, ports, env_vars, network, - run_deps, docker_compose_file, docker_compose_command, + repository, directory, build_directory, command, volumes, ports, + env_vars, network, run_deps, docker_compose_file, docker_compose_command, docker_compose_project_name, docker_compose_services, bazel_user_output_root, bazel_rc_file, docker_run_privileged, docker_machine, dazel_run_file, workspace_hex, delegated_volume, user, docker_build_args): @@ -69,6 +69,7 @@ def __init__(self, instance_name, image_name, run_command, docker_command, docke self.dockerfile = dockerfile self.repository = repository self.directory = directory + self.build_directory = build_directory self.command = command self.network = network self.docker_compose_file = docker_compose_file @@ -113,6 +114,7 @@ def from_config(cls): dockerfile=config.get("DAZEL_DOCKERFILE", DEFAULT_LOCAL_DOCKERFILE), repository=config.get("DAZEL_REPOSITORY", DEFAULT_REMOTE_REPOSITORY), directory=config.get("DAZEL_DIRECTORY", DEFAULT_DIRECTORY), + build_directory=config.get("DAZEL_BUILD_DIRECTORY", directory), command=config.get("DAZEL_COMMAND", DEFAULT_COMMAND), volumes=config.get("DAZEL_VOLUMES", DEFAULT_VOLUMES), ports=config.get("DAZEL_PORTS", DEFAULT_PORTS), @@ -251,7 +253,7 @@ def _build(self): raise RuntimeError("No Dockerfile to build the dazel image from.") command = "%s build %s -t %s/%s -f %s %s" % ( - self.docker_command, self.docker_build_args, self.repository, self.image_name, self.dockerfile, self.directory) + self.docker_command, self.docker_build_args, self.repository, self.image_name, self.dockerfile, self.build_directory) command = self._with_docker_machine(command) return self._run_silent_command(command)