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

Preparation of an infrastructure that can work in Webots devcontainer #39

Open
wants to merge 4 commits 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
15 changes: 15 additions & 0 deletions .devcontainer/cloud/devcontainer.json
Original file line number Diff line number Diff line change
@@ -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": [],
}
15 changes: 15 additions & 0 deletions .devcontainer/nvidia/devcontainer.json
Original file line number Diff line number Diff line change
@@ -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": [],
}
8 changes: 4 additions & 4 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
29 changes: 22 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
66 changes: 66 additions & 0 deletions config/Webots-R2023b.conf
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions docker-composes/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
WORKSPACE_DIR="/workspace"

10 changes: 10 additions & 0 deletions docker-composes/docker-compose-gui-nvidia.yml
Original file line number Diff line number Diff line change
@@ -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
22 changes: 22 additions & 0 deletions docker-composes/docker-compose-gui.yml
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions docker-composes/docker-compose-nvidia.yml
Original file line number Diff line number Diff line change
@@ -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
45 changes: 45 additions & 0 deletions docker-composes/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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

File renamed without changes.
File renamed without changes.
File renamed without changes.
66 changes: 66 additions & 0 deletions dockerfiles/Webots-R2023b.conf
Original file line number Diff line number Diff line change
@@ -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