Skip to content

Fix/docker local build test #27

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

Open
wants to merge 4 commits into
base: main
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
2 changes: 1 addition & 1 deletion context/apps/Dockerfile.robot
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ RUN mkdir -p /ras_robot_app
RUN apt update && apt install -y inetutils-ping
RUN apt install wget unzip -y
RUN pip install xArm-Python-SDK

RUN apt install -y ros-humble-realsense2-camera
USER ras
RUN python3 -m pip install flask pyftpdlib paho-mqtt opencv-contrib-python==4.7.0.72 numpy==1.21.5
USER root
Expand Down
74 changes: 58 additions & 16 deletions scripts/ras_docker/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ def init_app(args: argparse.Namespace):
# if(vcs_fetch_repos(repos_file,apps_path,pull=True)):
# dep_repos_file = app_path/"deps.repos"
# vcs_fetch_repos(dep_repos_file,app_path,pull=True)
force_pull = (hasattr(args,"image_pull") and args.image_pull)
pull_from_docker_repo("ras_base",force_pull)
pull_from_docker_repo(app_name,force_pull)
# force_pull = (hasattr(args,"image_pull") and args.image_pull)
# pull_from_docker_repo("ras_base",force_pull)
# pull_from_docker_repo(app_name,force_pull)


@dataclass
Expand All @@ -64,33 +64,75 @@ def __post_init__(self,app_ns:str):



def get_app_spacific_docker_cmd(args : argparse.Namespace,docker_cmd_fmt_src,remove_cn=True,extra_docker_args = ""):
# def get_app_spacific_docker_cmd(args : argparse.Namespace,docker_cmd_fmt_src,remove_cn=True,extra_docker_args = ""):
# app_conf = AppCoreConf(args.app)
# app_path = WORKING_PATH/'apps'/app_conf.app_name
# config_dir=str(WORKING_PATH/'configs')
# asset_dir=str(WORKING_PATH/'assets')
# if not app_path.exists():
# print(f"Error: {app_path} does not exist")
# print(f"Please run the init command first")
# exit(1)
# if remove_cn:
# extra_docker_args += " --rm "
# # if app_conf.app_name == "ras_server_app":
# extra_docker_args += f" -v {asset_dir}:/{app_conf.app_name}/ros2_ws/src/assets "
# docker_cmd_fmt_local = partial(docker_cmd_fmt_src,
# display_env=f"{get_display_var()}",
# app_dir=str(app_path),
# work_dir="/"+app_conf.app_name,
# extra_docker_args=f"-v {config_dir}:/{app_conf.app_name}/configs {extra_docker_args}"
# )
# allow_login = args.command in ["dev","run"]
# docker_cmd_fmt_new = regen_docker_fmt(docker_cmd_fmt_local,app_conf,allow_login=allow_login)
# if isinstance(docker_cmd_fmt_new,type(None)):
# print("Already Running")
# exit(1)
# return docker_cmd_fmt_new

def get_app_spacific_docker_cmd(args: argparse.Namespace, docker_cmd_fmt_src, remove_cn=True, extra_docker_args=""):
app_conf = AppCoreConf(args.app)
app_path = WORKING_PATH/'apps'/app_conf.app_name
config_dir=str(WORKING_PATH/'configs')
asset_dir=str(WORKING_PATH/'assets')
app_path = WORKING_PATH / 'apps' / app_conf.app_name
config_dir = str(WORKING_PATH / 'configs')
asset_dir = str(WORKING_PATH / 'assets')

if not app_path.exists():
print(f"Error: {app_path} does not exist")
print(f"Please run the init command first")
exit(1)

# Freshly construct docker args for this app
docker_args = ""
if remove_cn:
extra_docker_args += " --rm "
# if app_conf.app_name == "ras_server_app":
extra_docker_args += f" -v {asset_dir}:/{app_conf.app_name}/ros2_ws/src/assets "
docker_cmd_fmt_local = partial(docker_cmd_fmt_src,
docker_args += " --rm "

# Only mount assets if this is the server app
if app_conf.app_name == "ras_server_app":
docker_args += f" -v {asset_dir}:/{app_conf.app_name}/ros2_ws/src/assets "

# Always mount the config directory
docker_args = f"-v {config_dir}:/{app_conf.app_name}/configs {docker_args}"

docker_cmd_fmt_local = partial(
docker_cmd_fmt_src,
display_env=f"{get_display_var()}",
app_dir=str(app_path),
work_dir="/"+app_conf.app_name,
extra_docker_args=f"-v {config_dir}:/{app_conf.app_name}/configs {extra_docker_args}"
work_dir="/" + app_conf.app_name,
extra_docker_args=docker_args
)
allow_login = args.command in ["dev","run"]
docker_cmd_fmt_new = regen_docker_fmt(docker_cmd_fmt_local,app_conf,allow_login=allow_login)
if isinstance(docker_cmd_fmt_new,type(None)):

allow_login = args.command in ["dev", "run"]
docker_cmd_fmt_new = regen_docker_fmt(docker_cmd_fmt_local, app_conf, allow_login=allow_login)

if docker_cmd_fmt_new is None:
print("Already Running")
exit(1)

return docker_cmd_fmt_new




def build_image_app(args : argparse.Namespace):

force_option = False
Expand Down