Skip to content

Commit

Permalink
Moving dockerfiles, removing use of dep image
Browse files Browse the repository at this point in the history
Signed-off-by: Aaron Chong <[email protected]>
  • Loading branch information
aaronchongth committed Oct 13, 2023
1 parent d7cf15e commit 574e85c
Show file tree
Hide file tree
Showing 8 changed files with 142 additions and 137 deletions.
57 changes: 11 additions & 46 deletions .github/workflows/build-releases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,14 @@ env:
REGISTRY: ghcr.io

jobs:
build-base-image:
name: Build and push base image
build-image:
name: Build and push image
runs-on: ubuntu-latest
strategy:
matrix:
ros2-distro: [humble]
steps:
- uses: actions/checkout@v4
with:
ref: ${{ matrix.ros2-distro }}
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
Expand All @@ -32,28 +30,27 @@ jobs:
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ github.repository }}/rmf-deps-${{ matrix.ros2-distro }}
images: ${{ github.repository }}/rmf-demos-${{ matrix.ros2-distro }}
tags: type=raw,value={{date 'YYYYMMDD'}}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
file: ./docker/${{ matrix.ros2-distro }}/base.Dockerfile
file: ./docker/${{ matrix.ros2-distro }}.Dockerfile
push: ${{ github.event_name == 'push' || github.event_name == 'schedule' }}
tags: |
${{ steps.meta.outputs.tags }}
${{ github.repository }}/rmf-deps-${{ matrix.ros2-distro }}:latest
${{ github.repository }}/rmf-demos-${{ matrix.ros2-distro }}:latest
build-image:
name: Build and push image
needs: build-base-image
build-release-image:
name: Build and push release image
runs-on: ubuntu-latest
strategy:
matrix:
ros2-distro: [humble]
steps:
- uses: actions/checkout@v4
with:
ref: ${{ matrix.ros2-distro }}
ref: ${{ matrix.ros2-distro }}-release
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
Expand All @@ -64,45 +61,13 @@ jobs:
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ github.repository }}/rmf-demos-${{ matrix.ros2-distro }}
images: ${{ github.repository }}/rmf-demos-${{ matrix.ros2-distro }}-release
tags: type=raw,value={{date 'YYYYMMDD'}}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
file: ./docker/${{ matrix.ros2-distro }}/${{ matrix.ros2-distro }}.Dockerfile
file: ./docker/${{ matrix.ros2-distro }}-release.Dockerfile
push: ${{ github.event_name == 'push' || github.event_name == 'schedule' }}
tags: |
${{ steps.meta.outputs.tags }}
${{ github.repository }}/rmf-demos-${{ matrix.ros2-distro }}:latest
# build-release-image:
# name: Build and push release image
# needs: build-base-image
# runs-on: ubuntu-latest
# strategy:
# matrix:
# ros2-distro: [humble]
# steps:
# - uses: actions/checkout@v4
# with:
# ref: ${{ matrix.ros2-distro }}-release
# - name: Log in to the Container registry
# uses: docker/login-action@v3
# with:
# registry: ${{ env.REGISTRY }}
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}
# - name: Extract tags for Docker
# id: meta
# uses: docker/metadata-action@v5
# with:
# images: ${{ github.repository }}/rmf-demos-${{ matrix.ros2-distro }}-release
# tags: type=raw,value={{date 'YYYYMMDD'}}
# - name: Build and push Docker image
# uses: docker/build-push-action@v5
# with:
# file: ./docker/${{ matrix.ros2-distro }}/${{ matrix.ros2-distro }}-release.Dockerfile
# push: ${{ github.event_name == 'push' || github.event_name == 'schedule' }}
# tags: |
# ${{ steps.meta.outputs.tags }}
# ${{ github.repository }}/rmf-demos-${{ matrix.ros2-distro }}-release:latest
${{ github.repository }}/rmf-demos-${{ matrix.ros2-distro }}-release:latest
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
file: ./docker/rolling/Dockerfile
file: ./docker/rolling.Dockerfile
push: ${{ github.event_name == 'push' || github.event_name == 'schedule' }}
tags: |
${{ steps.meta.outputs.tags }}
Expand Down
64 changes: 64 additions & 0 deletions docker/humble-release.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#-----------------------
# Stage 1 - Dependencies
#-----------------------

FROM ros:humble AS builder

