Skip to content

Commit

Permalink
Fix and optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
doganulus committed Jul 20, 2024
1 parent 269af34 commit bb73ab9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 14 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/builder-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.AUTOWARE_VERSION }}-builder
load: true
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest-builder
no-cache: true
cache-to: type=inline

- name: Build builder w/cache image
Expand All @@ -78,10 +78,9 @@ jobs:
load: true
cache-from: |
type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.AUTOWARE_VERSION }}-builder
type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.AUTOWARE_VERSION }}-builder-builder-with-cache
type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.AUTOWARE_VERSION }}-builder-with-cache
cache-to: type=inline

# Push the builder image to the registry
- name: Push builder image
uses: docker/build-push-action@v6
with:
Expand All @@ -93,7 +92,8 @@ jobs:
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest-builder
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.AUTOWARE_VERSION }}-builder
push: true
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest-builder
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.AUTOWARE_VERSION }}-builder
cache-to: type=inline

- name: Push builder-with-cache image
uses: docker/build-push-action@v6
Expand All @@ -108,4 +108,5 @@ jobs:
push: true
cache-from: |
type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.AUTOWARE_VERSION }}-builder
type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.AUTOWARE_VERSION }}-builder-builder-with-cache
type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.AUTOWARE_VERSION }}-builder-with-cache
cache-to: type=inline
32 changes: 23 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -125,55 +125,69 @@ ENV PATH="/usr/local/cuda-12.4/bin:${PATH}"

FROM autoware-builder AS autoware-builder-with-cache

#
# This build is only for producing a build cache to be saved in the image.
# Hence, we do not want build artifacts and logs.
#
RUN --mount=type=bind,from=autoware-source,source=${AUTOWARE_SOURCE_DIR},target=${AUTOWARE_SOURCE_DIR} \
--mount=type=cache,target=${AUTOWARE_BUILD_DIR},id=autoware-build-${AUTOWARE_VERSION} \
ccache --zero-stats && \
. /opt/ros/humble/setup.sh && \
colcon build \
--base-paths ${AUTOWARE_SOURCE_DIR} \
--build-base ${AUTOWARE_BUILD_DIR} \
--install-base /dev/null \
--log-base /dev/null \
--packages-up-to autoware_launch \
--event-handlers \
console_direct- \
console_stderr+ \
console_cohesion- \
console_start_end- \
console_package_list- \
status+ \
summary- \
status- \
summary+ \
desktop_notification- \
--cmake-args \
-DCMAKE_BUILD_TYPE=Release \
" -Wno-dev" \
" --no-warn-unused-cli" \
&& ccache -v --show-stats
&& du -h --max-depth=0 ${CCACHE_DIR}

USER bounverif
WORKDIR /home/bounverif

FROM autoware-builder-with-cache AS autoware-prebuilt

USER root

COPY autoware.repos.yml /var/lib/autoware/autoware.repos.${AUTOWARE_VERSION}.yml

RUN mkdir -p ${AUTOWARE_SOURCE_DIR} && vcs import --shallow ${AUTOWARE_SOURCE_DIR} < /var/lib/autoware/autoware.repos.${AUTOWARE_VERSION}.yml

RUN --mount=type=cache,target=${AUTOWARE_BUILD_DIR},id=autoware-build-${AUTOWARE_VERSION} \
ccache --zero-stats && \
RUN ccache --zero-stats && \
. /opt/ros/humble/setup.sh && \
colcon build \
--base-paths ${AUTOWARE_SOURCE_DIR} \
--build-base ${AUTOWARE_BUILD_DIR} \
--install-base ${AUTOWARE_INSTALL_DIR} \
--log-base /dev/null \
--packages-up-to autoware_launch \
--event-handlers \
console_direct- \
console_stderr+ \
console_cohesion- \
console_start_end- \
console_package_list- \
status+ \
summary- \
status- \
summary+ \
desktop_notification- \
--cmake-args \
-DCMAKE_BUILD_TYPE=Release \
" -Wno-dev" \
" --no-warn-unused-cli" \
&& ccache -v --show-stats

USER bounverif
WORKDIR /home/bounverif

FROM autoware-base AS autoware-runtime

Expand Down

0 comments on commit bb73ab9

Please sign in to comment.