diff --git a/.github/actions/docker-build-and-push/action.yaml b/.github/actions/docker-build-and-push/action.yaml index c0b9634baba..b79da13fa23 100644 --- a/.github/actions/docker-build-and-push/action.yaml +++ b/.github/actions/docker-build-and-push/action.yaml @@ -27,57 +27,20 @@ runs: sudo apt-get -y install jq shell: bash - # workflow_dispatch: latest, date - # schedule: latest, date - # tag: semver - - name: Set Docker tags - id: set-docker-tags - run: | - tags=() - if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then - tags+=("latest") - tags+=("{{date 'YYYYMMDD'}}") - else - tags+=("type=schedule,pattern=latest") - tags+=("type=schedule,pattern={{date 'YYYYMMDD'}}") - tags+=("type=semver,pattern={{version}}") - tags+=("type=match,pattern=\d+.\d+") - fi - - # Workaround for multiline strings - # https://github.community/t/set-output-truncates-multiline-strings/16852 - tags_multiline=$(printf "%s\n" "${tags[@]}") - tags_multiline="${tags_multiline//'%'/'%25'}" - tags_multiline="${tags_multiline//$'\n'/'%0A'}" - tags_multiline="${tags_multiline//$'\r'/'%0D'}" - - echo ::set-output name=tags::$tags_multiline - shell: bash - - - name: Docker meta for devel - id: meta-devel + - name: Docker meta for runtime + id: meta-runtime uses: docker/metadata-action@v4 with: images: ghcr.io/${{ github.repository_owner }}/${{ inputs.bake-target }} - tags: ${{ steps.set-docker-tags.outputs.tags }} - bake-target: docker-metadata-action-devel + tags: | + type=raw,value=latest + type=raw,value={{date 'YYYYMMDD'}} + bake-target: docker-metadata-action-runtime flavor: | latest=false prefix=${{ inputs.tag-prefix }} suffix=${{ inputs.tag-suffix }} - - name: Docker meta for prebuilt - id: meta-prebuilt - uses: docker/metadata-action@v4 - with: - images: ghcr.io/${{ github.repository_owner }}/${{ inputs.bake-target }} - tags: ${{ steps.set-docker-tags.outputs.tags }} - bake-target: docker-metadata-action-prebuilt - flavor: | - latest=false - prefix=${{ inputs.tag-prefix }} - suffix=-prebuilt${{ inputs.tag-suffix }} - - name: Login to GitHub Container Registry if: ${{ github.event_name != 'pull_request' }} uses: docker/login-action@v2 @@ -93,7 +56,6 @@ runs: push: ${{ github.event_name == 'schedule' || github.ref_name == github.event.repository.default_branch || github.event_name == 'push'}} files: | docker/${{ inputs.bake-target }}/docker-bake.hcl - ${{ steps.meta-devel.outputs.bake-file }} - ${{ steps.meta-prebuilt.outputs.bake-file }} + ${{ steps.meta-runtime.outputs.bake-file }} set: | ${{ inputs.build-args }} diff --git a/.github/workflows/docker-build-and-push-main.yaml b/.github/workflows/docker-build-and-push-main.yaml index 0dc3df7f6af..87a3337fe0b 100644 --- a/.github/workflows/docker-build-and-push-main.yaml +++ b/.github/workflows/docker-build-and-push-main.yaml @@ -1,8 +1,6 @@ name: docker-build-and-push-main on: - schedule: - - cron: 0 0 1,15 * * workflow_dispatch: jobs: @@ -12,9 +10,9 @@ jobs: fail-fast: false matrix: name: - - no-cuda + - no-nvidia include: - - name: no-cuda + - name: no-nvidia base_image_env: base_image setup-args: --no-nvidia additional-tag-suffix: "" @@ -40,7 +38,6 @@ jobs: *.platform=linux/amd64 *.args.ROS_DISTRO=${{ env.rosdistro }} *.args.BASE_IMAGE=${{ env[format('{0}', matrix.base_image_env)] }} - *.args.PREBUILT_BASE_IMAGE=${{ env.prebuilt_base_image }} *.args.SETUP_ARGS=${{ matrix.setup-args }} tag-prefix: ${{ env.rosdistro }}- tag-suffix: ${{ matrix.additional-tag-suffix }}-amd64 diff --git a/amd64.env b/amd64.env index afa17255034..1366bd83c91 100644 --- a/amd64.env +++ b/amd64.env @@ -2,7 +2,6 @@ rosdistro=humble rmw_implementation=rmw_cyclonedds_cpp base_image=ubuntu:22.04 cuda_base_image=ubuntu:22.04 -prebuilt_base_image=ubuntu:22.04 cuda_version=11.6 cudnn_version=8.4.1.50-1+cuda11.6 tensorrt_version=8.4.2-1+cuda11.6 diff --git a/docker/autoware-universe/Dockerfile b/docker/autoware-universe/Dockerfile index 9af0b8293fe..a53632b0dcd 100644 --- a/docker/autoware-universe/Dockerfile +++ b/docker/autoware-universe/Dockerfile @@ -1,128 +1,74 @@ -# Image args should come at the beginning. +# hadolint global ignore=DL3006,DL3008 ARG BASE_IMAGE -ARG PREBUILT_BASE_IMAGE -# hadolint ignore=DL3006 + +# ============================================================================== FROM $BASE_IMAGE as devel SHELL ["/bin/bash", "-o", "pipefail", "-c"] - ARG ROS_DISTRO ARG SETUP_ARGS -## Install apt packages -# hadolint ignore=DL3008 +# Install apt packages RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends \ git \ ssh \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* + && apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* "$HOME"/.cache + +# Add GitHub to known hosts for private repositories +RUN mkdir -p ~/.ssh \ + && ssh-keyscan github.com >> ~/.ssh/known_hosts -## Copy files +# Copy files COPY autoware.repos setup-dev-env.sh ansible-galaxy-requirements.yaml amd64.env arm64.env /autoware/ COPY ansible/ /autoware/ansible/ WORKDIR /autoware -RUN ls /autoware - -## Add GitHub to known hosts for private repositories -RUN mkdir -p ~/.ssh \ - && ssh-keyscan github.com >> ~/.ssh/known_hosts -## Set up development environment +# Set up development environment RUN --mount=type=ssh \ - ./setup-dev-env.sh -y $SETUP_ARGS universe \ + ./setup-dev-env.sh -y --runtime $SETUP_ARGS universe \ && pip uninstall -y ansible ansible-core \ && mkdir src \ && vcs import src < autoware.repos \ && rosdep update \ && DEBIAN_FRONTEND=noninteractive rosdep install -y --ignore-src --from-paths src --rosdistro "$ROS_DISTRO" \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* + && apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* "$HOME"/.cache -## Clean up unnecessary files +# Clean up unnecessary files RUN rm -rf \ - "$HOME"/.cache \ /etc/apt/sources.list.d/cuda*.list \ /etc/apt/sources.list.d/docker.list \ /etc/apt/sources.list.d/nvidia-docker.list -## Register Vulkan GPU vendors -RUN curl https://gitlab.com/nvidia/container-images/vulkan/raw/dc389b0445c788901fda1d85be96fd1cb9410164/nvidia_icd.json -o /etc/vulkan/icd.d/nvidia_icd.json \ - && chmod 644 /etc/vulkan/icd.d/nvidia_icd.json -RUN curl https://gitlab.com/nvidia/container-images/opengl/raw/5191cf205d3e4bb1150091f9464499b076104354/glvnd/runtime/10_nvidia.json -o /etc/glvnd/egl_vendor.d/10_nvidia.json \ - && chmod 644 /etc/glvnd/egl_vendor.d/10_nvidia.json +# Register Vulkan GPU vendors +ADD "https://gitlab.com/nvidia/container-images/vulkan/raw/dc389b0445c788901fda1d85be96fd1cb9410164/nvidia_icd.json" /etc/vulkan/icd.d/nvidia_icd.json +RUN chmod 644 /etc/vulkan/icd.d/nvidia_icd.json +ADD "https://gitlab.com/nvidia/container-images/opengl/raw/5191cf205d3e4bb1150091f9464499b076104354/glvnd/runtime/10_nvidia.json" /etc/glvnd/egl_vendor.d/10_nvidia.json +RUN chmod 644 /etc/glvnd/egl_vendor.d/10_nvidia.json -## Register OpenCL GPU vendors +# Register OpenCL GPU vendors RUN mkdir -p /etc/OpenCL/vendors \ && echo "libnvidia-opencl.so.1" > /etc/OpenCL/vendors/nvidia.icd \ && chmod 644 /etc/OpenCL/vendors/nvidia.icd -## Create entrypoint -# hadolint ignore=DL3059 -RUN echo "source /opt/ros/${ROS_DISTRO}/setup.bash" > /etc/bash.bashrc -CMD ["/bin/bash"] - -FROM devel as builder +# ============================================================================== +FROM devel as prebuilt SHELL ["/bin/bash", "-o", "pipefail", "-c"] -## Build and change permission for runtime data conversion +# Build and change permission for runtime data conversion RUN source /opt/ros/"$ROS_DISTRO"/setup.bash \ && colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release \ && find /autoware/install -type d -exec chmod 777 {} \; -# hadolint ignore=DL3006 -FROM $PREBUILT_BASE_IMAGE as prebuilt - -SHELL ["/bin/bash", "-o", "pipefail", "-c"] - -ARG ROS_DISTRO -ARG SETUP_ARGS - -## Install apt packages -# hadolint ignore=DL3008 -RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends \ - git \ - ssh \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* - -## Copy files -COPY autoware.repos setup-dev-env.sh ansible-galaxy-requirements.yaml amd64.env arm64.env /autoware/ -COPY ansible/ /autoware/ansible/ -WORKDIR /autoware -RUN ls /autoware - -## Add GitHub to known hosts for private repositories -RUN mkdir -p ~/.ssh \ - && ssh-keyscan github.com >> ~/.ssh/known_hosts - -## Set up runtime environment -RUN --mount=type=ssh \ - ./setup-dev-env.sh -y $SETUP_ARGS --no-cuda-drivers --runtime universe \ - && pip uninstall -y ansible ansible-core \ - && mkdir src \ - && vcs import src < autoware.repos \ - && rosdep update \ - && DEBIAN_FRONTEND=noninteractive rosdep install -y --ignore-src --from-paths src --rosdistro "$ROS_DISTRO" \ - && rm -rf src \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* - -## Copy install folder from builder -COPY --from=builder /autoware/install/ /autoware/install/ +# Create entrypoint +RUN echo "source /autoware/install/setup.bash" > /etc/bash.bashrc +CMD ["/bin/bash"] -## Clean up unnecessary files -RUN rm -rf \ - "$HOME"/.cache \ - /etc/apt/sources.list.d/cuda*.list \ - /etc/apt/sources.list.d/docker.list \ - /etc/apt/sources.list.d/nvidia-docker.list +# ============================================================================== +FROM devel as runtime -## Register Vulkan GPU vendors -ADD "https://gitlab.com/nvidia/container-images/vulkan/raw/dc389b0445c788901fda1d85be96fd1cb9410164/nvidia_icd.json" /etc/vulkan/icd.d/nvidia_icd.json -RUN chmod 644 /etc/vulkan/icd.d/nvidia_icd.json -ADD "https://gitlab.com/nvidia/container-images/opengl/raw/5191cf205d3e4bb1150091f9464499b076104354/glvnd/runtime/10_nvidia.json" /etc/glvnd/egl_vendor.d/10_nvidia.json -RUN chmod 644 /etc/glvnd/egl_vendor.d/10_nvidia.json +# Remove setup files and copy install directory +RUN rm -rf /autoware/* +COPY --from=prebuilt /autoware/install/ /autoware/install/ -## Create entrypoint -# hadolint ignore=DL3059 +# Create entrypoint RUN echo "source /autoware/install/setup.bash" > /etc/bash.bashrc CMD ["/bin/bash"] diff --git a/docker/autoware-universe/docker-bake.hcl b/docker/autoware-universe/docker-bake.hcl index fa5b3dff25f..35ce50486fd 100644 --- a/docker/autoware-universe/docker-bake.hcl +++ b/docker/autoware-universe/docker-bake.hcl @@ -1,19 +1,29 @@ group "default" { - targets = ["devel", "prebuilt"] + targets = ["devel", "prebuilt", "runtime"] } // For docker/metadata-action target "docker-metadata-action-devel" {} target "docker-metadata-action-prebuilt" {} +target "docker-metadata-action-runtime" {} +// For source image target "devel" { inherits = ["docker-metadata-action-devel"] dockerfile = "docker/autoware-universe/Dockerfile" target = "devel" } +// For prebuilt image target "prebuilt" { inherits = ["docker-metadata-action-prebuilt"] dockerfile = "docker/autoware-universe/Dockerfile" target = "prebuilt" } + +// For runtime image +target "runtime" { + inherits = ["docker-metadata-action-runtime"] + dockerfile = "docker/autoware-universe/Dockerfile" + target = "runtime" +} diff --git a/docker/build.sh b/docker/build.sh index 36b31b17ba7..71eea907a7f 100755 --- a/docker/build.sh +++ b/docker/build.sh @@ -9,16 +9,13 @@ WORKSPACE_ROOT="$SCRIPT_DIR/../" args=() while [ "$1" != "" ]; do case "$1" in - --no-cuda) - option_no_cuda=true + --no-nvidia) + option_no_nvidia=true ;; --platform) option_platform="$2" shift ;; - --no-prebuilt) - option_no_prebuilt=true - ;; *) args+=("$1") ;; @@ -27,7 +24,7 @@ while [ "$1" != "" ]; do done # Set CUDA options -if [ "$option_no_cuda" = "true" ]; then +if [ "$option_no_nvidia" = "true" ]; then setup_args="--no-nvidia" image_name_suffix="" else @@ -35,14 +32,6 @@ else image_name_suffix="-cuda" fi -# Set prebuilt options -if [ "$option_no_prebuilt" = "true" ]; then - targets=("devel") -else - # default targets include devel and prebuilt - targets=() -fi - # Set platform if [ -n "$option_platform" ]; then platform="$option_platform" @@ -69,9 +58,8 @@ docker buildx bake --no-cache --load --progress=plain -f "$SCRIPT_DIR/autoware-u --set "*.platform=$platform" \ --set "*.args.ROS_DISTRO=$rosdistro" \ --set "*.args.BASE_IMAGE=$base_image" \ - --set "*.args.PREBUILT_BASE_IMAGE=$prebuilt_base_image" \ --set "*.args.SETUP_ARGS=$setup_args" \ - --set "devel.tags=ghcr.io/automotiveaichallenge/autoware-universe:$rosdistro-latest$image_name_suffix" \ + --set "devel.tags=ghcr.io/automotiveaichallenge/autoware-universe:$rosdistro-latest-devel$image_name_suffix" \ --set "prebuilt.tags=ghcr.io/automotiveaichallenge/autoware-universe:$rosdistro-latest-prebuilt$image_name_suffix" \ - "${targets[@]}" + --set "runtime.tags=ghcr.io/automotiveaichallenge/autoware-universe:$rosdistro-latest-runtime$image_name_suffix" set +x