Skip to content

Commit

Permalink
Merge pull request #1522 from tier4/feature/docker/traffic_simulator
Browse files Browse the repository at this point in the history
add Dockerfile for traffic_simulator
  • Loading branch information
hakuturu583 authored Feb 5, 2025
2 parents 132c03d + 8040a27 commit 17759d8
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 0 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/Docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,61 @@ on:
required: true

jobs:
push_traffic_sim_docker:
name: Push Docker Image for traffic_simulator
runs-on: ubuntu-22.04
timeout-minutes: 720
strategy:
matrix:
rosdistro: [humble]

steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
tool-cache: false

- name: Install docker for ubuntu runner
uses: docker/setup-buildx-action@v3

- uses: actions/checkout@v4

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build
if: github.event_name == 'pull_request'
uses: docker/[email protected]
with:
files: |
./docker-bake.hcl
workdir: .
set: |
*.cache-to=type=gha,mode=max
*.cache-from=type=gha
push: false
targets: |
traffic_simulator_${{ matrix.rosdistro }}
- name: Build and push
if: github.event_name == 'workflow_dispatch'
uses: docker/[email protected]
with:
files: |
./docker-bake.hcl
workdir: .
set: |
*.cache-to=type=gha,mode=max
*.cache-from=type=gha
*.tags=ghcr.io/tier4/scenario_simulator_v2:traffic_simulator_${{ matrix.rosdistro }}-${{ github.event.inputs.version }}
push: true
targets: |
traffic_simulator_${{ matrix.rosdistro }}
push_docker:
name: Push Docker Image
runs-on: ubuntu-22.04
Expand Down
47 changes: 47 additions & 0 deletions Dockerfile.traffic_simulator
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
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 ./simulation/traffic_simulator /home/ubuntu/Desktop/scenario_simulator_ws/src/scenario_simulator/simulation/traffic_simulator
COPY ./simulation/traffic_simulator_msgs /home/ubuntu/Desktop/scenario_simulator_ws/src/scenario_simulator/simulation/traffic_simulator_msgs
COPY ./simulation/simulation_interface /home/ubuntu/Desktop/scenario_simulator_ws/src/scenario_simulator/simulation/simulation_interface
COPY ./external/concealer /home/ubuntu/Desktop/scenario_simulator_ws/src/scenario_simulator/external/concealer
COPY ./common /home/ubuntu/Desktop/scenario_simulator_ws/src/scenario_simulator/common
COPY ./dependency_${ROS_DISTRO}.repos /home/ubuntu/Desktop/scenario_simulator_ws/src/scenario_simulator/dependency_${ROS_DISTRO}.repos
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} -t build -t buildtool -t exec

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 \
--cmake-args \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DBUILD_TESTING=OFF
COPY ./docker-entrypoint.sh /
RUN chmod a+x /docker-entrypoint.sh

ENTRYPOINT ["/docker-entrypoint.sh"]
9 changes: 9 additions & 0 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,12 @@ target "humble" {
base = ["base_amd64", "base_arm64"]
}
}

target "traffic_simulator" {
name = "traffic_simulator_humble"
tags = ["ghcr.io/tier4/scenario_simulator_v2:traffic_simulator_humble"]
args = {"ROS_DISTRO" : "humble"}
group = ["humble"]
matrix = {}
dockerfile = "Dockerfile.traffic_simulator"
}

0 comments on commit 17759d8

Please sign in to comment.