Skip to content

Commit

Permalink
feat(docker): inherit autoware-base images (#5492)
Browse files Browse the repository at this point in the history
* change run

Signed-off-by: Yutaka Kondo <[email protected]>

* use autoware-base images

Signed-off-by: Yutaka Kondo <[email protected]>

* update health-check

Signed-off-by: Yutaka Kondo <[email protected]>

* update load-env

Signed-off-by: Yutaka Kondo <[email protected]>

* update load-env

Signed-off-by: Yutaka Kondo <[email protected]>

* fix rebase

Signed-off-by: Yutaka Kondo <[email protected]>

* add build-args

Signed-off-by: Yutaka Kondo <[email protected]>

* fix hcl

Signed-off-by: Yutaka Kondo <[email protected]>

---------

Signed-off-by: Yutaka Kondo <[email protected]>
  • Loading branch information
youtalk authored Nov 27, 2024
1 parent 0e44b14 commit 4148d65
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 102 deletions.
13 changes: 0 additions & 13 deletions .github/actions/docker-build-and-push-cuda/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,6 @@ runs:
run: echo "date=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT
shell: bash

- name: Docker meta for autoware:base-cuda
id: meta-base-cuda
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository_owner }}/${{ inputs.target-image }}
tags: |
type=raw,value=base-cuda-${{ inputs.platform }}
type=raw,value=base-cuda-${{ steps.date.outputs.date }}-${{ inputs.platform }}
bake-target: docker-metadata-action-base-cuda
flavor: |
latest=false
- name: Docker meta for autoware:universe-sensing-perception-devel-cuda
id: meta-universe-sensing-perception-devel-cuda
uses: docker/metadata-action@v5
Expand Down Expand Up @@ -137,7 +125,6 @@ runs:
push: true
files: |
docker/docker-bake-cuda.hcl
${{ steps.meta-base-cuda.outputs.bake-file }}
${{ steps.meta-universe-sensing-perception-devel-cuda.outputs.bake-file }}
${{ steps.meta-universe-sensing-perception-cuda.outputs.bake-file }}
${{ steps.meta-universe-devel-cuda.outputs.bake-file }}
Expand Down
13 changes: 0 additions & 13 deletions .github/actions/docker-build-and-push/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,6 @@ runs:
run: echo "date=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT
shell: bash

