title: How to improve the Docker image build time when CI tool used is GitHub Actions
body: <p>We have a java application which uses maven, docker and Github actions.</p>
  <p>The below snippet is from our Dockerfile.</p>
  <pre><code>FROM maven:3.6.3-jdk-8-openj9 AS builder
  RUN mkdir /app
  WORKDIR /app
  ADD . .
  RUN mvn clean install
  </code></pre>
  <p>And then we have a deploy.yml for GitHub actions. The issue is that on GitHub actions, maven always downloads the dependencies and then creates a jar and finally a docker image is created.</p>
  <p>Using below tutorial, I have tried to implement caching in GitHub actions.
  <a href="https://evilmartians.com/chronicles/build-images-on-github-actions-with-docker-layer-caching" rel="nofollow noreferrer">https://evilmartians.com/chronicles/build-images-on-github-actions-with-docker-layer-caching</a></p>
  <p>The key for the cache in my case is calculated as below:
  key: ${{ runner.os }}-buildx-${{ hashFiles('pom.xml') }}</p>
  <p>Also made the following changes in the Dockerfile.</p>
  <pre><code>FROM maven:3.6.3-jdk-8-openj9 AS builder
  RUN mkdir /app
  WORKDIR /app
  ADD . .
  RUN mvn clean dependency:copy-dependencies
  ADD . .
  RUN mvn install
  </code></pre>
  <p>Still I do not see any significant changes in the reduction in build time.
  What I am trying to do is that I want the maven dependencies download as a separate layer in docker image, and caching this docker layer which can be later re-used in the final docker image build.</p>
  <p>If anyone can shade a light on this issue.</p>