diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..5d4eed38d --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +.git +build +install +log diff --git a/Dockerfile b/Dockerfile index 8006e4e09..ab66b73fb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,8 +26,6 @@ ARG USER_GID # Copy source code from the workspace's ROS 2 packages to a workspace inside the container ARG USER_WS=/home/${USERNAME}/user_ws ENV USER_WS=${USER_WS} -RUN mkdir -p ${USER_WS}/src ${USER_WS}/build ${USER_WS}/install ${USER_WS}/log -COPY ./src ${USER_WS}/src # Also mkdir with user permission directories which will be mounted later to avoid docker creating them as root WORKDIR $USER_WS @@ -67,6 +65,7 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ # hadolint ignore=SC1091 RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ --mount=type=cache,target=/var/lib/apt,sharing=locked \ + --mount=type=bind,target=${USER_WS}/,source=. \ . /opt/overlay_ws/install/setup.sh && \ apt-get update && \ rosdep install -q -y \