- name: Docker meta for autoware:base
id: meta-base
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository_owner }}/${{ inputs.target-image }}
tags: |
type=raw,value=base-${{ inputs.platform }}
type=raw,value=base-${{ steps.date.outputs.date }}-${{ inputs.platform }}
bake-target: docker-metadata-action-base
flavor: |
latest=false
- name: Docker meta for autoware:core-devel
id: meta-core-devel
uses: docker/metadata-action@v5
Expand Down Expand Up @@ -221,7 +209,6 @@ runs:
push: true
files: |
docker/docker-bake.hcl
${{ steps.meta-base.outputs.bake-file }}
${{ steps.meta-core-devel.outputs.bake-file }}
${{ steps.meta-universe-sensing-perception-devel.outputs.bake-file }}
${{ steps.meta-universe-sensing-perception.outputs.bake-file }}
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/docker-build-and-push-arm64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ jobs:
*.platform=linux/arm64
*.args.ROS_DISTRO=${{ needs.load-env.outputs.rosdistro }}
*.args.BASE_IMAGE=${{ needs.load-env.outputs.base_image }}
*.args.AUTOWARE_BASE_IMAGE=${{ needs.load-env.outputs.autoware_base_image }}
*.args.AUTOWARE_BASE_CUDA_IMAGE=${{ needs.load-env.outputs.autoware_base_cuda_image }}
*.args.LIB_DIR=aarch64
*.cache-from=type=registry,ref=ghcr.io/${{ github.repository }}-buildcache:arm64-${{ github.ref_name }}
*.cache-from=type=registry,ref=ghcr.io/${{ github.repository }}-buildcache:arm64-main
Expand Down Expand Up @@ -106,6 +108,8 @@ jobs:
*.platform=linux/arm64
*.args.ROS_DISTRO=${{ needs.load-env.outputs.rosdistro }}
*.args.BASE_IMAGE=${{ needs.load-env.outputs.base_image }}
*.args.AUTOWARE_BASE_IMAGE=${{ needs.load-env.outputs.autoware_base_image }}
*.args.AUTOWARE_BASE_CUDA_IMAGE=${{ needs.load-env.outputs.autoware_base_cuda_image }}
*.args.LIB_DIR=aarch64
*.cache-from=type=registry,ref=ghcr.io/${{ github.repository }}-buildcache:arm64-${{ github.ref_name }}
*.cache-from=type=registry,ref=ghcr.io/${{ github.repository }}-buildcache:arm64-main
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/docker-build-and-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ jobs:
*.platform=linux/amd64
*.args.ROS_DISTRO=${{ needs.load-env.outputs.rosdistro }}
*.args.BASE_IMAGE=${{ needs.load-env.outputs.base_image }}
*.args.AUTOWARE_BASE_IMAGE=${{ needs.load-env.outputs.autoware_base_image }}
*.args.AUTOWARE_BASE_CUDA_IMAGE=${{ needs.load-env.outputs.autoware_base_cuda_image }}
*.args.LIB_DIR=x86_64
*.cache-from=type=registry,ref=ghcr.io/${{ github.repository }}-buildcache:amd64-${{ github.ref_name }}
*.cache-from=type=registry,ref=ghcr.io/${{ github.repository }}-buildcache:amd64-main
Expand Down Expand Up @@ -101,6 +103,8 @@ jobs:
*.platform=linux/amd64
*.args.ROS_DISTRO=${{ needs.load-env.outputs.rosdistro }}
*.args.BASE_IMAGE=${{ needs.load-env.outputs.base_image }}
*.args.AUTOWARE_BASE_IMAGE=${{ needs.load-env.outputs.autoware_base_image }}
*.args.AUTOWARE_BASE_CUDA_IMAGE=${{ needs.load-env.outputs.autoware_base_cuda_image }}
*.args.LIB_DIR=x86_64
*.cache-from=type=registry,ref=ghcr.io/${{ github.repository }}-buildcache:amd64-${{ github.ref_name }}
*.cache-from=type=registry,ref=ghcr.io/${{ github.repository }}-buildcache:amd64-main
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/health-check-arm64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ jobs:
build-args: |
ROS_DISTRO=${{ needs.load-env.outputs.rosdistro }}
BASE_IMAGE=${{ needs.load-env.outputs.base_image }}
AUTOWARE_BASE_IMAGE=${{ needs.load-env.outputs.autoware_base_image }}
AUTOWARE_BASE_CUDA_IMAGE=${{ needs.load-env.outputs.autoware_base_cuda_image }}
LIB_DIR=aarch64
- name: Show disk space
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/health-check-nightly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ jobs:
build-args: |
ROS_DISTRO=${{ needs.load-env.outputs.rosdistro }}
BASE_IMAGE=${{ needs.load-env.outputs.base_image }}
AUTOWARE_BASE_IMAGE=${{ needs.load-env.outputs.autoware_base_image }}
AUTOWARE_BASE_CUDA_IMAGE=${{ needs.load-env.outputs.autoware_base_cuda_image }}
LIB_DIR=x86_64
- name: Show disk space
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/health-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ jobs:
build-args: |
ROS_DISTRO=${{ needs.load-env.outputs.rosdistro }}
BASE_IMAGE=${{ needs.load-env.outputs.base_image }}
AUTOWARE_BASE_IMAGE=${{ needs.load-env.outputs.autoware_base_image }}
AUTOWARE_BASE_CUDA_IMAGE=${{ needs.load-env.outputs.autoware_base_cuda_image }}
LIB_DIR=x86_64
- name: Show disk space
Expand Down
16 changes: 12 additions & 4 deletions .github/workflows/load-env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,23 @@ name: load-env
on:
workflow_call:
outputs:
base_image:
value: ${{ jobs.load-env.outputs.base_image }}
rosdistro:
value: ${{ jobs.load-env.outputs.rosdistro }}
base_image:
value: ${{ jobs.load-env.outputs.base_image }}
autoware_base_image:
value: ${{ jobs.load-env.outputs.autoware_base_image }}
autoware_base_cuda_image:
value: ${{ jobs.load-env.outputs.autoware_base_cuda_image }}

