Skip to content

Commit e3d47dc

Browse files
Formatting, remove user, don't remove config script after running
1 parent 5bae41f commit e3d47dc

File tree

3 files changed

+56
-31
lines changed

3 files changed

+56
-31
lines changed

webots-docker/Dockerfile

+44-22
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,15 @@ ARG WEBOTS_PACKAGE_PREFIX=
88
# Disable dpkg/gdebi interactive dialogs
99
ENV DEBIAN_FRONTEND=noninteractive
1010

11-
RUN apt-get update && apt-get install --yes wget bzip2 && rm -rf /var/lib/apt/lists/ && \
12-
wget https://github.com/cyberbotics/webots/releases/download/$WEBOTS_VERSION/webots-$WEBOTS_VERSION-x86-64$WEBOTS_PACKAGE_PREFIX.tar.bz2 && \
13-
tar xjf webots-*.tar.bz2 && rm webots-*.tar.bz2
11+
RUN apt-get update
12+
RUN apt-get install --yes \
13+
wget\
14+
bzip2
15+
16+
RUN rm -rf /var/lib/apt/lists/
17+
RUN wget https://github.com/cyberbotics/webots/releases/download/$WEBOTS_VERSION/webots-$WEBOTS_VERSION-x86-64$WEBOTS_PACKAGE_PREFIX.tar.bz2
18+
RUN tar xjf webots-*.tar.bz2
19+
RUN rm webots-*.tar.bz2
1420

1521
FROM ${BASE_IMAGE}
1622

@@ -19,13 +25,25 @@ ENV DEBIAN_FRONTEND=noninteractive
1925

2026

2127
# Install Webots runtime dependencies
22-
RUN apt-get update && apt-get install --yes wget xvfb git python3-pip sudo && rm -rf /var/lib/apt/lists/ && \
23-
wget https://raw.githubusercontent.com/cyberbotics/webots/master/scripts/install/linux_runtime_dependencies.sh && \
24-
chmod +x linux_runtime_dependencies.sh && ./linux_runtime_dependencies.sh && rm ./linux_runtime_dependencies.sh
28+
RUN apt-get update
29+
RUN apt-get install --yes \
30+
wget \
31+
xvfb \
32+
git \
33+
python3-pip
34+
35+
RUN rm -rf /var/lib/apt/lists/
36+
RUN wget https://raw.githubusercontent.com/cyberbotics/webots/master/scripts/install/linux_runtime_dependencies.sh
37+
RUN chmod +x linux_runtime_dependencies.sh
38+
RUN ./linux_runtime_dependencies.sh
39+
RUN rm ./linux_runtime_dependencies.sh
2540

2641
# Install NUWebots dependencies
27-
RUN wget https://raw.githubusercontent.com/NUbots/NUWebots/main/webots-docker/dependencies.sh && \
28-
chmod +x dependencies.sh && ./dependencies.sh && rm ./dependencies.sh && rm -rf /var/lib/apt/lists/
42+
RUN wget https://raw.githubusercontent.com/NUbots/NUWebots/williamson/webots-docker/webots-docker/dependencies.sh
43+
RUN chmod +x dependencies.sh
44+
RUN ./dependencies.sh
45+
RUN rm ./dependencies.sh
46+
RUN rm -rf /var/lib/apt/lists/
2947

3048
# Install Webots
3149
WORKDIR /usr/local
@@ -37,29 +55,33 @@ ENV PATH /usr/local/webots:${PATH}
3755
# Enable OpenGL capabilities
3856
ENV NVIDIA_DRIVER_CAPABILITIES=graphics
3957

40-
RUN useradd -ms /bin/bash webots && usermod -aG sudo webots && echo "webots ALL=(ALL:ALL) NOPASSWD: ALL" >> /etc/sudoers
41-
ENV HOME=/home/webots
42-
USER webots
58+
# RUN useradd -ms /bin/bash webots && usermod -aG sudo webots && echo "webots ALL=(ALL:ALL) NOPASSWD: ALL" >> /etc/sudoers
59+
# ENV HOME=/home/webots
60+
# USER webots
4361

44-
WORKDIR $HOME
62+
# WORKDIR $HOME
4563

