diff --git a/.devcontainer/cloud/devcontainer.json b/.devcontainer/cloud/devcontainer.json new file mode 100644 index 0000000..cf4dadc --- /dev/null +++ b/.devcontainer/cloud/devcontainer.json @@ -0,0 +1,15 @@ +{ + "name": "Webots Cloud Based", + "dockerComposeFile": [ + "../../docker-composes/docker-compose-gui-nvidia.yml" // Alternatives: "../docker/docker-compose-gui.yml", "../docker/docker-compose-gui-nvidia.yml", "../docker/docker-compose-nvidia.yml" + ], + "service": "webots_docker", + "workspaceFolder": "/workspace", + "shutdownAction": "stopCompose", + "remoteEnv": {}, + "postAttachCommand": "", + "postCreateCommand": "", + "postStartCommand": "", + "initializeCommand": "echo 'webots cloud based'", + "extensions": [], +} \ No newline at end of file diff --git a/.devcontainer/nvidia/devcontainer.json b/.devcontainer/nvidia/devcontainer.json new file mode 100644 index 0000000..cf4dadc --- /dev/null +++ b/.devcontainer/nvidia/devcontainer.json @@ -0,0 +1,15 @@ +{ + "name": "Webots Cloud Based", + "dockerComposeFile": [ + "../../docker-composes/docker-compose-gui-nvidia.yml" // Alternatives: "../docker/docker-compose-gui.yml", "../docker/docker-compose-gui-nvidia.yml", "../docker/docker-compose-nvidia.yml" + ], + "service": "webots_docker", + "workspaceFolder": "/workspace", + "shutdownAction": "stopCompose", + "remoteEnv": {}, + "postAttachCommand": "", + "postCreateCommand": "", + "postStartCommand": "", + "initializeCommand": "echo 'webots cloud based'", + "extensions": [], +} \ No newline at end of file diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index f22ce70..bb44f73 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -34,8 +34,8 @@ jobs: echo "WEBOTS_VERSION=${WEBOTS_VERSION}" >> $GITHUB_ENV - name: Build the Docker image run: | - docker build . --file Dockerfile --tag $IMAGE_NAME:$IMAGE_TAG --build-arg WEBOTS_VERSION=$WEBOTS_VERSION --build-arg BASE_IMAGE=${{ matrix.BASE_IMAGE }} --build-arg WEBOTS_PACKAGE_PREFIX=${{ matrix.WEBOTS_PACKAGE_PREFIX }} - docker build . --file Dockerfile_webots_cloud --tag $CLOUD_IMAGE_NAME:$IMAGE_TAG --build-arg WEBOTS_VERSION=$WEBOTS_VERSION --build-arg BASE_IMAGE=$IMAGE_NAME:$IMAGE_TAG + docker build . --file dockerfiles/Dockerfile.nvidia --tag $IMAGE_NAME:$IMAGE_TAG --build-arg WEBOTS_VERSION=$WEBOTS_VERSION --build-arg BASE_IMAGE=${{ matrix.BASE_IMAGE }} --build-arg WEBOTS_PACKAGE_PREFIX=${{ matrix.WEBOTS_PACKAGE_PREFIX }} + docker build . --file dockerfiles/Dockerfile.cloud --tag $CLOUD_IMAGE_NAME:$IMAGE_TAG --build-arg WEBOTS_VERSION=$WEBOTS_VERSION --build-arg BASE_IMAGE=$IMAGE_NAME:$IMAGE_TAG - name: Log into registry run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login --username=${{ secrets.DOCKER_USERNAME }} --password-stdin - name: Push image @@ -77,8 +77,8 @@ jobs: echo "WEBOTS_VERSION=${WEBOTS_VERSION}" >> $GITHUB_ENV - name: Build image run: | - docker build . --file Dockerfile --tag $IMAGE_NAME:$IMAGE_TAG --build-arg WEBOTS_VERSION=$WEBOTS_VERSION --build-arg BASE_IMAGE=${{ matrix.BASE_IMAGE }} --build-arg WEBOTS_PACKAGE_PREFIX=${{ matrix.WEBOTS_PACKAGE_PREFIX }} - docker build . --file Dockerfile_webots_cloud --tag $CLOUD_IMAGE_NAME:$IMAGE_TAG --build-arg WEBOTS_VERSION=$WEBOTS_VERSION --build-arg BASE_IMAGE=$IMAGE_NAME:$IMAGE_TAG + docker build . --file dockerfiles/Dockerfile.nvidia --tag $IMAGE_NAME:$IMAGE_TAG --build-arg WEBOTS_VERSION=$WEBOTS_VERSION --build-arg BASE_IMAGE=${{ matrix.BASE_IMAGE }} --build-arg WEBOTS_PACKAGE_PREFIX=${{ matrix.WEBOTS_PACKAGE_PREFIX }} + docker build . --file dockerfiles/Dockerfile.cloud --tag $CLOUD_IMAGE_NAME:$IMAGE_TAG --build-arg WEBOTS_VERSION=$WEBOTS_VERSION --build-arg BASE_IMAGE=$IMAGE_NAME:$IMAGE_TAG - name: Log into registry run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin - name: Push image diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 11588b9..65064a5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,5 +19,5 @@ jobs: docker-compose --file docker-compose.test.yml build docker-compose --file docker-compose.test.yml run sut else - docker build . --file Dockerfile --build-arg BASE_IMAGE=${{ matrix.BASE_IMAGE }} --build-arg WEBOTS_PACKAGE_PREFIX=${{ matrix.WEBOTS_PACKAGE_PREFIX }} + docker build . --file ./dockerfiles/Dockerfile.nvidia --build-arg BASE_IMAGE=${{ matrix.BASE_IMAGE }} --build-arg WEBOTS_PACKAGE_PREFIX=${{ matrix.WEBOTS_PACKAGE_PREFIX }} fi diff --git a/README.md b/README.md index 40180d6..da0111e 100644 --- a/README.md +++ b/README.md @@ -7,28 +7,43 @@ This repository is used to create a Docker image with Webots already pre-installed. To use the already available image please follow the [Webots installation instructions](https://cyberbotics.com/doc/guide/installation-procedure#installing-the-docker-image). -## Build the Image +## Build the Images Use the following command to build the docker container from the Dockerfile: +### Build with Nvidia + ``` bash -docker build . --file Dockerfile --tag cyberbotics/webots:latest --build-arg WEBOTS_PACKAGE_PREFIX=_ubuntu-22.04 +docker build . --file dockerfiles/Dockerfile.nvidia --tag cyberbotics/webots:latest --build-arg BASE_IMAGE=nvidia/cuda:11.8.0-base-ubuntu22.04 --build-arg WEBOTS_VERSION=R2023b --build-arg WEBOTS_PACKAGE_PREFIX=_ubuntu-22.04 ``` -## Build the Webots.Cloud Images +### Build the Webots.Cloud Images -Use the following command to build the docker container from the Dockerfile_webots_cloud: +Use the following command to build the docker container from the Dockerfile Webots Cloud: ``` bash -docker build . --file Dockerfile_webots_cloud --tag cyberbotics/webots.cloud:latest +docker build . --file dockerfiles/Dockerfile.cloud --tag cyberbotics/webots.cloud:latest --build-arg BASE_IMAGE=cyberbotics/webots:latest --build-arg WEBOTS_VERSION=R2023b + ``` ## Run a Docker container from the Image -You can run the previously built image with: + +### Running Webots in Docker with GPU Support + +``` bash +docker run --gpus=all -it -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix cyberbotics/webots:latest webots --stdout --stderr --batch --mode=realtime +``` +### Running Webots with GPU in Container + +``` bash +docker run --gpus=all -it -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix cyberbotics/webots:latest /bin/bash +``` + +### Running Container ``` bash -docker run -it cyberbotics/webots:latest /bin/bash +docker run -it -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix cyberbotics/webots:latest /bin/bash ``` ## Clean the temporary Images diff --git a/config/Webots-R2023b.conf b/config/Webots-R2023b.conf new file mode 100644 index 0000000..4b7ac5e --- /dev/null +++ b/config/Webots-R2023b.conf @@ -0,0 +1,66 @@ +[Directories] +movies=/root/Videos/ +objects=/root/Documents/ +projects=/root/Documents/ +screenshots=/root/Pictures/ +vrml=/root/Documents/ +www=/root/Documents/ + +[Editor] +font="Monospace, 9" + +[%General] +checkWebotsUpdateOnStartup=true +disableSaveWarning=false +language= +numberOfThreads=8 +pythonCommand=python3 +rendering=true +startupMode=Real-time +telemetry=false +theme=webots_night.qss + +[Internal] +firstLaunch=false + +[Movie] +acceleration=1 +caption=false +quality=90 +resolution=6 + +[Network] +cacheSize=1024 +httpProxyHostName= +httpProxyPassword= +httpProxyPort=0 +httpProxyType=2 +httpProxyUsername= +uploadUrl=https://webots.cloud + +[OpenGL] +GTAO=0 +disableAntiAliasing=true +disableShadows=true +textureFiltering=0 +textureQuality=0 + +[RobotWindow] +browser= +newBrowserWindow=false + +[Sound] +mute=true +volume=80 + +[View3d] +hideAllCameraOverlays=false +hideAllDisplayOverlays=false +hideAllRangeFinderOverlays=false + +[VirtualRealityHeadset] +antiAliasing=false +enable=false +trackOrientation=true +trackPosition=true +visibleEye=left diff --git a/docker-composes/.env b/docker-composes/.env new file mode 100644 index 0000000..49b6780 --- /dev/null +++ b/docker-composes/.env @@ -0,0 +1,2 @@ +WORKSPACE_DIR="/workspace" + diff --git a/docker-composes/docker-compose-gui-nvidia.yml b/docker-composes/docker-compose-gui-nvidia.yml new file mode 100644 index 0000000..9ea97ed --- /dev/null +++ b/docker-composes/docker-compose-gui-nvidia.yml @@ -0,0 +1,10 @@ +version: "3.9" +services: + webots_docker: + extends: + file: docker-compose-gui.yml + service: webots_nvidia + environment: + - NVIDIA_VISIBLE_DEVICES=all + - NVIDIA_DRIVER_CAPABILITIES=all + runtime: nvidia diff --git a/docker-composes/docker-compose-gui.yml b/docker-composes/docker-compose-gui.yml new file mode 100644 index 0000000..77b0540 --- /dev/null +++ b/docker-composes/docker-compose-gui.yml @@ -0,0 +1,22 @@ +version: "3.9" +services: + webots_cloud: + extends: + file: docker-compose.yml + service: webots_cloud + environment: + - DISPLAY=${DISPLAY:-0} + - QT_X11_NO_MITSHM=1 + volumes: + - /tmp/.X11-unix:/tmp/.X11-unix:rw + - /tmp/.docker.xauth:/tmp/.docker.xauth:rw + webots_nvidia: + extends: + file: docker-compose.yml + service: webots_nvidia + environment: + - DISPLAY=${DISPLAY:-0} + - QT_X11_NO_MITSHM=1 + volumes: + - /tmp/.X11-unix:/tmp/.X11-unix:rw + - /tmp/.docker.xauth:/tmp/.docker.xauth:rw diff --git a/docker-composes/docker-compose-nvidia.yml b/docker-composes/docker-compose-nvidia.yml new file mode 100644 index 0000000..8088871 --- /dev/null +++ b/docker-composes/docker-compose-nvidia.yml @@ -0,0 +1,9 @@ +version: "3.9" +services: + webots_docker: + extends: + file: docker-compose.yml + service: webots_nvidia + environment: + - NVIDIA_VISIBLE_DEVICES=all + runtime: nvidia diff --git a/docker-composes/docker-compose.yml b/docker-composes/docker-compose.yml new file mode 100644 index 0000000..9aca517 --- /dev/null +++ b/docker-composes/docker-compose.yml @@ -0,0 +1,45 @@ +version: "3.9" +services: + webots_cloud: + build: + context: .. + dockerfile: dockerfiles/Dockerfile.cloud + # target: dev + args: + - WORKSPACE_DIR=${WORKSPACE_DIR} + - USERNAME=developer + # - USERNAME=${USERNAME:-developer} + - UID=${UID:-1000} + - GID=${UID:-1000} + container_name: webots_cloud + environment: + - ROS_MASTER_URI=http://${ROBOT_IP}:11311 + - ROS_IP=${YOUR_IP} + image: webots_cloud_template:devel + network_mode: "host" + tty: true + volumes: + - ../src:/${WORKSPACE_DIR}/src + - ../config/Webots-R2023b.conf:/Webots-R2023b.conf + webots_nvidia: + build: + context: .. + dockerfile: dockerfiles/Dockerfile.nvidia + # target: dev + args: + - WORKSPACE_DIR=${WORKSPACE_DIR} + - USERNAME=developer + # - USERNAME=${USERNAME:-developer} + - UID=${UID:-1000} + - GID=${UID:-1000} + container_name: webots_cloud + environment: + - ROS_MASTER_URI=http://${ROBOT_IP}:11311 + - ROS_IP=${YOUR_IP} + image: webots_cloud_template:devel + network_mode: "host" + tty: true + volumes: + - ../src:/${WORKSPACE_DIR}/src + - ../config/Webots-R2023b.conf:/Webots-R2023b.conf + diff --git a/Dockerfile_webots_cloud b/dockerfiles/Dockerfile.cloud similarity index 100% rename from Dockerfile_webots_cloud rename to dockerfiles/Dockerfile.cloud diff --git a/Dockerfile_ikpy b/dockerfiles/Dockerfile.ikpy similarity index 100% rename from Dockerfile_ikpy rename to dockerfiles/Dockerfile.ikpy diff --git a/Dockerfile b/dockerfiles/Dockerfile.nvidia similarity index 100% rename from Dockerfile rename to dockerfiles/Dockerfile.nvidia diff --git a/dockerfiles/Webots-R2023b.conf b/dockerfiles/Webots-R2023b.conf new file mode 100644 index 0000000..4b7ac5e --- /dev/null +++ b/dockerfiles/Webots-R2023b.conf @@ -0,0 +1,66 @@ +[Directories] +movies=/root/Videos/ +objects=/root/Documents/ +projects=/root/Documents/ +screenshots=/root/Pictures/ +vrml=/root/Documents/ +www=/root/Documents/ + +[Editor] +font="Monospace, 9" + +[%General] +checkWebotsUpdateOnStartup=true +disableSaveWarning=false +language= +numberOfThreads=8 +pythonCommand=python3 +rendering=true +startupMode=Real-time +telemetry=false +theme=webots_night.qss + +[Internal] +firstLaunch=false + +[Movie] +acceleration=1 +caption=false +quality=90 +resolution=6 + +[Network] +cacheSize=1024 +httpProxyHostName= +httpProxyPassword= +httpProxyPort=0 +httpProxyType=2 +httpProxyUsername= +uploadUrl=https://webots.cloud + +[OpenGL] +GTAO=0 +disableAntiAliasing=true +disableShadows=true +textureFiltering=0 +textureQuality=0 + +[RobotWindow] +browser= +newBrowserWindow=false + +[Sound] +mute=true +volume=80 + +[View3d] +hideAllCameraOverlays=false +hideAllDisplayOverlays=false +hideAllRangeFinderOverlays=false + +[VirtualRealityHeadset] +antiAliasing=false +enable=false +trackOrientation=true +trackPosition=true +visibleEye=left