jobs:
load-env:
runs-on: ubuntu-22.04
outputs:
base_image: ${{ steps.set-env.outputs.base_image }}
rosdistro: ${{ steps.set-env.outputs.rosdistro }}
base_image: ${{ steps.set-env.outputs.base_image }}
autoware_base_image: ${{ steps.set-env.outputs.autoware_base_image }}
autoware_base_cuda_image: ${{ steps.set-env.outputs.autoware_base_cuda_image }}
steps:
- name: Check out repository
uses: actions/checkout@v4
Expand All @@ -28,5 +34,7 @@ jobs:
- name: Set env
id: set-env
run: |
echo "base_image=${{ env.base_image }}" >> $GITHUB_OUTPUT
echo "rosdistro=${{ env.rosdistro }}" >> $GITHUB_OUTPUT
echo "base_image=${{ env.base_image }}" >> $GITHUB_OUTPUT
echo "autoware_base_image=${{ env.autoware_base_image }}" >> $GITHUB_OUTPUT
echo "autoware_base_cuda_image=${{ env.autoware_base_cuda_image }}" >> $GITHUB_OUTPUT
2 changes: 2 additions & 0 deletions amd64.env
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
rosdistro=humble
rmw_implementation=rmw_cyclonedds_cpp
base_image=ros:humble-ros-base-jammy
autoware_base_image=ghcr.io/autowarefoundation/autoware-base:latest
autoware_base_cuda_image=ghcr.io/autowarefoundation/autoware-base:cuda-latest
cuda_version=12.3
cudnn_version=8.9.5.29-1+cuda12.2
tensorrt_version=8.6.1.6-1+cuda12.0
Expand Down
74 changes: 18 additions & 56 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,52 +1,6 @@
ARG BASE_IMAGE

# hadolint ignore=DL3006
FROM $BASE_IMAGE AS base
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ARG ROS_DISTRO

# Copy files
COPY setup-dev-env.sh ansible-galaxy-requirements.yaml amd64.env arm64.env /autoware/
COPY ansible/ /autoware/ansible/
COPY docker/scripts/cleanup_apt.sh /autoware/cleanup_apt.sh
RUN chmod +x /autoware/cleanup_apt.sh
COPY docker/scripts/cleanup_system.sh /autoware/cleanup_system.sh
RUN chmod +x /autoware/cleanup_system.sh
WORKDIR /autoware

# Install apt packages and add GitHub to known hosts for private repositories
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
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends \
gosu \
ssh \
&& /autoware/cleanup_apt.sh \
&& mkdir -p ~/.ssh \
&& ssh-keyscan github.com >> ~/.ssh/known_hosts

# Set up base environment
RUN --mount=type=ssh \
--mount=type=cache,target=/var/cache/apt,sharing=locked \
./setup-dev-env.sh -y --module base --no-nvidia --no-cuda-drivers --runtime openadkit \
&& pip uninstall -y ansible ansible-core \
&& /autoware/cleanup_apt.sh \
&& echo "source /opt/ros/${ROS_DISTRO}/setup.bash" > /etc/bash.bashrc

# Create entrypoint
COPY docker/etc/ros_entrypoint.sh /ros_entrypoint.sh
RUN chmod +x /ros_entrypoint.sh
CMD ["/bin/bash"]

FROM base AS base-cuda
SHELL ["/bin/bash", "-o", "pipefail", "-c"]

# Set up CUDA runtime environment and artifacts
# hadolint ignore=SC2002
RUN --mount=type=ssh \
./setup-dev-env.sh -y --module base --download-artifacts --no-cuda-drivers --runtime openadkit \
&& pip uninstall -y ansible ansible-core \
&& /autoware/cleanup_apt.sh true
ARG AUTOWARE_BASE_IMAGE
ARG AUTOWARE_BASE_CUDA_IMAGE

# hadolint ignore=DL3006
FROM $BASE_IMAGE AS rosdep-depend

Check warning on line 6 in docker/Dockerfile

View workflow job for this annotation

GitHub Actions / docker-build-and-push

Default value for global ARG results in an empty or invalid base image name

InvalidDefaultArgInFrom: Default value for ARG $BASE_IMAGE results in empty or invalid base image name More info: https://docs.docker.com/go/dockerfile/rule/invalid-default-arg-in-from/
Expand Down Expand Up @@ -158,7 +112,8 @@ RUN /autoware/resolve_rosdep_keys.sh /autoware/src ${ROS_DISTRO} \
> /rosdep-exec-depend-packages.txt \
&& cat /rosdep-exec-depend-packages.txt