RUN apt-get update \
&& apt-get install -y \
cmake \
curl \
git \
python3-colcon-common-extensions \
python3-vcstool \
wget \
python3-pip \
clang lldb lld \
&& pip3 install flask-socketio fastapi uvicorn \
&& update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++ 100 \
&& rm -rf /var/lib/apt/lists/*

# setup keys
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys D2486D2DD83DB69272AFE98867170598AF249743

# setup sources.list
RUN . /etc/os-release \
&& echo "deb http://packages.osrfoundation.org/gazebo/$ID-stable `lsb_release -sc` main" > /etc/apt/sources.list.d/gazebo-latest.list

RUN mkdir $HOME/rmf_demos_ws
WORKDIR $HOME/rmf_demos_ws
RUN mkdir src
RUN rosdep update --rosdistro $ROS_DISTRO

RUN git clone https://github.com/open-rmf/rmf_demos -b humble src/rmf_demos
RUN apt-get update \
&& apt-get upgrade -y \
&& rosdep update \
&& rosdep install --from-paths src --ignore-src --rosdistro $ROS_DISTRO -yr \
&& rm -rf /var/lib/apt/lists/*

#-----------------
# Stage 2 - build
#-----------------

# colcon compilation
RUN . /opt/ros/$ROS_DISTRO/setup.sh \
&& colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release

#----------
# Stage 3
#----------

# TODO: rosdep doesn't support installing only exec dependencies (https://github.com/ros-infrastructure/rosdep/pull/727)
# When the PR is merged, we can do a multi-stage build and include only whats needed at runtime.
# FROM ros:foxy
# COPY --from=0 /root/rmf/install /opt/rmf
# RUN rosdep ...
# COPY --from=builder /root/rmf/install /opt/rmf

# cleanup
RUN rm -rf build devel src \
&& sed -i '$isource "/rmf_demos_ws/install/setup.bash"' /ros_entrypoint.sh

ENTRYPOINT ["/ros_entrypoint.sh"]
CMD ["bash"]
65 changes: 65 additions & 0 deletions docker/humble.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#-----------------------
# Stage 1 - Dependencies
#-----------------------

FROM ros:humble AS builder

RUN apt-get update \
&& apt-get install -y \
cmake \
curl \
git \
python3-colcon-common-extensions \
python3-vcstool \
wget \
python3-pip \
clang lldb lld \
&& pip3 install flask-socketio fastapi uvicorn \
&& update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++ 100 \
&& rm -rf /var/lib/apt/lists/*

# setup keys
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys D2486D2DD83DB69272AFE98867170598AF249743

# setup sources.list
RUN . /etc/os-release \
&& echo "deb http://packages.osrfoundation.org/gazebo/$ID-stable `lsb_release -sc` main" > /etc/apt/sources.list.d/gazebo-latest.list

RUN mkdir $HOME/rmf_demos_ws
WORKDIR $HOME/rmf_demos_ws
RUN mkdir src
RUN rosdep update --rosdistro $ROS_DISTRO

RUN wget https://raw.githubusercontent.com/open-rmf/rmf/humble/rmf.repos
RUN vcs import src < rmf.repos \
&& apt-get update \
&& apt-get upgrade -y \
&& rosdep update \
&& rosdep install --from-paths src --ignore-src --rosdistro $ROS_DISTRO -yr \
&& rm -rf /var/lib/apt/lists/*

#-----------------
# Stage 2 - build
#-----------------

# colcon compilation
RUN . /opt/ros/$ROS_DISTRO/setup.sh \
&& colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release

#----------
# Stage 3
#----------

# TODO: rosdep doesn't support installing only exec dependencies (https://github.com/ros-infrastructure/rosdep/pull/727)
# When the PR is merged, we can do a multi-stage build and include only whats needed at runtime.
# FROM ros:foxy
# COPY --from=0 /root/rmf/install /opt/rmf
# RUN rosdep ...
# COPY --from=builder /root/rmf/install /opt/rmf

# cleanup
RUN rm -rf build devel src \
&& sed -i '$isource "/rmf_demos_ws/install/setup.bash"' /ros_entrypoint.sh

ENTRYPOINT ["/ros_entrypoint.sh"]
CMD ["bash"]
26 changes: 0 additions & 26 deletions docker/humble/base.Dockerfile

This file was deleted.

31 changes: 0 additions & 31 deletions docker/humble/humble-release.Dockerfile

This file was deleted.

30 changes: 0 additions & 30 deletions docker/humble/humble.Dockerfile

This file was deleted.

4 changes: 1 addition & 3 deletions docker/rolling/Dockerfile → docker/rolling.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ WORKDIR $HOME/rmf_demos_ws
RUN mkdir src
RUN rosdep update --rosdistro $ROS_DISTRO

# This replaces: wget https://raw.githubusercontent.com/open-rmf/rmf/main/rmf.repos
ENV DEBIAN_FRONTEND=noninteractive
COPY rmf.repos rmf.repos
RUN wget https://raw.githubusercontent.com/open-rmf/rmf/main/rmf.repos
RUN vcs import src < rmf.repos \
&& apt-get update \
&& apt-get upgrade -y \
Expand Down

0 comments on commit 574e85c

Please sign in to comment.