From 60349997022a22d25794bffb89d1c9dfbc8515c1 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 23 Apr 2021 18:09:49 -0700 Subject: [PATCH] Add support for computers without NVIDIA hardware --- Dockerfile | 5 ++--- README.md | 6 +++--- docker-compose.yml | 38 +++++++++++++++++++++++++------------- 3 files changed, 30 insertions(+), 19 deletions(-) diff --git a/Dockerfile b/Dockerfile index 89d5aa0..008f54c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,6 @@ +ARG BASE_IMAGE -ARG UBUNTU_VERSION - -FROM nvidia/opengl:1.1-glvnd-runtime-ubuntu${UBUNTU_VERSION} +FROM ${BASE_IMAGE} # For this build, we pull the entire ros image, and then merge the filesystem # with the nvidia/opengl image, so that displaying to the screen on GPU diff --git a/README.md b/README.md index 2fa3cbe..82a20d4 100644 --- a/README.md +++ b/README.md @@ -29,11 +29,11 @@ is new enough. Once docker is installed, run the following command, and the project should show up: ``` -docker-compose build && xhost +local:root && docker-compose up +docker-compose build ros && xhost +local:root && docker-compose up ros ``` This command does three things: -1) `docker-compose build` +1) `docker-compose build ros` This builds the project in a container. That means nothing is installed on your host machine! The first time this runs, this command will take a long while. After running it once, caching @@ -43,7 +43,7 @@ This command does three things: This command gives X the ability to display GUI's from within the docker container -3) `docker-compose up` +3) `docker-compose up ros` This runs the image specified in the `docker-compose.yml`, which by default runs the command `roslaunch myCobotROS control_slider.launch` within the container. diff --git a/docker-compose.yml b/docker-compose.yml index 322d9d4..e11f3fb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,19 +1,31 @@ -version: '3' +version: '3.4' + +x-app: &common + command: [ "roslaunch myCobotROS control_slider.launch" ] + privileged: true + environment: + PYTHONUNBUFFERED: 1 + QT_X11_NO_MITSHM: 1 + DISPLAY: :1 + volumes: + - "/tmp/.X11-unix:/tmp/.X11-unix:rw" + build: + context: . + args: &common-args + ROS_DISTRO: "kinetic" + PYMYCOBOT_VERSION: ">=2<3" + BASE_IMAGE: nvidia/opengl:1.1-glvnd-runtime-ubuntu18.04 + services: + # This configuration builds the project for computers with NVIDIA hardware + nvidia-ros: *common + + # This is the default for computers that don't have nvidia hardware accelerators ros: - image: elephantrobotics/my-cobot-ros - command: ["roslaunch myCobotROS control_slider.launch"] - privileged: true - environment: - PYTHONUNBUFFERED: 1 - QT_X11_NO_MITSHM: 1 - DISPLAY: :1 - volumes: - - "/tmp/.X11-unix:/tmp/.X11-unix:rw" + <<: *common build: context: . args: - UBUNTU_VERSION: "16.04" - ROS_DISTRO: "kinetic" - PYMYCOBOT_VERSION: ">=2<3" + <<: *common-args + BASE_IMAGE: ubuntu:18.04