Skip to content

Dockerfile and devcontainer.json #2

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

Merged
merged 19 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from 15 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
67 changes: 67 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"name": "Whole Body MPC Dev Container",
"initializeCommand": "xhost +local:",
"build": {
"dockerfile": "${localWorkspaceFolder}/docker/Dockerfile",
"target": "base",
"args": {
"WB_HUMANOID_MPC_DIR": "/wb_humanoid_mpc_ws",
"PYTHON_VERSION": "3.12",
"USER_ID": "${localEnv:USER_ID}",
"GROUP_ID": "${localEnv:GROUP_ID}",
"GIT_USER_NAME": "${command:git config --global user.name}",
"GIT_USER_EMAIL": "${command:git config --global user.email}"
}
},
"runArgs": [
"--rm",
"-it",
"--net=host",
"--privileged",
"-u", "${localEnv:USER_ID}:${localEnv:GROUP_ID}",
"-e", "DISPLAY",
"-e", "QT_X11_NO_MITSHM=1",
"-e", "XDG_RUNTIME_DIR=${localEnv:XDG_RUNTIME_DIR}",
"-e",
"GIT_USER_NAME=$(git config --global user.name)",
"-e",
"GIT_USER_EMAIL=$(git config --global user.email)",
"-v", "/tmp/.X11-unix:/tmp/.X11-unix",
"-v", "${localEnv:XDG_RUNTIME_DIR}:${localEnv:XDG_RUNTIME_DIR}"
],
"overrideCommand": true,
"workspaceFolder": "/wb_humanoid_mpc_ws/src/wb_humanoid_mpc",
"customizations": {
"vscode": {
"settings": {
"terminal.integrated.defaultProfile.linux": "bash",
"editor.formatOnSave": true,
"files.trimTrailingWhitespace": true
},
"extensions": [
"ms-vscode.cpptools",
"ms-vscode.cmake-tools",
"ms-vscode-remote.remote-containers",
"ms-azuretools.vscode-docker",
"ms-python.python",
"ms-python.vscode-pylance",
"eamodio.gitlens",
"GitHub.copilot",
"GitHub.copilot-chat",
"twxs.cmake",
"cheshirekow.cmake-format",
"xaver.clang-format",
"ms-toolsai.jupyter-keymap",
"ms-vscode-remote.remote-ssh",
"ms-vscode-remote.remote-ssh-edit",
"ms-vscode.remote-explorer",
"sankethdev.vscode-proto"
]
}
},
"mounts": [
"source=${localWorkspaceFolder}/../..,target=/wb_humanoid_mpc_ws,type=bind,consistency=cached",
"source=${localEnv:HOME}/.gitconfig,target=/home/vscode/.gitconfig,type=bind"
],
"postCreateCommand": "git config --global user.name \"$GIT_USER_NAME\" && git config --global user.email \"$GIT_USER_EMAIL\" && git config --global --add safe.directory /wb_humanoid_mpc_ws/src/wb_humanoid_mpc && curl -o .git-completion.bash https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash && echo 'source /opt/ros/jazzy/setup.bash' >> ~/.bashrc && echo 'source ./.git-completion.bash' >> ~/.bashrc"
}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ install/

**/__pycache__/**

# MuJoCo log
# MuJoCo log
*/MUJOCO_LOG.TXT
*mjData.bin

Expand All @@ -62,3 +62,4 @@ install/

**/.gdb_history

.git-completion.bash
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
[submodule "lib/cmake_modules"]
path = lib/cmake_modules
url = https://github.com/ros/cmake_modules.git
[submodule "lib/pinocchio"]
path = lib/pinocchio
url = https://github.com/manumerous/pinocchio.git
[submodule "lib/mujoco"]
path = lib/mujoco
url = https://github.com/google-deepmind/mujoco.git
Expand Down
64 changes: 64 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
ARG BASE_IMAGE=ubuntu:24.04
FROM ${BASE_IMAGE} AS base

ARG USER_ID=1000
ARG GROUP_ID=1000
ARG WB_HUMANOID_MPC_DIR="/wb_humanoid_mpc_ws"
ARG PYTHON_VERSION=3.12
ENV DEBIAN_FRONTEND=noninteractive
ENV ROS_DISTRO=jazzy

# Install system dependencies, ROS, Python, and development tools in a single step
RUN apt-get update && apt-get install -y --no-install-recommends \
curl gnupg2 lsb-release locales software-properties-common \
git build-essential clang-format make ninja-build \
python3-pygame libeigen3-dev libglpk-dev libboost-all-dev \
libboost-filesystem-dev libboost-log-dev libglfw3-dev \
x11-apps mesa-utils \
&& rm -rf /var/lib/apt/lists/*

# Set up locales
RUN locale-gen en_US.UTF-8 && update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
ENV LANG en_US.UTF-8 LANGUAGE en_US:en LC_ALL en_US.UTF-8

# Install Python and pip
RUN apt-get update && \
apt-get install -y --no-install-recommends \
python${PYTHON_VERSION} python${PYTHON_VERSION}-dev python${PYTHON_VERSION}-tk libpython${PYTHON_VERSION}-dev \
python3-pip python3-argcomplete \
&& rm -rf /var/lib/apt/lists/*
RUN ln -sf /usr/bin/python${PYTHON_VERSION} /usr/bin/python3
RUN python3 -m pip install --break-system-packages --no-cache-dir --upgrade setuptools cython catkin_pkg colcon-common-extensions

# Add ROS2 repository and install core packages
RUN curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | apt-key add - && \
echo "deb http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main" > /etc/apt/sources.list.d/ros2-latest.list
RUN apt-get update && apt-get install -y --no-install-recommends \
ros-${ROS_DISTRO}-desktop ros-${ROS_DISTRO}-ament-cmake \
ros-${ROS_DISTRO}-ament-cmake-clang-format \
ros-${ROS_DISTRO}-joint-state-publisher-gui ros-${ROS_DISTRO}-xacro \
ros-${ROS_DISTRO}-mcap-vendor ros-${ROS_DISTRO}-interactive-markers \
ros-${ROS_DISTRO}-std-msgs ros-${ROS_DISTRO}-pinocchio \
&& rm -rf /var/lib/apt/lists/*

# Increase Git buffer size
RUN git config --global http.postBuffer 1048576000

# Set default shell to bash
SHELL ["/bin/bash", "-c"]

# Set up environment variables
ENV CMAKE_PREFIX_PATH="/opt/ros/${ROS_DISTRO}:${CMAKE_PREFIX_PATH}"
ENV DISPLAY=${DISPLAY} QT_X11_NO_MITSHM=1

# Set up user and workspace
WORKDIR ${WB_HUMANOID_MPC_DIR}
RUN mkdir -p ${WB_HUMANOID_MPC_DIR}/src/wb_humanoid_mpc

# Ensure correct UID/GID
RUN if ! getent group $GROUP_ID > /dev/null; then groupadd --gid $GROUP_ID devgroup; fi && \
if ! getent passwd $USER_ID > /dev/null; then useradd --uid $USER_ID --gid $GROUP_ID --create-home devuser; fi && \
chown -R $USER_ID:$GROUP_ID .

# Copy the Makefile and other necessary files
COPY . ${WB_HUMANOID_MPC_DIR}/src/wb_humanoid_mpc
1 change: 0 additions & 1 deletion lib/pinocchio
Submodule pinocchio deleted from 16d84f
Loading