Skip to content

Commit

Permalink
Changed plugin to use buildx.
Browse files Browse the repository at this point in the history
Now supports:
 - multi-arch builds
 - full caching for intemediate layers
 - pushing to local registry
 - building non latest tag.
  • Loading branch information
nigelgbanks committed Mar 23, 2021
1 parent bd3ef6f commit feed59a
Show file tree
Hide file tree
Showing 18 changed files with 1,625 additions and 367 deletions.
34 changes: 17 additions & 17 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Java
uses: actions/setup-java@v1
with:
java-version: 8
- name: Setup Gradle Cache
uses: actions/cache@v1
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Build Plugin
uses: eskatos/gradle-command-action@v1
with:
arguments: build --info
- name: Checkout
uses: actions/checkout@v2
- name: Setup Java
uses: actions/setup-java@v1
with:
java-version: 8
- name: Setup Gradle Cache
uses: actions/cache@v1
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Build Plugin
uses: eskatos/gradle-command-action@v1
with:
arguments: build --info
48 changes: 24 additions & 24 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
name: Release
on:
release:
types: [published]
types: [ published ]
jobs:
build:
name: Publish Gradle Plugin
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Java
uses: actions/setup-java@v1
with:
java-version: 8
- name: Setup Gradle Cache
uses: actions/cache@v1
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Set Version Environment Variable
run: |
export NEW_VERSION=$(echo "${GITHUB_REF}" | cut -d "/" -f3)
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
- name: Publish Gradle Plugin
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: eskatos/gradle-command-action@v1
with:
arguments: build publish -Pversion=${{ env.NEW_VERSION }} --info
- name: Checkout
uses: actions/checkout@v2
- name: Setup Java
uses: actions/setup-java@v1
with:
java-version: 8
- name: Setup Gradle Cache
uses: actions/cache@v1
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Set Version Environment Variable
run: |
export NEW_VERSION=$(echo "${GITHUB_REF}" | cut -d "/" -f3)
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
- name: Publish Gradle Plugin
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: eskatos/gradle-command-action@v1
with:
arguments: build publish -Pversion=${{ env.NEW_VERSION }} --info
57 changes: 24 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,22 @@
- [Introduction](#introduction)
- [Requirements](#requirements)
- [Building](#building)
- [Build and Publish the Plugin](#build-and-publish-the-plugin)
- [Build and Publish the Plugin](#build-and-publish-the-plugin)
- [Using the Plugin](#using-the-plugin)

## Introduction

This repository provides a Gradle plugin that supports building interdependent
Docker images with [Buildkit] support.
This repository provides a Gradle plugin that supports building interdependent Docker images with [Buildkit] support.

The plugin is setup such that it will automatically detect which folders should
be considered
[projects](https://docs.gradle.org/current/dsl/org.gradle.api.Project.html) and
what dependencies exist between them. The only caveat is that the projects
cannot be nested, though that use case does not really apply.
The plugin is setup such that it will automatically detect which folders should be considered
[projects](https://docs.gradle.org/current/dsl/org.gradle.api.Project.html) and what dependencies exist between them.
The only caveat is that the projects cannot be nested, though that use case does not really apply.

The dependencies are resolved by parsing the Dockerfile and looking for ``FROM``
statements to determine which images are required to build it.

This means to add a new Docker image to the project you do not need to modify
the build scripts, simply add a new folder and place your Dockerfile inside of
it and it will be discovered built in the correct order relative to the other
This means to add a new Docker image to the project you do not need to modify the build scripts, simply add a new folder
and place your Dockerfile inside of it and it will be discovered built in the correct order relative to the other
images.

## Requirements
Expand All @@ -36,10 +32,9 @@ To build this plugin the following is required:

## Building

The build scripts rely on Gradle and should function equally well across
platforms. The only difference being the script you call to interact with gradle
(the following assumes you are executing from the **root directory** of the
project):
The build scripts rely on Gradle and should function equally well across platforms. The only difference being the script
you call to interact with gradle
(the following assumes you are executing from the **root directory** of the project):

**Linux or OSX:**

Expand All @@ -53,11 +48,10 @@ project):
gradlew.bat
```

For the remaining examples the **Linux or OSX** call method will be used, if
using Windows substitute the call to Gradle script.
For the remaining examples the **Linux or OSX** call method will be used, if using Windows substitute the call to Gradle
script.

Gradle is a project/task based build system to query all the available tasks use
the following command.
Gradle is a project/task based build system to query all the available tasks use the following command.

```bash
./gradlew tasks --all
Expand All @@ -75,9 +69,9 @@ Tasks runnable from root project
Build tasks
-----------
assemble - Assembles the outputs of this project.
build - Assembles and tests this project.
buildDependents - Assembles and tests this project and all projects that depend on it.
buildNeeded - Assembles and tests this project and all projects it depends on.
build - Assembles and tasks.tests this project.
buildDependents - Assembles and tasks.tests this project and all projects that depend on it.
buildNeeded - Assembles and tasks.tests this project and all projects it depends on.
classes - Assembles main classes.
clean - Deletes the build directory.
jar - Assembles a jar archive containing the main classes.
Expand All @@ -86,13 +80,13 @@ testClasses - Assembles test classes.
...
```

In Gradle each Project maps onto a folder in the file system path where it is
delimited by ``:`` instead of ``/`` (Unix) or ``\`` (Windows).
In Gradle each Project maps onto a folder in the file system path where it is delimited by ``:`` instead of ``/`` (Unix)
or ``\`` (Windows).

The root project ``:`` can be omitted.

So if you want to run a particular task ``taskname`` that resided in the project
folder ``project/subproject`` you would specify it like so:
So if you want to run a particular task ``taskname`` that resided in the project folder ``project/subproject`` you would
specify it like so:

```bash
./gradlew :project:subproject:taskname
Expand All @@ -114,8 +108,7 @@ The following will build and test the plugin.
./gradlew build
```

The following will publish the module to Github packages, which requires you
setup a personal access token.
The following will publish the module to Github packages, which requires you setup a personal access token.

```bash
export GITHUB_REPOSITORY=Islandora-Devops/isle-gradle-docker-plugin
Expand All @@ -124,16 +117,14 @@ export GITHUB_TOKEN=XXXXXXXXXXXXXXXXX
./gradlew build publish
```

Alternatively you can rely on the Github actions which will publish when a
release is made.
Alternatively you can rely on the Github actions which will publish when a release is made.

> N.B. It is NOT POSSIBLE to delete/replace packages on a public repository (except *-SNAPSHOT). A new release must be made.
## Using the Plugin

To include this plugin in another project use the following snippet of Kotlin script in
your Gradle project with the `settings.gradle.kts` file that allows the plugin
source to be discoverable:
To include this plugin in another project use the following snippet of Kotlin script in your Gradle project with
the `settings.gradle.kts` file that allows the plugin source to be discoverable:

```kotlin
sourceControl {
Expand Down
8 changes: 7 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import java.text.SimpleDateFormat
import java.util.Date
import java.util.*

plugins {
`kotlin-dsl`
Expand All @@ -14,6 +14,8 @@ repositories {

dependencies {
implementation("com.bmuschko:gradle-docker-plugin:6.7.0")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.9.8")
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.9.8")
}

java {
Expand Down Expand Up @@ -48,4 +50,8 @@ publishing {
}
}
}
}

kotlinDslPluginOptions {
experimentalWarning.set(false)
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
org.gradle.parallel=true
org.gradle.caching=true
version=0.0.3-SNAPSHOT
version=0.0.4-SNAPSHOT
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit feed59a

Please sign in to comment.