FROM base AS core-devel
# hadolint ignore=DL3006
FROM $AUTOWARE_BASE_IMAGE AS core-devel

Check warning on line 116 in docker/Dockerfile

View workflow job for this annotation

GitHub Actions / docker-build-and-push

Default value for global ARG results in an empty or invalid base image name

InvalidDefaultArgInFrom: Default value for ARG $AUTOWARE_BASE_IMAGE results in empty or invalid base image name More info: https://docs.docker.com/go/dockerfile/rule/invalid-default-arg-in-from/
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ARG ROS_DISTRO
ENV CCACHE_DIR="/root/.ccache"
Expand Down Expand Up @@ -413,7 +368,8 @@ COPY --from=universe-devel /opt/autoware /opt/autoware
ENTRYPOINT ["/ros_entrypoint.sh"]
CMD ["/bin/bash"]

FROM base AS universe-sensing-perception
# hadolint ignore=DL3006
FROM $AUTOWARE_BASE_IMAGE AS universe-sensing-perception

Check warning on line 372 in docker/Dockerfile

View workflow job for this annotation

GitHub Actions / docker-build-and-push

Default value for global ARG results in an empty or invalid base image name

InvalidDefaultArgInFrom: Default value for ARG $AUTOWARE_BASE_IMAGE results in empty or invalid base image name More info: https://docs.docker.com/go/dockerfile/rule/invalid-default-arg-in-from/
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ARG ROS_DISTRO
ARG LIB_DIR
Expand All @@ -438,7 +394,8 @@ RUN echo "source /opt/autoware/setup.bash" > /etc/bash.bashrc
ENTRYPOINT ["/ros_entrypoint.sh"]
CMD ["/bin/bash"]

FROM base-cuda AS universe-sensing-perception-cuda
# hadolint ignore=DL3006
FROM $AUTOWARE_BASE_CUDA_IMAGE AS universe-sensing-perception-cuda

Check warning on line 398 in docker/Dockerfile

View workflow job for this annotation

GitHub Actions / docker-build-and-push

Default value for global ARG results in an empty or invalid base image name

InvalidDefaultArgInFrom: Default value for ARG $AUTOWARE_BASE_CUDA_IMAGE results in empty or invalid base image name More info: https://docs.docker.com/go/dockerfile/rule/invalid-default-arg-in-from/
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ARG ROS_DISTRO
ARG LIB_DIR
Expand All @@ -459,7 +416,8 @@ COPY --from=universe-sensing-perception-devel-cuda /opt/autoware /opt/autoware
ENTRYPOINT ["/ros_entrypoint.sh"]
CMD ["/bin/bash"]

FROM base AS universe-localization-mapping
# hadolint ignore=DL3006
FROM $AUTOWARE_BASE_IMAGE AS universe-localization-mapping

Check warning on line 420 in docker/Dockerfile

View workflow job for this annotation

GitHub Actions / docker-build-and-push

Default value for global ARG results in an empty or invalid base image name

InvalidDefaultArgInFrom: Default value for ARG $AUTOWARE_BASE_IMAGE results in empty or invalid base image name More info: https://docs.docker.com/go/dockerfile/rule/invalid-default-arg-in-from/
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ARG ROS_DISTRO
ARG LIB_DIR
Expand All @@ -484,7 +442,8 @@ RUN echo "source /opt/autoware/setup.bash" > /etc/bash.bashrc
ENTRYPOINT ["/ros_entrypoint.sh"]
CMD ["/bin/bash"]

FROM base AS universe-planning-control
# hadolint ignore=DL3006
FROM $AUTOWARE_BASE_IMAGE AS universe-planning-control

Check warning on line 446 in docker/Dockerfile

View workflow job for this annotation

GitHub Actions / docker-build-and-push

Default value for global ARG results in an empty or invalid base image name

InvalidDefaultArgInFrom: Default value for ARG $AUTOWARE_BASE_IMAGE results in empty or invalid base image name More info: https://docs.docker.com/go/dockerfile/rule/invalid-default-arg-in-from/
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ARG ROS_DISTRO
ARG LIB_DIR
Expand All @@ -509,7 +468,8 @@ RUN echo "source /opt/autoware/setup.bash" > /etc/bash.bashrc
ENTRYPOINT ["/ros_entrypoint.sh"]
CMD ["/bin/bash"]