4664
# Build the latest version of the RoboCup Humanoid TC fork of GameController
47-
RUN git clone https://github.com/RoboCup-Humanoid-TC/GameController ./GameController && cd GameController && ant
65+
RUN git clone https://github.com/RoboCup-Humanoid-TC/GameController ./GameController
66+
RUN cd GameController && ant
4867

4968
# Build the robocup controllers
50-
RUN git clone https://github.com/RoboCup-Humanoid-TC/hlvs_webots.git ./hlvs_webots && \
51-
pip3 install -r ./hlvs_webots/controllers/referee/requirements.txt && make -j$(nproc) -C ./hlvs_webots
69+
RUN git clone https://github.com/RoboCup-Humanoid-TC/hlvs_webots.git ./hlvs_webots
70+
RUN pip3 install -r ./hlvs_webots/controllers/referee/requirements.txt
71+
RUN make -j$(nproc) -C ./hlvs_webots
5272

5373
# Set environment variables for GameController
54-
ENV GAME_CONTROLLER_HOME=${HOME}/GameController JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
74+
ENV GAME_CONTROLLER_HOME=/GameController JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
5575

5676
# Install the NUbots-developed environment
57-
RUN git clone https://github.com/NUbots/NUWebots.git ./NUWebots && cd ./NUWebots && pip3 install -r ./requirements.txt && \
58-
./b configure -- -DENABLE_CLANG_TIDY=OFF && ./b build
59-
60-
RUN wget https://raw.githubusercontent.com/NUbots/NUWebots/main/webots-docker/webots-config.py && \
61-
wget https://raw.githubusercontent.com/NUbots/NUWebots/main/webots-docker/entrypoint.sh && \
62-
chmod +x entrypoint.sh
77+
RUN git clone https://github.com/NUbots/NUWebots /NUWebots
78+
RUN pip3 install -r /NUWebots/requirements.txt
79+
RUN /NUWebots/b configure -- -DENABLE_CLANG_TIDY=OFF
80+
RUN /NUWebots/b build
81+
82+
RUN wget https://raw.githubusercontent.com/NUbots/NUWebots/williamson/webots-docker/webots-docker/entrypoint.sh
83+
RUN wget https://raw.githubusercontent.com/NUbots/NUWebots/williamson/webots-docker/webots-docker/webots-config.py
84+
RUN chmod +x entrypoint.sh
6385

6486
# Configure robocup game.json file based on environment variables
6587
ENTRYPOINT ["./entrypoint.sh"]

webots-docker/entrypoint.sh

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/bin/bash
2-
python3 docker-config.py ${HOME}/hlvs_webots/controllers/referee/game.json
3-
rm docker-config.py
2+
python3 webots-config.py /hlvs_webots/controllers/referee/game.json
43
# Run the command given by CMD or docker run parameter, replacing current process
54
exec "$@"

webots-docker/webots-config.py

+11-7
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1-
import json, os, sys
1+
import json
2+
import os
3+
import sys
24

3-
TEAM_NAME = os.environ.get('TEAM_NAME')
4-
ROBOT_HOSTS = os.environ.get('ROBOT_HOSTS')
5+
TEAM_NAME = os.environ.get("TEAM_NAME")
6+
ROBOT_HOSTS = os.environ.get("ROBOT_HOSTS")
57

68
filename = sys.argv[1]
79

8-
with open(filename, 'r') as f:
10+
with open(filename, "r") as f:
911
game_config = json.load(f)
1012

11-
if TEAM_NAME: game_config['red']['config'] = 'teams/' + TEAM_NAME + '.json'
12-
if ROBOT_HOSTS: game_config['red']['hosts'] += ROBOT_HOSTS.split(",")
13+
if TEAM_NAME:
14+
game_config["red"]["config"] = "teams/" + TEAM_NAME + ".json"
15+
if ROBOT_HOSTS:
16+
game_config["red"]["hosts"] += ROBOT_HOSTS.split(",")
1317

14-
with open(filename, 'w') as f:
18+
with open(filename, "w") as f:
1519
json.dump(game_config, f, indent=2)

0 commit comments

Comments
 (0)