diff --git a/README.md b/README.md index f7e14ee..bcabd85 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 \ No newline at end of file diff --git a/buildkitd.toml b/buildkitd.toml deleted file mode 100644 index 1ccadc0..0000000 --- a/buildkitd.toml +++ /dev/null @@ -1,11 +0,0 @@ -[worker.containerd] - enabled = false -[worker.oci] - enabled = true - gc = false -[registry."islandora.io"] - insecure=false - ca=["./certs/rootCA.pem"] - [[registry."islandora.io".keypair]] - key="./certs/privkey.pem" - cert="./certs/cert.pem" \ No newline at end of file diff --git a/certs/.gitkeep b/certs/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/docker-bake.hcl b/docker-bake.hcl index 1620450..9f79f64 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -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}"] @@ -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", @@ -47,6 +63,9 @@ group "ci" { ] } +############################################################################### +# Targets +############################################################################### target "common" { args = { # Required for reproduciable builds. @@ -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 @@ -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" { @@ -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") -} \ No newline at end of file +} + +target "imagemagick" { + inherits = ["imagemagick-common"] + cache-from = cacheFrom("imagemagick", hostArch()) + tags = tags("imagemagick", "") +} diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 36f3934..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- -version: "3.8" -name: isle-imagemagick - -# Common to all services -x-common: &common - restart: "no" - -volumes: - registry-data: {} - -networks: - default: - name: isle-imagemagick - -services: - registry: - <<: *common - image: registry:2.8.1 - container_name: isle-imagemagick-registry - environment: - REGISTRY_HTTP_ADDR: "0.0.0.0:443" - REGISTRY_STORAGE_DELETE_ENABLED: "true" - REGISTRY_HTTP_TLS_CERTIFICATE: "/usr/local/share/ca-certificates/cert.pem" - REGISTRY_HTTP_TLS_KEY: "/usr/local/share/ca-certificates/privkey.pem" - volumes: - - registry-data:/var/lib/registry - - ./certs/cert.pem:/usr/local/share/ca-certificates/cert.pem:ro - - ./certs/privkey.pem:/usr/local/share/ca-certificates/privkey.pem:ro - - ./certs/rootCA.pem:/usr/local/share/ca-certificates/rootCA.pem:ro - networks: - default: - aliases: [ "islandora.io" ] \ No newline at end of file