Skip to content

Commit

Permalink
Change README to use isle-builder
Browse files Browse the repository at this point in the history
Instead of maintaining additional documentation on how to do cross
platform builds.
  • Loading branch information
nigelgbanks committed Dec 20, 2023
1 parent 5f42dbd commit a244709
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 97 deletions.
56 changes: 13 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@

- [Introduction](#introduction)
- [Requirements](#requirements)
- [Building](#building)
- [Local Registry](#local-registry)
- [Cleanup](#cleanup)
- [Host-platform Builds](#host-platform-builds)
- [Multi-platform builds](#multi-platform-builds)

## Introduction

Expand All @@ -21,62 +20,33 @@ both platforms it's been moved to it's own repository.

To build the Docker images using the provided Gradle build scripts requires:

- [Docker 19.03+](https://docs.docker.com/get-docker/)
- [mkcert](https://github.com/FiloSottile/mkcert)
- [Docker 20+](https://docs.docker.com/get-docker/)

## Building
## Host-platform Builds

You can build your host platform locally using the default builder like so.

```bash
docker buildx bake --builder default
docker context use default
docker buildx bake
```

### Local Registry
## Multi-platform builds

To test multi-arch builds and remote build caching requires setting up a local
registry.

You need to generate certificates for the local registry:
Please use [isle-builder] to create a builder to simplify this process. Using
the defaults provided, .e.g:

```bash
mkcert -install
cp $(mkcert -CAROOT)/* certs/
mkcert -cert-file ./certs/cert.pem -key-file ./certs/privkey.pem "*.islandora.dev" "islandora.dev" "*.islandora.io" "islandora.io" "*.islandora.info" "islandora.info" "localhost" "127.0.0.1" "::1"
```

A docker compose file is provided to setup a local registry:

```bash
docker compose up -d
```

Once the registry is setup can create a builder:

```bash
docker buildx create \
--bootstrap \
--config buildkitd.toml \
--driver-opt "image=moby/buildkit:v0.11.1,network=isle-imagemagick" \
--name "isle-imagemagick"
```

Now you can perform the build locally by pushing to the local registry:

```bash
REGISTRY=islandora.io docker buildx bake --builder isle-imagemagick ci --push
make start
```

## Cleanup

Remove the builder:
After which you should be able to build with the following command:

```bash
docker buildx rm isle-imagemagick
REPOSITORY=islandora.io docker buildx bake --builder isle-builder ci --push
```

Remove the registry:

```bash
docker compose down -v
```
[isle-builder]: https://github.com/Islandora-Devops/isle-builder
11 changes: 0 additions & 11 deletions buildkitd.toml

This file was deleted.

Empty file removed certs/.gitkeep
Empty file.
45 changes: 35 additions & 10 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ variable "TAG" {
default = "local"
}

###############################################################################
# Functions
###############################################################################
function hostArch {
params = []
result = equal("linux/amd64", BAKE_LOCAL_PLATFORM) ? "amd64" : "arm64" # Only two platforms supported.
}

function "tags" {
params = [image, arch]
result = ["${REPOSITORY}/${image}:${TAG}-${arch}"]
Expand All @@ -23,10 +31,18 @@ function "cacheFrom" {

function "cacheTo" {
params = [image, arch]
result = ["type=registry,oci-mediatypes=true,mode=max,compression=estargz,compression-level=5,ref=${REPOSITORY}/cache:${image}-${TAG}-${arch}"]
result = ["type=registry,oci-mediatypes=true,mode=max,compression=estargz,compression-level=5,ref=${REPOSITORY}/cache:${image}-${TAG}-${arch}"]
}

###############################################################################
# Groups
###############################################################################
group "default" {
targets = [
"imagemagick",
]
}

# No default target is specified.
group "amd64" {
targets = [
"imagemagick-amd64",
Expand All @@ -47,6 +63,9 @@ group "ci" {
]
}

###############################################################################
# Targets
###############################################################################
target "common" {
args = {
# Required for reproduciable builds.
Expand All @@ -58,7 +77,7 @@ target "common" {

target "imagemagick-common" {
inherits = ["common"]
context = "imagemagick"
context = "imagemagick"
contexts = {
# The digest (sha256 hash) is not platform specific but the digest for the manifest of all platforms.
# It will be the digest printed when you do: docker pull alpine:3.17.1
Expand All @@ -69,10 +88,10 @@ target "imagemagick-common" {
}

target "imagemagick-amd64" {
inherits = ["imagemagick-common"]
tags = tags("imagemagick", "amd64")
inherits = ["imagemagick-common"]
tags = tags("imagemagick", "amd64")
cache-from = cacheFrom("imagemagick", "amd64")
platforms = ["linux/amd64"]
platforms = ["linux/amd64"]
}

target "imagemagick-amd64-ci" {
Expand All @@ -81,13 +100,19 @@ target "imagemagick-amd64-ci" {
}

target "imagemagick-arm64" {
inherits = ["imagemagick-common"]
tags = tags("imagemagick", "arm64")
inherits = ["imagemagick-common"]
tags = tags("imagemagick", "arm64")
cache-from = cacheFrom("imagemagick", "arm64")
platforms = ["linux/arm64"]
platforms = ["linux/arm64"]
}

target "imagemagick-arm64-ci" {
inherits = ["imagemagick-arm64"]
cache-to = cacheTo("imagemagick", "arm64")
}
}

target "imagemagick" {
inherits = ["imagemagick-common"]
cache-from = cacheFrom("imagemagick", hostArch())
tags = tags("imagemagick", "")
}
33 changes: 0 additions & 33 deletions docker-compose.yml

This file was deleted.

0 comments on commit a244709

Please sign in to comment.