Skip to content

Commit 654e7be

Browse files
authored
refactor(docker-build-and-push): refine autoware-tools workflow (#5941)
1 parent 3683fb5 commit 654e7be

File tree

5 files changed

+104
-116
lines changed

5 files changed

+104
-116
lines changed

.github/actions/docker-build-and-push-tools/action.yaml

+29-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,34 @@ runs:
3131
- name: Setup Docker Buildx
3232
uses: docker/setup-buildx-action@v3
3333

34+
- name: Cache ccache
35+
uses: actions/cache@v4
36+
with:
37+
path: |
38+
root-ccache
39+
key: ccache-tools-${{ inputs.platform }}-${{ hashFiles('src/**/*.cpp') }}
40+
restore-keys: |
41+
ccache-tools-${{ inputs.platform }}-
42+
43+
- name: Cache apt-get
44+
uses: actions/cache@v4
45+
with:
46+
path: |
47+
var-cache-apt
48+
key: apt-get-tools-${{ inputs.platform }}-${{ hashFiles('src/**/package.xml') }}
49+
restore-keys: |
50+
apt-get-tools-${{ inputs.platform }}-
51+
52+
- name: Inject cache into docker
53+
uses: reproducible-containers/buildkit-cache-dance@v3.1.2
54+
with:
55+
cache-map: |
56+
{
57+
"root-ccache": "/root/.ccache",
58+
"var-cache-apt": "/var/cache/apt"
59+
}
60+
skip-extraction: ${{ steps.cache-ccache.outputs.cache-hit && steps.cache-apt-get.outputs.cache-hit }}
61+
3462
- name: Get current date
3563
id: date
3664
run: echo "date=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT
@@ -74,7 +102,7 @@ runs:
74102
with:
75103
push: true
76104
files: |
77-
docker/docker-bake-tools.hcl
105+
docker/tools/docker-bake.hcl
78106
${{ steps.meta-visualizer.outputs.bake-file }}
79107
${{ steps.meta-scenario-simulator.outputs.bake-file }}
80108
provenance: false

docker/docker-bake-tools.hcl renamed to docker/tools/docker-bake.hcl

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ target "docker-metadata-action-scenario-simulator" {}
1111

1212
target "visualizer" {
1313
inherits = ["docker-metadata-action-visualizer"]
14-
dockerfile = "docker/tools/visualizer/Dockerfile.visualizer"
14+
dockerfile = "docker/tools/visualizer/Dockerfile"
1515
target = "visualizer"
1616
}
1717

1818
target "scenario-simulator" {
1919
inherits = ["docker-metadata-action-scenario-simulator"]
20-
dockerfile = "docker/tools/scenario-simulator/Dockerfile.scenario-simulator"
20+
dockerfile = "docker/tools/scenario-simulator/Dockerfile"
2121
target = "scenario-simulator"
2222
}

docker/tools/scenario-simulator/Dockerfile.scenario-simulator renamed to docker/tools/scenario-simulator/Dockerfile

+21-26
Original file line numberDiff line numberDiff line change
@@ -2,57 +2,52 @@
22
FROM ghcr.io/autowarefoundation/autoware:universe-devel AS builder
33
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
44
ARG ROS_DISTRO
5-
ARG LIB_DIR
65
ENV CCACHE_DIR="/root/.ccache"
7-
WORKDIR /autoware
8-
COPY src/simulator /autoware/src/simulator
6+
97
COPY docker/scripts/resolve_rosdep_keys.sh /autoware/resolve_rosdep_keys.sh
108
RUN chmod +x /autoware/resolve_rosdep_keys.sh
9+
COPY src/simulator /autoware/src/simulator
10+
WORKDIR /autoware
1111

1212
# Install dependencies and build the scenario simulator
1313
# hadolint ignore=SC1091
14-
RUN --mount=type=ssh \
15-
--mount=type=cache,target=/var/cache/apt,sharing=locked \
14+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
1615
apt-get update \
17-
&& source /opt/ros/"$ROS_DISTRO"/setup.bash && source /opt/autoware/setup.bash \
16+
&& source /opt/autoware/setup.bash \
1817
&& rosdep update && rosdep install -y --from-paths src --ignore-src --rosdistro $ROS_DISTRO \
19-
&& colcon build --cmake-args \
20-
"-Wno-dev" \
21-
"--no-warn-unused-cli" \
22-
--install-base /opt/autoware \
23-
--merge-install \
24-
--mixin release compile-commands ccache \
18+
&& /autoware/cleanup_apt.sh
19+
20+
# hadolint ignore=SC1091
21+
RUN --mount=type=cache,target=${CCACHE_DIR} \
22+
source /opt/autoware/setup.bash \
23+
&& /autoware/build_and_clean.sh ${CCACHE_DIR} /opt/autoware \
2524
&& find /opt/autoware/lib -type f -name "*.py" -exec chmod +x {} \; \
26-
&& find /opt/autoware/share -type f -name "*.py" -exec chmod +x {} \; \
27-
&& apt-get clean \
28-
&& rm -rf /var/lib/apt/lists/* "$HOME"/.cache
25+
&& find /opt/autoware/share -type f -name "*.py" -exec chmod +x {} \;
2926

3027
# Extract rosdep dependencies for simulator
3128
# hadolint ignore=SC1091
32-
RUN source /opt/ros/"$ROS_DISTRO"/setup.bash && source /opt/autoware/setup.bash \
33-
&& /autoware/resolve_rosdep_keys.sh /autoware/src/simulator ${ROS_DISTRO} --dependency-types=exec \
34-
> /rosdep-simulator-depend-packages.txt \
35-
&& cat /rosdep-simulator-depend-packages.txt
29+
RUN source /opt/autoware/setup.bash \
30+
&& /autoware/resolve_rosdep_keys.sh /autoware/src ${ROS_DISTRO} --dependency-types=exec \
31+
> /rosdep-simulator-exec-depend-packages.txt \
32+
&& cat /rosdep-simulator-exec-depend-packages.txt
3633

3734
### Scenario Simulator
3835
FROM ghcr.io/autowarefoundation/autoware:core AS scenario-simulator
3936
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
4037
ARG ROS_DISTRO
4138
ARG LIB_DIR
42-
WORKDIR /autoware
39+
4340
COPY --from=builder /opt/autoware /opt/autoware
44-
COPY --from=builder /rosdep-simulator-depend-packages.txt /tmp/rosdep-simulator-depend-packages.txt
41+
COPY --from=builder /rosdep-simulator-exec-depend-packages.txt /tmp/rosdep-simulator-exec-depend-packages.txt
4542

4643
# hadolint ignore=SC2002
4744
RUN --mount=type=ssh \
4845
--mount=type=cache,target=/var/cache/apt,sharing=locked \
49-
apt-get update && apt-get install -y curl unzip \
50-
&& source /opt/ros/"$ROS_DISTRO"/setup.bash && source /opt/autoware/setup.bash \
51-
&& rosdep update \
46+
apt-get update \
5247
# Remove xmlschema and yamale from rosdep packages since we install via pip
53-
&& sed -i '/\(xmlschema\|yamale\)/d' /tmp/rosdep-simulator-depend-packages.txt \
48+
&& sed -i '/\(xmlschema\|yamale\)/d' /tmp/rosdep-simulator-exec-depend-packages.txt \
5449
&& pip install --no-cache-dir yamale xmlschema \
55-
&& cat /tmp/rosdep-simulator-depend-packages.txt | xargs apt-get install -y --no-install-recommends \
50+
&& cat /tmp/rosdep-simulator-exec-depend-packages.txt | xargs apt-get install -y --no-install-recommends \
5651
&& /autoware/cleanup_system.sh $LIB_DIR $ROS_DISTRO
5752

5853
COPY docker/tools/scenario-simulator/entrypoint.sh /entrypoint.sh

docker/tools/visualizer/Dockerfile

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# cspell:ignore openbox, VNC, tigervnc, novnc, websockify, newkey, xstartup, keyout
2+
FROM ghcr.io/autowarefoundation/autoware:universe AS universe
3+
4+
# Extract RViz configs for visualizer
5+
# hadolint ignore=SC1091
6+
RUN source /opt/autoware/setup.bash \
7+
&& RVIZ_PATH="$(ros2 pkg prefix --share autoware_launch)/rviz" \
8+
&& cp -r "$RVIZ_PATH" /autoware/rviz
9+
10+
### visualizer
11+
FROM ghcr.io/autowarefoundation/autoware:universe-visualization AS visualizer
12+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
13+
ARG ROS_DISTRO
14+
ARG LIB_DIR
15+
16+
COPY --from=universe /autoware/rviz /autoware/rviz
17+
WORKDIR /autoware
18+
19+
# Install openbox, VNC, and simulator dependencies
20+
# hadolint ignore=SC2002
21+
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
22+
curl \
23+
unzip \
24+
openbox \
25+
tigervnc-standalone-server \
26+
tigervnc-common \
27+
novnc \
28+
websockify \
29+
python3-numpy \
30+
python3-xdg \
31+
&& pip install --no-cache-dir yamale xmlschema \
32+
&& /autoware/cleanup_system.sh $LIB_DIR $ROS_DISTRO
33+
34+
# Create SSL certificate for NoVNC
35+
RUN openssl req -x509 -nodes -newkey rsa:2048 \
36+
-keyout /etc/ssl/private/novnc.key \
37+
-out /etc/ssl/certs/novnc.crt \
38+
-days 365 \
39+
-subj "/O=Autoware-OpenADKit/CN=localhost"
40+
41+
# Need to expose VNC and NoVNC ports when running the container
42+
EXPOSE 5900 6080
43+
44+
# Add source commands to bash startup
45+
RUN echo "source /opt/ros/$ROS_DISTRO/setup.bash" >> /root/.bashrc && \
46+
echo "source /opt/autoware/setup.bash" >> /root/.bashrc
47+
48+
# Copy startup scripts
49+
COPY docker/tools/visualizer/xstartup /root/.vnc/xstartup
50+
COPY docker/tools/visualizer/entrypoint.sh /entrypoint.sh
51+
RUN chmod +x /entrypoint.sh && chmod +x /root/.vnc/xstartup
52+
ENTRYPOINT ["/entrypoint.sh"]

docker/tools/visualizer/Dockerfile.visualizer

-87
This file was deleted.

0 commit comments

Comments
 (0)