From b48e0cef845c782326db5142ea7de6e108805228 Mon Sep 17 00:00:00 2001 From: Jesse Williamson Date: Fri, 24 Mar 2023 09:21:27 +1100 Subject: [PATCH 1/9] Adds a dockerfile for webots with nuwebots and robocup environments --- webots-docker/Dockerfile | 63 ++++++++++++++++++++++++++++++++++ webots-docker/dependencies.sh | 3 ++ webots-docker/docker-config.py | 17 +++++++++ 3 files changed, 83 insertions(+) create mode 100644 webots-docker/Dockerfile create mode 100644 webots-docker/dependencies.sh create mode 100644 webots-docker/docker-config.py diff --git a/webots-docker/Dockerfile b/webots-docker/Dockerfile new file mode 100644 index 000000000..50b41d994 --- /dev/null +++ b/webots-docker/Dockerfile @@ -0,0 +1,63 @@ +ARG BASE_IMAGE=nvidia/cuda:11.8.0-base-ubuntu22.04 +FROM ${BASE_IMAGE} AS downloader + +# Determine Webots version to be used and set default argument +ARG WEBOTS_VERSION=R2022b +ARG WEBOTS_PACKAGE_PREFIX= + +# Disable dpkg/gdebi interactive dialogs +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update && apt-get install --yes wget bzip2 && rm -rf /var/lib/apt/lists/ && \ + wget https://github.com/cyberbotics/webots/releases/download/$WEBOTS_VERSION/webots-$WEBOTS_VERSION-x86-64$WEBOTS_PACKAGE_PREFIX.tar.bz2 && \ + tar xjf webots-*.tar.bz2 && rm webots-*.tar.bz2 + +FROM ${BASE_IMAGE} + +# Disable dpkg/gdebi interactive dialogs +ENV DEBIAN_FRONTEND=noninteractive + + +# Install Webots runtime dependencies +RUN apt-get update && apt-get install --yes wget xvfb git python3-pip sudo && rm -rf /var/lib/apt/lists/ && \ + wget https://raw.githubusercontent.com/cyberbotics/webots/master/scripts/install/linux_runtime_dependencies.sh && \ + chmod +x linux_runtime_dependencies.sh && ./linux_runtime_dependencies.sh && rm ./linux_runtime_dependencies.sh + +# Install NUWebots dependencies +RUN wget https://raw.githubusercontent.com/NUbots/NUWebots/main/webots-docker/dependencies.sh && \ + chmod +x dependencies.sh && ./dependencies.sh && rm ./dependencies.sh && rm -rf /var/lib/apt/lists/ + +# Install Webots +WORKDIR /usr/local +COPY --from=downloader /webots /usr/local/webots/ +ENV QTWEBENGINE_DISABLE_SANDBOX=1 +ENV WEBOTS_HOME /usr/local/webots +ENV PATH /usr/local/webots:${PATH} + +# Enable OpenGL capabilities +ENV NVIDIA_DRIVER_CAPABILITIES=graphics + +RUN useradd -ms /bin/bash webots && usermod -aG sudo webots && echo "webots ALL=(ALL:ALL) NOPASSWD: ALL" >> /etc/sudoers +ENV HOME=/home/webots +USER webots + +WORKDIR $HOME + +# Build the latest version of the RoboCup Humanoid TC fork of GameController +RUN git clone https://github.com/RoboCup-Humanoid-TC/GameController ./GameController && cd GameController && ant + +# Build the robocup controllers +RUN git clone https://github.com/RoboCup-Humanoid-TC/hlvs_webots.git ./hlvs_webots && \ + pip3 install -r ./hlvs_webots/controllers/referee/requirements.txt && make -j$(nproc) -C ./hlvs_webots + +# Set environment variables for GameController +ENV GAME_CONTROLLER_HOME=${HOME}/GameController JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64 + +# Install the NUbots-developed environment +RUN git clone https://github.com/NUbots/NUWebots.git ./NUWebots && cd ./NUWebots && pip3 install -r ./requirements.txt && \ + ./b configure -- -DENABLE_CLANG_TIDY=OFF && ./b build + +RUN wget https://raw.githubusercontent.com/NUbots/NUWebots/main/webots-docker/docker-config.py + +# Configure robocup game.json file based on environment variables +CMD ["/bin/bash", "-c", "python3 docker-config.py ${HOME}/hlvs_webots/controllers/referee/game.json;rm docker-config.py;bash"] diff --git a/webots-docker/dependencies.sh b/webots-docker/dependencies.sh new file mode 100644 index 000000000..a1b5e09c8 --- /dev/null +++ b/webots-docker/dependencies.sh @@ -0,0 +1,3 @@ +#!/bin/bash +apt-get update +apt-get install -y ant cmake-curses-gui libprotobuf-dev protobuf-compiler libeigen3-dev libyaml-cpp-dev ninja-build clang-tidy python3-dev libjpeg9-dev diff --git a/webots-docker/docker-config.py b/webots-docker/docker-config.py new file mode 100644 index 000000000..4820a1ca1 --- /dev/null +++ b/webots-docker/docker-config.py @@ -0,0 +1,17 @@ +import json, os, sys + +TEAM_NAME = os.environ.get('TEAM_NAME') +ROBOT_HOST = os.environ.get('ROBOT_HOST') + +print(type(ROBOT_HOST)) + +filename = sys.argv[1] + +with open(filename, 'r') as f: + game_config = json.load(f) + +if TEAM_NAME: game_config['red']['config'] = TEAM_NAME + '.json' +if ROBOT_HOST: game_config['red']['hosts'].append(ROBOT_HOST) + +with open(filename, 'w') as f: + json.dump(game_config, f, indent=2) From 2bb5411d0e2b5944fa35cf981bd09e39318d5a28 Mon Sep 17 00:00:00 2001 From: Jesse Williamson Date: Wed, 12 Apr 2023 15:13:42 +1000 Subject: [PATCH 2/9] Add basic utilities to dependencies install script --- webots-docker/dependencies.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webots-docker/dependencies.sh b/webots-docker/dependencies.sh index a1b5e09c8..4cb4d3cab 100644 --- a/webots-docker/dependencies.sh +++ b/webots-docker/dependencies.sh @@ -1,3 +1,3 @@ #!/bin/bash apt-get update -apt-get install -y ant cmake-curses-gui libprotobuf-dev protobuf-compiler libeigen3-dev libyaml-cpp-dev ninja-build clang-tidy python3-dev libjpeg9-dev +apt-get install -y ant cmake-curses-gui libprotobuf-dev protobuf-compiler libeigen3-dev libyaml-cpp-dev ninja-build clang-tidy python3-dev libjpeg9-dev sudo vim nano From d9affbda583bbbbc88792dc3fb5faed93bcd750a Mon Sep 17 00:00:00 2001 From: Jesse Williamson Date: Sun, 16 Apr 2023 15:22:56 +1000 Subject: [PATCH 3/9] Replace CMD with entrypoint script --- webots-docker/Dockerfile | 9 ++++++--- webots-docker/entrypoint.sh | 5 +++++ 2 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 webots-docker/entrypoint.sh diff --git a/webots-docker/Dockerfile b/webots-docker/Dockerfile index 50b41d994..972b95129 100644 --- a/webots-docker/Dockerfile +++ b/webots-docker/Dockerfile @@ -56,8 +56,11 @@ ENV GAME_CONTROLLER_HOME=${HOME}/GameController JAVA_HOME=/usr/lib/jvm/java-11-o # Install the NUbots-developed environment RUN git clone https://github.com/NUbots/NUWebots.git ./NUWebots && cd ./NUWebots && pip3 install -r ./requirements.txt && \ ./b configure -- -DENABLE_CLANG_TIDY=OFF && ./b build - -RUN wget https://raw.githubusercontent.com/NUbots/NUWebots/main/webots-docker/docker-config.py + +RUN wget https://raw.githubusercontent.com/NUbots/NUWebots/main/webots-docker/docker-config.py && \ + wget https://raw.githubusercontent.com/NUbots/NUWebots/main/webots-docker/entrypoint.sh && \ + chmod +x entrypoint.sh # Configure robocup game.json file based on environment variables -CMD ["/bin/bash", "-c", "python3 docker-config.py ${HOME}/hlvs_webots/controllers/referee/game.json;rm docker-config.py;bash"] +ENTRYPOINT ["./entrypoint.sh"] +CMD ["bash"] diff --git a/webots-docker/entrypoint.sh b/webots-docker/entrypoint.sh new file mode 100644 index 000000000..ccfe28bd7 --- /dev/null +++ b/webots-docker/entrypoint.sh @@ -0,0 +1,5 @@ +#!/bin/bash +python3 docker-config.py ${HOME}/hlvs_webots/controllers/referee/game.json +rm docker-config.py +# Run the command given by CMD or docker run parameter, replacing current process +exec "$@" From 5bae41f71b4a285269c3073a91fc6b731c03eb90 Mon Sep 17 00:00:00 2001 From: Jesse Williamson Date: Mon, 17 Apr 2023 13:07:39 +1000 Subject: [PATCH 4/9] Allow comma separated addresses in run command and add teams/ prefix --- webots-docker/Dockerfile | 2 +- webots-docker/{docker-config.py => webots-config.py} | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) rename webots-docker/{docker-config.py => webots-config.py} (53%) diff --git a/webots-docker/Dockerfile b/webots-docker/Dockerfile index 972b95129..635f25b09 100644 --- a/webots-docker/Dockerfile +++ b/webots-docker/Dockerfile @@ -57,7 +57,7 @@ ENV GAME_CONTROLLER_HOME=${HOME}/GameController JAVA_HOME=/usr/lib/jvm/java-11-o RUN git clone https://github.com/NUbots/NUWebots.git ./NUWebots && cd ./NUWebots && pip3 install -r ./requirements.txt && \ ./b configure -- -DENABLE_CLANG_TIDY=OFF && ./b build -RUN wget https://raw.githubusercontent.com/NUbots/NUWebots/main/webots-docker/docker-config.py && \ +RUN wget https://raw.githubusercontent.com/NUbots/NUWebots/main/webots-docker/webots-config.py && \ wget https://raw.githubusercontent.com/NUbots/NUWebots/main/webots-docker/entrypoint.sh && \ chmod +x entrypoint.sh diff --git a/webots-docker/docker-config.py b/webots-docker/webots-config.py similarity index 53% rename from webots-docker/docker-config.py rename to webots-docker/webots-config.py index 4820a1ca1..19527ac68 100644 --- a/webots-docker/docker-config.py +++ b/webots-docker/webots-config.py @@ -1,17 +1,15 @@ import json, os, sys TEAM_NAME = os.environ.get('TEAM_NAME') -ROBOT_HOST = os.environ.get('ROBOT_HOST') - -print(type(ROBOT_HOST)) +ROBOT_HOSTS = os.environ.get('ROBOT_HOSTS') filename = sys.argv[1] with open(filename, 'r') as f: game_config = json.load(f) -if TEAM_NAME: game_config['red']['config'] = TEAM_NAME + '.json' -if ROBOT_HOST: game_config['red']['hosts'].append(ROBOT_HOST) +if TEAM_NAME: game_config['red']['config'] = 'teams/' + TEAM_NAME + '.json' +if ROBOT_HOSTS: game_config['red']['hosts'] += ROBOT_HOSTS.split(",") with open(filename, 'w') as f: json.dump(game_config, f, indent=2) From e3d47dc7b94206076cf26c5166757a32b8da9ef1 Mon Sep 17 00:00:00 2001 From: Jesse Williamson Date: Thu, 14 Sep 2023 21:12:30 +1000 Subject: [PATCH 5/9] Formatting, remove user, don't remove config script after running --- webots-docker/Dockerfile | 66 ++++++++++++++++++++++------------ webots-docker/entrypoint.sh | 3 +- webots-docker/webots-config.py | 18 ++++++---- 3 files changed, 56 insertions(+), 31 deletions(-) diff --git a/webots-docker/Dockerfile b/webots-docker/Dockerfile index 635f25b09..da0c3d9ee 100644 --- a/webots-docker/Dockerfile +++ b/webots-docker/Dockerfile @@ -8,9 +8,15 @@ ARG WEBOTS_PACKAGE_PREFIX= # Disable dpkg/gdebi interactive dialogs ENV DEBIAN_FRONTEND=noninteractive -RUN apt-get update && apt-get install --yes wget bzip2 && rm -rf /var/lib/apt/lists/ && \ - wget https://github.com/cyberbotics/webots/releases/download/$WEBOTS_VERSION/webots-$WEBOTS_VERSION-x86-64$WEBOTS_PACKAGE_PREFIX.tar.bz2 && \ - tar xjf webots-*.tar.bz2 && rm webots-*.tar.bz2 +RUN apt-get update +RUN apt-get install --yes \ + wget\ + bzip2 + +RUN rm -rf /var/lib/apt/lists/ +RUN wget https://github.com/cyberbotics/webots/releases/download/$WEBOTS_VERSION/webots-$WEBOTS_VERSION-x86-64$WEBOTS_PACKAGE_PREFIX.tar.bz2 +RUN tar xjf webots-*.tar.bz2 +RUN rm webots-*.tar.bz2 FROM ${BASE_IMAGE} @@ -19,13 +25,25 @@ ENV DEBIAN_FRONTEND=noninteractive # Install Webots runtime dependencies -RUN apt-get update && apt-get install --yes wget xvfb git python3-pip sudo && rm -rf /var/lib/apt/lists/ && \ - wget https://raw.githubusercontent.com/cyberbotics/webots/master/scripts/install/linux_runtime_dependencies.sh && \ - chmod +x linux_runtime_dependencies.sh && ./linux_runtime_dependencies.sh && rm ./linux_runtime_dependencies.sh +RUN apt-get update +RUN apt-get install --yes \ + wget \ + xvfb \ + git \ + python3-pip + +RUN rm -rf /var/lib/apt/lists/ +RUN wget https://raw.githubusercontent.com/cyberbotics/webots/master/scripts/install/linux_runtime_dependencies.sh +RUN chmod +x linux_runtime_dependencies.sh +RUN ./linux_runtime_dependencies.sh +RUN rm ./linux_runtime_dependencies.sh # Install NUWebots dependencies -RUN wget https://raw.githubusercontent.com/NUbots/NUWebots/main/webots-docker/dependencies.sh && \ - chmod +x dependencies.sh && ./dependencies.sh && rm ./dependencies.sh && rm -rf /var/lib/apt/lists/ +RUN wget https://raw.githubusercontent.com/NUbots/NUWebots/williamson/webots-docker/webots-docker/dependencies.sh +RUN chmod +x dependencies.sh +RUN ./dependencies.sh +RUN rm ./dependencies.sh +RUN rm -rf /var/lib/apt/lists/ # Install Webots WORKDIR /usr/local @@ -37,29 +55,33 @@ ENV PATH /usr/local/webots:${PATH} # Enable OpenGL capabilities ENV NVIDIA_DRIVER_CAPABILITIES=graphics -RUN useradd -ms /bin/bash webots && usermod -aG sudo webots && echo "webots ALL=(ALL:ALL) NOPASSWD: ALL" >> /etc/sudoers -ENV HOME=/home/webots -USER webots +# RUN useradd -ms /bin/bash webots && usermod -aG sudo webots && echo "webots ALL=(ALL:ALL) NOPASSWD: ALL" >> /etc/sudoers +# ENV HOME=/home/webots +# USER webots -WORKDIR $HOME +# WORKDIR $HOME # Build the latest version of the RoboCup Humanoid TC fork of GameController -RUN git clone https://github.com/RoboCup-Humanoid-TC/GameController ./GameController && cd GameController && ant +RUN git clone https://github.com/RoboCup-Humanoid-TC/GameController ./GameController +RUN cd GameController && ant # Build the robocup controllers -RUN git clone https://github.com/RoboCup-Humanoid-TC/hlvs_webots.git ./hlvs_webots && \ - pip3 install -r ./hlvs_webots/controllers/referee/requirements.txt && make -j$(nproc) -C ./hlvs_webots +RUN git clone https://github.com/RoboCup-Humanoid-TC/hlvs_webots.git ./hlvs_webots +RUN pip3 install -r ./hlvs_webots/controllers/referee/requirements.txt +RUN make -j$(nproc) -C ./hlvs_webots # Set environment variables for GameController -ENV GAME_CONTROLLER_HOME=${HOME}/GameController JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64 +ENV GAME_CONTROLLER_HOME=/GameController JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64 # Install the NUbots-developed environment -RUN git clone https://github.com/NUbots/NUWebots.git ./NUWebots && cd ./NUWebots && pip3 install -r ./requirements.txt && \ - ./b configure -- -DENABLE_CLANG_TIDY=OFF && ./b build - -RUN wget https://raw.githubusercontent.com/NUbots/NUWebots/main/webots-docker/webots-config.py && \ - wget https://raw.githubusercontent.com/NUbots/NUWebots/main/webots-docker/entrypoint.sh && \ - chmod +x entrypoint.sh +RUN git clone https://github.com/NUbots/NUWebots /NUWebots +RUN pip3 install -r /NUWebots/requirements.txt +RUN /NUWebots/b configure -- -DENABLE_CLANG_TIDY=OFF +RUN /NUWebots/b build + +RUN wget https://raw.githubusercontent.com/NUbots/NUWebots/williamson/webots-docker/webots-docker/entrypoint.sh +RUN wget https://raw.githubusercontent.com/NUbots/NUWebots/williamson/webots-docker/webots-docker/webots-config.py +RUN chmod +x entrypoint.sh # Configure robocup game.json file based on environment variables ENTRYPOINT ["./entrypoint.sh"] diff --git a/webots-docker/entrypoint.sh b/webots-docker/entrypoint.sh index ccfe28bd7..9257d0c1b 100644 --- a/webots-docker/entrypoint.sh +++ b/webots-docker/entrypoint.sh @@ -1,5 +1,4 @@ #!/bin/bash -python3 docker-config.py ${HOME}/hlvs_webots/controllers/referee/game.json -rm docker-config.py +python3 webots-config.py /hlvs_webots/controllers/referee/game.json # Run the command given by CMD or docker run parameter, replacing current process exec "$@" diff --git a/webots-docker/webots-config.py b/webots-docker/webots-config.py index 19527ac68..d5c4d81a9 100644 --- a/webots-docker/webots-config.py +++ b/webots-docker/webots-config.py @@ -1,15 +1,19 @@ -import json, os, sys +import json +import os +import sys -TEAM_NAME = os.environ.get('TEAM_NAME') -ROBOT_HOSTS = os.environ.get('ROBOT_HOSTS') +TEAM_NAME = os.environ.get("TEAM_NAME") +ROBOT_HOSTS = os.environ.get("ROBOT_HOSTS") filename = sys.argv[1] -with open(filename, 'r') as f: +with open(filename, "r") as f: game_config = json.load(f) -if TEAM_NAME: game_config['red']['config'] = 'teams/' + TEAM_NAME + '.json' -if ROBOT_HOSTS: game_config['red']['hosts'] += ROBOT_HOSTS.split(",") +if TEAM_NAME: + game_config["red"]["config"] = "teams/" + TEAM_NAME + ".json" +if ROBOT_HOSTS: + game_config["red"]["hosts"] += ROBOT_HOSTS.split(",") -with open(filename, 'w') as f: +with open(filename, "w") as f: json.dump(game_config, f, indent=2) From 208b98d6bdbcf9b8cdeed5ceec0af90a66317ff5 Mon Sep 17 00:00:00 2001 From: Jesse Williamson Date: Thu, 14 Sep 2023 21:30:12 +1000 Subject: [PATCH 6/9] Update Dockerfile --- webots-docker/Dockerfile | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/webots-docker/Dockerfile b/webots-docker/Dockerfile index da0c3d9ee..f6f267ec2 100644 --- a/webots-docker/Dockerfile +++ b/webots-docker/Dockerfile @@ -2,7 +2,7 @@ ARG BASE_IMAGE=nvidia/cuda:11.8.0-base-ubuntu22.04 FROM ${BASE_IMAGE} AS downloader # Determine Webots version to be used and set default argument -ARG WEBOTS_VERSION=R2022b +ARG WEBOTS_VERSION=R2023b ARG WEBOTS_PACKAGE_PREFIX= # Disable dpkg/gdebi interactive dialogs @@ -23,15 +23,13 @@ FROM ${BASE_IMAGE} # Disable dpkg/gdebi interactive dialogs ENV DEBIAN_FRONTEND=noninteractive - # Install Webots runtime dependencies RUN apt-get update RUN apt-get install --yes \ wget \ xvfb \ - git \ - python3-pip - + locales \ + RUN rm -rf /var/lib/apt/lists/ RUN wget https://raw.githubusercontent.com/cyberbotics/webots/master/scripts/install/linux_runtime_dependencies.sh RUN chmod +x linux_runtime_dependencies.sh @@ -53,17 +51,17 @@ ENV WEBOTS_HOME /usr/local/webots ENV PATH /usr/local/webots:${PATH} # Enable OpenGL capabilities -ENV NVIDIA_DRIVER_CAPABILITIES=graphics +ENV NVIDIA_DRIVER_CAPABILITIES=graphics,compute,utility -# RUN useradd -ms /bin/bash webots && usermod -aG sudo webots && echo "webots ALL=(ALL:ALL) NOPASSWD: ALL" >> /etc/sudoers -# ENV HOME=/home/webots -# USER webots - -# WORKDIR $HOME +# Install dependencies for setting up GameController and NUbots code +RUN apt-get install --yes \ + git \ + python3-pip # Build the latest version of the RoboCup Humanoid TC fork of GameController RUN git clone https://github.com/RoboCup-Humanoid-TC/GameController ./GameController -RUN cd GameController && ant +RUN cd GameController +RUN ant # Build the robocup controllers RUN git clone https://github.com/RoboCup-Humanoid-TC/hlvs_webots.git ./hlvs_webots From 53b700b8f2cff25690b56ec85eb76342d96ba35c Mon Sep 17 00:00:00 2001 From: Jesse Williamson Date: Thu, 14 Sep 2023 23:04:08 +1000 Subject: [PATCH 7/9] fix ant gamecontroller build, fix package installs --- webots-docker/Dockerfile | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/webots-docker/Dockerfile b/webots-docker/Dockerfile index f6f267ec2..0a838ebdd 100644 --- a/webots-docker/Dockerfile +++ b/webots-docker/Dockerfile @@ -28,9 +28,8 @@ RUN apt-get update RUN apt-get install --yes \ wget \ xvfb \ - locales \ + locales -RUN rm -rf /var/lib/apt/lists/ RUN wget https://raw.githubusercontent.com/cyberbotics/webots/master/scripts/install/linux_runtime_dependencies.sh RUN chmod +x linux_runtime_dependencies.sh RUN ./linux_runtime_dependencies.sh @@ -41,7 +40,6 @@ RUN wget https://raw.githubusercontent.com/NUbots/NUWebots/williamson/webots-doc RUN chmod +x dependencies.sh RUN ./dependencies.sh RUN rm ./dependencies.sh -RUN rm -rf /var/lib/apt/lists/ # Install Webots WORKDIR /usr/local @@ -54,14 +52,15 @@ ENV PATH /usr/local/webots:${PATH} ENV NVIDIA_DRIVER_CAPABILITIES=graphics,compute,utility # Install dependencies for setting up GameController and NUbots code +RUN apt-get update RUN apt-get install --yes \ git \ python3-pip +RUN rm -rf /var/lib/apt/lists/ # Build the latest version of the RoboCup Humanoid TC fork of GameController -RUN git clone https://github.com/RoboCup-Humanoid-TC/GameController ./GameController -RUN cd GameController -RUN ant +RUN git clone https://github.com/RoboCup-Humanoid-TC/GameController /GameController +RUN ant -buildfile /GameController/build.xml # Build the robocup controllers RUN git clone https://github.com/RoboCup-Humanoid-TC/hlvs_webots.git ./hlvs_webots From 3d75850a43d9bebace9ab0000932a63bc02b271b Mon Sep 17 00:00:00 2001 From: Jesse Williamson Date: Thu, 14 Sep 2023 23:45:12 +1000 Subject: [PATCH 8/9] change hlvs_webots location and remove working directory change --- webots-docker/Dockerfile | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/webots-docker/Dockerfile b/webots-docker/Dockerfile index 0a838ebdd..bfcf64de1 100644 --- a/webots-docker/Dockerfile +++ b/webots-docker/Dockerfile @@ -42,7 +42,6 @@ RUN ./dependencies.sh RUN rm ./dependencies.sh # Install Webots -WORKDIR /usr/local COPY --from=downloader /webots /usr/local/webots/ ENV QTWEBENGINE_DISABLE_SANDBOX=1 ENV WEBOTS_HOME /usr/local/webots @@ -63,9 +62,9 @@ RUN git clone https://github.com/RoboCup-Humanoid-TC/GameController /GameControl RUN ant -buildfile /GameController/build.xml # Build the robocup controllers -RUN git clone https://github.com/RoboCup-Humanoid-TC/hlvs_webots.git ./hlvs_webots -RUN pip3 install -r ./hlvs_webots/controllers/referee/requirements.txt -RUN make -j$(nproc) -C ./hlvs_webots +RUN git clone https://github.com/RoboCup-Humanoid-TC/hlvs_webots.git /hlvs_webots +RUN pip3 install -r /hlvs_webots/controllers/referee/requirements.txt +RUN make -j$(nproc) -C /hlvs_webots # Set environment variables for GameController ENV GAME_CONTROLLER_HOME=/GameController JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64 From 5a27f90c59cb7d9af803fa84f20aa573716cc911 Mon Sep 17 00:00:00 2001 From: Jesse Williamson Date: Thu, 21 Sep 2023 14:08:31 +1000 Subject: [PATCH 9/9] Copy scripts instead of downloading from repo, clean up user setup --- webots-docker/Dockerfile | 57 ++++++++++++++++++++++------------- webots-docker/dependencies.sh | 3 -- webots-docker/entrypoint.sh | 3 +- 3 files changed, 38 insertions(+), 25 deletions(-) delete mode 100644 webots-docker/dependencies.sh diff --git a/webots-docker/Dockerfile b/webots-docker/Dockerfile index bfcf64de1..274cc8e8e 100644 --- a/webots-docker/Dockerfile +++ b/webots-docker/Dockerfile @@ -29,17 +29,15 @@ RUN apt-get install --yes \ wget \ xvfb \ locales - RUN wget https://raw.githubusercontent.com/cyberbotics/webots/master/scripts/install/linux_runtime_dependencies.sh RUN chmod +x linux_runtime_dependencies.sh RUN ./linux_runtime_dependencies.sh RUN rm ./linux_runtime_dependencies.sh -# Install NUWebots dependencies -RUN wget https://raw.githubusercontent.com/NUbots/NUWebots/williamson/webots-docker/webots-docker/dependencies.sh -RUN chmod +x dependencies.sh -RUN ./dependencies.sh -RUN rm ./dependencies.sh +# Webots complains if run by root +RUN useradd webots +ENV HOME=/home/webots +WORKDIR ${HOME} # Install Webots COPY --from=downloader /webots /usr/local/webots/ @@ -50,35 +48,52 @@ ENV PATH /usr/local/webots:${PATH} # Enable OpenGL capabilities ENV NVIDIA_DRIVER_CAPABILITIES=graphics,compute,utility -# Install dependencies for setting up GameController and NUbots code +# Dependencies for building NUbots and Robocup code RUN apt-get update RUN apt-get install --yes \ + ant \ + cmake-curses-gui \ + libprotobuf-dev \ + protobuf-compiler \ + libeigen3-dev \ + libyaml-cpp-dev \ + ninja-build \ + clang-tidy \ + python3-dev \ + libjpeg9-dev \ git \ - python3-pip + python3-pip \ + vim \ + nano + RUN rm -rf /var/lib/apt/lists/ # Build the latest version of the RoboCup Humanoid TC fork of GameController -RUN git clone https://github.com/RoboCup-Humanoid-TC/GameController /GameController -RUN ant -buildfile /GameController/build.xml +RUN git clone https://github.com/RoboCup-Humanoid-TC/GameController ./GameController +RUN ant -buildfile ./GameController/build.xml # Build the robocup controllers -RUN git clone https://github.com/RoboCup-Humanoid-TC/hlvs_webots.git /hlvs_webots -RUN pip3 install -r /hlvs_webots/controllers/referee/requirements.txt -RUN make -j$(nproc) -C /hlvs_webots +RUN git clone https://github.com/RoboCup-Humanoid-TC/hlvs_webots.git ./hlvs_webots +RUN pip3 install -r ./hlvs_webots/controllers/referee/requirements.txt +RUN make -j$(nproc) -C ./hlvs_webots # Set environment variables for GameController -ENV GAME_CONTROLLER_HOME=/GameController JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64 +ENV GAME_CONTROLLER_HOME=./GameController JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64 # Install the NUbots-developed environment -RUN git clone https://github.com/NUbots/NUWebots /NUWebots -RUN pip3 install -r /NUWebots/requirements.txt -RUN /NUWebots/b configure -- -DENABLE_CLANG_TIDY=OFF -RUN /NUWebots/b build +RUN git clone https://github.com/NUbots/NUWebots ./NUWebots +RUN pip3 install -r ./NUWebots/requirements.txt +RUN ./NUWebots/b configure -- -DENABLE_CLANG_TIDY=OFF +RUN ./NUWebots/b build -RUN wget https://raw.githubusercontent.com/NUbots/NUWebots/williamson/webots-docker/webots-docker/entrypoint.sh -RUN wget https://raw.githubusercontent.com/NUbots/NUWebots/williamson/webots-docker/webots-docker/webots-config.py +COPY entrypoint.sh ./entrypoint.sh +COPY webots-config.py ./webots-config.py RUN chmod +x entrypoint.sh +RUN chown -R webots:webots /home/webots +USER webots +ENV USER=webots + # Configure robocup game.json file based on environment variables ENTRYPOINT ["./entrypoint.sh"] -CMD ["bash"] +CMD ["bash", "-i"] diff --git a/webots-docker/dependencies.sh b/webots-docker/dependencies.sh deleted file mode 100644 index 4cb4d3cab..000000000 --- a/webots-docker/dependencies.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -apt-get update -apt-get install -y ant cmake-curses-gui libprotobuf-dev protobuf-compiler libeigen3-dev libyaml-cpp-dev ninja-build clang-tidy python3-dev libjpeg9-dev sudo vim nano diff --git a/webots-docker/entrypoint.sh b/webots-docker/entrypoint.sh index 9257d0c1b..c3352edfb 100644 --- a/webots-docker/entrypoint.sh +++ b/webots-docker/entrypoint.sh @@ -1,4 +1,5 @@ #!/bin/bash -python3 webots-config.py /hlvs_webots/controllers/referee/game.json + +python3 webots-config.py /home/webots/hlvs_webots/controllers/referee/game.json # Run the command given by CMD or docker run parameter, replacing current process exec "$@"