FROM base AS universe-vehicle-system
# hadolint ignore=DL3006
FROM $AUTOWARE_BASE_IMAGE AS universe-vehicle-system

Check warning on line 472 in docker/Dockerfile

View workflow job for this annotation

GitHub Actions / docker-build-and-push

Default value for global ARG results in an empty or invalid base image name

InvalidDefaultArgInFrom: Default value for ARG $AUTOWARE_BASE_IMAGE results in empty or invalid base image name More info: https://docs.docker.com/go/dockerfile/rule/invalid-default-arg-in-from/
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ARG ROS_DISTRO
ARG LIB_DIR
Expand All @@ -534,7 +494,8 @@ RUN echo "source /opt/autoware/setup.bash" > /etc/bash.bashrc
ENTRYPOINT ["/ros_entrypoint.sh"]
CMD ["/bin/bash"]

FROM base AS universe
# hadolint ignore=DL3006
FROM $AUTOWARE_BASE_IMAGE AS universe

Check warning on line 498 in docker/Dockerfile

View workflow job for this annotation

GitHub Actions / docker-build-and-push

Default value for global ARG results in an empty or invalid base image name

InvalidDefaultArgInFrom: Default value for ARG $AUTOWARE_BASE_IMAGE results in empty or invalid base image name More info: https://docs.docker.com/go/dockerfile/rule/invalid-default-arg-in-from/
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ARG ROS_DISTRO
ARG LIB_DIR
Expand All @@ -559,7 +520,8 @@ RUN echo "source /opt/autoware/setup.bash" > /etc/bash.bashrc
ENTRYPOINT ["/ros_entrypoint.sh"]
CMD ["/bin/bash"]

FROM base-cuda AS universe-cuda
# hadolint ignore=DL3006
FROM $AUTOWARE_BASE_CUDA_IMAGE AS universe-cuda

Check warning on line 524 in docker/Dockerfile

View workflow job for this annotation

GitHub Actions / docker-build-and-push

Default value for global ARG results in an empty or invalid base image name

InvalidDefaultArgInFrom: Default value for ARG $AUTOWARE_BASE_CUDA_IMAGE results in empty or invalid base image name More info: https://docs.docker.com/go/dockerfile/rule/invalid-default-arg-in-from/
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ARG ROS_DISTRO
ARG LIB_DIR
Expand Down
8 changes: 0 additions & 8 deletions docker/docker-bake-cuda.hcl
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
group "default" {
targets = [
"base-cuda",
"universe-sensing-perception-devel-cuda",
"universe-sensing-perception-cuda",
"universe-devel-cuda",
Expand All @@ -9,18 +8,11 @@ group "default" {
}

// For docker/metadata-action
target "docker-metadata-action-base-cuda" {}
target "docker-metadata-action-universe-sensing-perception-devel-cuda" {}
target "docker-metadata-action-universe-sensing-perception-cuda" {}
target "docker-metadata-action-universe-devel-cuda" {}
target "docker-metadata-action-universe-cuda" {}

target "base-cuda" {
inherits = ["docker-metadata-action-base-cuda"]
dockerfile = "docker/Dockerfile"
target = "base-cuda"
}

target "universe-sensing-perception-devel-cuda" {
inherits = ["docker-metadata-action-universe-sensing-perception-devel-cuda"]
dockerfile = "docker/Dockerfile"
Expand Down
8 changes: 0 additions & 8 deletions docker/docker-bake.hcl
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
group "default" {
targets = [
"base",
"core-devel",
"universe-sensing-perception-devel",
"universe-sensing-perception",
Expand All @@ -16,7 +15,6 @@ group "default" {
}

// For docker/metadata-action
target "docker-metadata-action-base" {}
target "docker-metadata-action-core-devel" {}
target "docker-metadata-action-universe-sensing-perception-devel" {}
target "docker-metadata-action-universe-sensing-perception" {}
Expand All @@ -29,12 +27,6 @@ target "docker-metadata-action-universe-vehicle-system" {}
target "docker-metadata-action-universe-devel" {}
target "docker-metadata-action-universe" {}

target "base" {
inherits = ["docker-metadata-action-base"]
dockerfile = "docker/Dockerfile"
target = "base"
}

target "core-devel" {
inherits = ["docker-metadata-action-core-devel"]
dockerfile = "docker/Dockerfile"
Expand Down

0 comments on commit 4148d65

Please sign in to comment.