Skip to content

Commit

Permalink
Add project name option for docker compose
Browse files Browse the repository at this point in the history
  • Loading branch information
ZiwenZhuang committed Nov 13, 2024
1 parent 84b2d2d commit b69581d
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ Guidelines for modifications:
* Yujian Zhang
* Zhengyu Zhang
* Ziqi Fan
* Qian Wan
* Wei Yang
* Ziwen Zhuang

## Acknowledgements

Expand Down
3 changes: 3 additions & 0 deletions docker/.env.base
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ DOCKER_ISAACSIM_ROOT_PATH=/isaac-sim
DOCKER_ISAACLAB_PATH=/workspace/isaaclab
# Docker user directory - by default this is the root user's home directory
DOCKER_USER_HOME=/root
# Learning framework to use (e.g. rl_games, rsl_rl, sb3, skrl, robomimic, none)
# no specification installs all
LEARNING_FRAMEWORK=""
5 changes: 4 additions & 1 deletion docker/Dockerfile.base
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ ENV ISAACSIM_ROOT_PATH=${ISAACSIM_ROOT_PATH_ARG}
# Path to the Isaac Lab directory
ARG ISAACLAB_PATH_ARG
ENV ISAACLAB_PATH=${ISAACLAB_PATH_ARG}
# Learning framework to install
ARG ISAACLAB_LEARNING_FRAMEWORK_ARG
ENV ISAACLAB_LEARNING_FRAMEWORK=${ISAACLAB_LEARNING_FRAMEWORK_ARG}
# Home dir of docker user, typically '/root'
ARG DOCKER_USER_HOME_ARG
ENV DOCKER_USER_HOME=${DOCKER_USER_HOME_ARG}
Expand Down Expand Up @@ -82,7 +85,7 @@ RUN touch /bin/nvidia-smi && \
# installing Isaac Lab dependencies
# use pip caching to avoid reinstalling large packages
RUN --mount=type=cache,target=${DOCKER_USER_HOME}/.cache/pip \
${ISAACLAB_PATH}/isaaclab.sh --install
${ISAACLAB_PATH}/isaaclab.sh --install ${ISAACLAB_LEARNING_FRAMEWORK}

# aliasing isaaclab.sh and python for convenience
RUN echo "export ISAACLAB_PATH=${ISAACLAB_PATH}" >> ${HOME}/.bashrc && \
Expand Down
12 changes: 11 additions & 1 deletion docker/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ def parse_cli_args() -> argparse.Namespace:

# We have to create separate parent parsers for common options to our subparsers
parent_parser = argparse.ArgumentParser(add_help=False)
parent_parser.add_argument(
"--project",
nargs="?",
default="isaac-lab",
help="Optional project name to be used for the container.",
)
parent_parser.add_argument(
"profile", nargs="?", default="base", help="Optional container profile specification. Example: 'base' or 'ros'."
)
Expand Down Expand Up @@ -90,7 +96,11 @@ def main(args: argparse.Namespace):

# creating container interface
ci = ContainerInterface(
context_dir=Path(__file__).resolve().parent, profile=args.profile, yamls=args.files, envs=args.env_files
context_dir=Path(__file__).resolve().parent,
profile=args.profile,
project_name=args.project,
yamls=args.files,
envs=args.env_files,
)

print(f"[INFO] Using container profile: {ci.profile}")
Expand Down
9 changes: 5 additions & 4 deletions docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@ services:
- ISAACSIM_ROOT_PATH_ARG=${DOCKER_ISAACSIM_ROOT_PATH}
- ISAACLAB_PATH_ARG=${DOCKER_ISAACLAB_PATH}
- DOCKER_USER_HOME_ARG=${DOCKER_USER_HOME}
image: isaac-lab-base
container_name: isaac-lab-base
- ISAACLAB_LEARNING_FRAMEWORK_ARG=${ISAACLAB_LEARNING_FRAMEWORK}
image: ${COMPOSE_PROJECT_NAME}-base
container_name: ${COMPOSE_PROJECT_NAME}-base
environment: *default-isaac-lab-environment
volumes: *default-isaac-lab-volumes
network_mode: host
Expand All @@ -110,8 +111,8 @@ services:
# avoid a warning message when building only the base profile
# with the .env.base file
- ROS2_APT_PACKAGE=${ROS2_APT_PACKAGE:-NONE}
image: isaac-lab-ros2
container_name: isaac-lab-ros2
image: ${COMPOSE_PROJECT_NAME}-ros2
container_name: ${COMPOSE_PROJECT_NAME}-ros2
environment: *default-isaac-lab-environment
volumes: *default-isaac-lab-volumes
network_mode: host
Expand Down
7 changes: 5 additions & 2 deletions docker/utils/container_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def __init__(
self,
context_dir: Path,
profile: str = "base",
project_name: str = "isaac-lab",
yamls: list[str] | None = None,
envs: list[str] | None = None,
statefile: StateFile | None = None,
Expand Down Expand Up @@ -54,12 +55,14 @@ def __init__(
# Silently correct from isaaclab to base, because isaaclab is a commonly passed arg
# but not a real profile
self.profile = "base"
self.project_name = project_name

self.container_name = f"isaac-lab-{self.profile}"
self.image_name = f"isaac-lab-{self.profile}:latest"
self.container_name = f"{self.project_name}-{self.profile}"
self.image_name = f"{self.project_name}-{self.profile}:latest"

# keep the environment variables from the current environment
self.environ = os.environ
self.environ["COMPOSE_PROJECT_NAME"] = f"{self.project_name}"

# resolve the image extension through the passed yamls and envs
self._resolve_image_extension(yamls, envs)
Expand Down

0 comments on commit b69581d

Please sign in to comment.