Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BAZEL_BUILD_DIRECTORY option #66

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,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.
Expand Down
5 changes: 4 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
11 changes: 7 additions & 4 deletions dazel.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
DEFAULT_RUN_COMMAND = "/bin/bash"
DEFAULT_DOCKER_COMMAND = "docker"
DEFAULT_LOCAL_DOCKERFILE = "Dockerfile.dazel"
DEFAULT_BUILD_DIRECTORY = os.getcwd()
DEFAULT_REMOTE_REPOSITORY = "dazel"
DEFAULT_DIRECTORY = os.getcwd()
DEFAULT_COMMAND = "/usr/bin/bazel"
Expand Down Expand Up @@ -61,8 +62,8 @@ class DockerInstance:
"""

def __init__(self, instance_name, image_name, run_command, docker_command, dockerfile,
repository, directory, command, volumes, ports, env_vars, gpus, 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):
Expand All @@ -75,6 +76,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
Expand Down Expand Up @@ -121,6 +123,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", DEFAULT_BUILD_DIRECTORY),
Copy link
Collaborator

Choose a reason for hiding this comment

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

To make this backwards compatible, can you please make build_directory fallback to directory rather than than to the default?

command=config.get("DAZEL_COMMAND", DEFAULT_COMMAND),
volumes=config.get("DAZEL_VOLUMES", DEFAULT_VOLUMES),
ports=config.get("DAZEL_PORTS", DEFAULT_PORTS),
Expand Down Expand Up @@ -314,8 +317,8 @@ 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)

Expand Down