Skip to content
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

Feature/dockerfile traffic sim #1448

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
10 changes: 5 additions & 5 deletions .github/workflows/Docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
strategy:
matrix:
rosdistro: [humble]
arch: [amd64, arm64]
target: [base_amd64, base_arm64, base_traffic_simulator]

steps:
- name: Free Disk Space (Ubuntu)
Expand Down Expand Up @@ -54,7 +54,7 @@ jobs:
docker buildx create --use
docker buildx inspect --bootstrap

- name: Build (${{ matrix.arch }})
- name: Build (${{ matrix.target }})
if: github.event_name == 'pull_request'
uses: docker/bake-action@v3
with:
Expand All @@ -66,9 +66,9 @@ jobs:
*.cache-from=type=gha
push: false
targets: |
${{ matrix.rosdistro }}_base_${{ matrix.arch }}
${{ matrix.rosdistro }}_${{ matrix.target }}

- name: Build and push (${{ matrix.arch }})
- name: Build and push (${{ matrix.target }})
if: github.event_name == 'workflow_dispatch'
uses: docker/bake-action@v3
with:
Expand All @@ -81,4 +81,4 @@ jobs:
*.tags=ghcr.io/tier4/scenario_simulator_v2:humble-${{ github.event.inputs.version }}
push: true
targets: |
${{ matrix.rosdistro }}_base_${{ matrix.arch }}
${{ matrix.rosdistro }}_${{ matrix.target }}
46 changes: 46 additions & 0 deletions Dockerfile.traffic_simulator
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
ARG ROS_DISTRO="humble"
FROM ros:${ROS_DISTRO} as build-stage
SHELL ["/bin/bash", "-c"]
ENV DEBIAN_FRONTEND=noninteractive
ENV DEBCONF_NOWARNINGS=yes

# cspell: ignore kisak
RUN --mount=type=cache,id=apt-cache-amd64,target=/var/cache/apt,sharing=locked \
--mount=type=cache,id=apt-lib-amd64,target=/var/lib/apt,sharing=locked \
apt-get update && apt-get -y install python3-pip python3-rospkg python3-rosdep software-properties-common ccache && \
add-apt-repository ppa:kisak/kisak-mesa -y && \
apt-get update && apt-get install libegl-mesa0 -y

RUN rm -f /etc/apt/apt.conf.d/docker-clean && \
echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache

WORKDIR /home/ubuntu/Desktop/scenario_simulator_ws/src/scenario_simulator
COPY . $WORKDIR

WORKDIR /home/ubuntu/Desktop/scenario_simulator_ws/
RUN mkdir -p /home/ubuntu/Desktop/scenario_simulator_ws/src/scenario_simulator/external
WORKDIR /home/ubuntu/Desktop/scenario_simulator_ws/src/scenario_simulator
RUN vcs import external < dependency_${ROS_DISTRO}.repos
WORKDIR /home/ubuntu/Desktop/scenario_simulator_ws/src
RUN --mount=type=cache,id=apt-cache-amd64,target=/var/cache/apt,sharing=locked \
--mount=type=cache,id=apt-lib-amd64,target=/var/lib/apt,sharing=locked \
source /opt/ros/${ROS_DISTRO}/setup.bash \
&& apt-get update \
&& rosdep install -iy --from-paths . --rosdistro ${ROS_DISTRO}

WORKDIR /home/ubuntu/Desktop/scenario_simulator_ws

ENV CC="/usr/lib/ccache/gcc"
ENV CXX="/usr/lib/ccache/g++"
ENV CCACHE_DIR="/ccache"
RUN --mount=type=cache,target=/ccache source /opt/ros/${ROS_DISTRO}/setup.bash && \
colcon build --symlink-install \
--packages-up-to traffic_simulator \
--cmake-args \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
COPY ./docker-entrypoint.sh /
RUN chmod a+x /docker-entrypoint.sh

ENTRYPOINT ["/docker-entrypoint.sh"]
8 changes: 7 additions & 1 deletion docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,19 @@ target "base_arm64" {
platforms = ["linux/arm64/v8"]
}

target "base_traffic_simulator" {
target = "build-stage"
dockerfile = "Dockerfile.traffic_simulator"
platforms = ["linux/amd64"]
}

target "humble" {
inherits = [base]
name = "humble_${base}"
tags = ["ghcr.io/tier4/scenario_simulator_v2:humble"]
args = {"ROS_DISTRO" : "humble"}
group = ["humble"]
matrix = {
base = ["base_amd64", "base_arm64"]
base = ["base_amd64", "base_arm64", "base_traffic_simulator"]
}
}
Loading