Skip to content

Commit

Permalink
Setup devel docker to speed up first build using ccache (#77)
Browse files Browse the repository at this point in the history
This proposal speeds up the first build after starting the container,
and also if the `build` and `install` folders are cleared for any
reason.

- Adds cccache to the container.
- Binds a new docker volume to keep the ccache cache files in the
  host machine.
- Installs colcon mixins in the container to use the ccache mixin.
- Setups the defaults.yaml file of colcon to build using the ccache
  mixin by default.

The result is that when using the `colcon build` command all of the
build process will go through `ccache`, speeding up the process
considerably whenever the same file is built under the same conditions
again.

Note that there's a new warning during the build process because one of
the `flatland` packages seems to ignore the CMake ccache settings.
Worst case that means that that part of the process will not be sped up.

Signed-off-by: Gerardo Puga <[email protected]>
  • Loading branch information
glpuga authored Jan 27, 2023
1 parent c43d564 commit 7fc4658
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ services:
- /tmp/.X11-unix:/tmp/.X11-unix:rw
- /tmp/.docker.xauth:/tmp/.docker.xauth
- ..:/ws/src
- beluga_ccache:/home/developer/.ccache
volumes:
beluga_ccache:
5 changes: 5 additions & 0 deletions docker/files/colcon_defaults.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"build": {
"mixin": [ "ccache" ]
}
}
6 changes: 6 additions & 0 deletions docker/images/humble/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update \
&& apt-get install --no-install-recommends -y \
ccache \
curl \
doxygen \
perl \
Expand Down Expand Up @@ -36,6 +37,11 @@ ENV USER_WS /ws

WORKDIR $USER_WS

RUN colcon mixin add default https://raw.githubusercontent.com/colcon/colcon-mixin-repository/master/index.yaml \
&& colcon mixin update default
COPY --chown=$USER:$GROUP docker/files/colcon_defaults.yaml /home/$USER/.colcon/defaults.yaml
RUN mkdir -p /home/$USER/.ccache

COPY . $USER_WS/src

RUN sudo chown -R $USER:$GROUP $USER_WS
Expand Down

0 comments on commit 7fc4658

Please sign in to comment.