Skip to content

Commit

Permalink
Enable caching for building docker images (#633)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vatan Aksoy Tezer authored Aug 24, 2021
1 parent 31470cc commit 2fdd06c
Showing 1 changed file with 74 additions and 47 deletions.
121 changes: 74 additions & 47 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: docker

on:
schedule:
# 5 PM UTC every Sunday
- cron: '0 17 * * 6'
workflow_dispatch:
push:
branches:
Expand All @@ -20,18 +23,24 @@ jobs:
IMAGE: ghcr.io/ros-planning/moveit2:${{ matrix.ROS_DISTRO }}-${{ github.job }}

steps:
- uses: actions/checkout@v2

- name: Build image
run: |
echo Building docker ${{ env.IMAGE }}
docker build . --build-arg ROS_DISTRO=${{ matrix.ROS_DISTRO }} --file .docker/${{ github.job }}/Dockerfile --tag ${{ env.IMAGE }}
- name: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

- name: Push image
run: docker push ${{ env.IMAGE }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to Github Containter Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push
uses: docker/build-push-action@v2
with:
file: .docker/${{ github.job }}/Dockerfile
build-args: ROS_DISTRO=${{ matrix.ROS_DISTRO }}
push: true
no_cache: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
cache-from: type=registry,ref=${{ env.IMAGE }}
cache-to: type=inline
tags: ${{ env.IMAGE }}

ci:
strategy:
Expand All @@ -46,18 +55,24 @@ jobs:
IMAGE: ghcr.io/ros-planning/moveit2:${{ matrix.ROS_DISTRO }}-${{ github.job }}

steps:
- uses: actions/checkout@v2

- name: Build image
run: |
echo Building docker ${{ env.IMAGE }}
docker build . --build-arg ROS_DISTRO=${{ matrix.ROS_DISTRO }} --file .docker/${{ github.job }}/Dockerfile --tag ${{ env.IMAGE }}
- name: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

- name: Push image
run: docker push ${{ env.IMAGE }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to Github Containter Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push
uses: docker/build-push-action@v2
with:
file: .docker/${{ github.job }}/Dockerfile
build-args: ROS_DISTRO=${{ matrix.ROS_DISTRO }}
push: true
no_cache: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
cache-from: type=registry,ref=${{ env.IMAGE }}
cache-to: type=inline
tags: ${{ env.IMAGE }}

ci-testing:
needs: ci
Expand All @@ -73,18 +88,25 @@ jobs:
IMAGE: ghcr.io/ros-planning/moveit2:${{ matrix.ROS_DISTRO }}-${{ github.job }}

steps:
- uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to Github Containter Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push
uses: docker/build-push-action@v2
with:
file: .docker/${{ github.job }}/Dockerfile
build-args: ROS_DISTRO=${{ matrix.ROS_DISTRO }}
push: true
no_cache: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
cache-from: type=registry,ref=${{ env.IMAGE }}
cache-to: type=inline
tags: ${{ env.IMAGE }}

- name: Build image
run: |
echo Building docker ${{ env.IMAGE }}
docker build . --build-arg ROS_DISTRO=${{ matrix.ROS_DISTRO }} --file .docker/${{ github.job }}/Dockerfile --tag ${{ env.IMAGE }}
- name: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

- name: Push image
run: docker push ${{ env.IMAGE }}

source:
needs: ci-testing
Expand All @@ -100,15 +122,20 @@ jobs:
IMAGE: ghcr.io/ros-planning/moveit2:${{ matrix.ROS_DISTRO }}-${{ github.job }}

steps:
- uses: actions/checkout@v2

- name: Build image
run: |
echo Building docker ${{ env.IMAGE }}
docker build . --build-arg ROS_DISTRO=${{ matrix.ROS_DISTRO }} --file .docker/${{ github.job }}/Dockerfile --tag ${{ env.IMAGE }}
- name: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

- name: Push image
run: docker push ${{ env.IMAGE }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to Github Containter Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push
uses: docker/build-push-action@v2
with:
file: .docker/${{ github.job }}/Dockerfile
build-args: ROS_DISTRO=${{ matrix.ROS_DISTRO }}
push: true
cache-from: type=registry,ref=${{ env.IMAGE }}
cache-to: type=inline
tags: ${{ env.IMAGE }}

0 comments on commit 2fdd06c

Please sign in to comment.