Skip to content

Commit

Permalink
Update leptonica and make the build process the same as imagemagick
Browse files Browse the repository at this point in the history
  • Loading branch information
nigelgbanks committed Aug 4, 2024
1 parent 95a8570 commit 52f717f
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 140 deletions.
58 changes: 14 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@

- [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

This repository provides the `islandora/leptonica` image which only exists
This repository provides the `islandora/imagemagick` image which only exists
to provide a custom Alpine APK package(s).

Since this does not change often and takes a very long time to cross compile for
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-leptonica" \
--name "isle-leptonica"
```

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

```bash
REGISTRY=islandora.io docker buildx bake --builder isle-leptonica 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-leptonica
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.
72 changes: 22 additions & 50 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
@@ -1,27 +1,16 @@
###############################################################################
# Variables
###############################################################################
variable "REPOSITORY" {
default = "islandora"
}

variable "CACHE_FROM_REPOSITORY" {
default = "islandora"
variable "SOURCE_DATE_EPOCH" {
default = "0"
}

variable "CACHE_TO_REPOSITORY" {
variable "REPOSITORY" {
default = "islandora"
}

variable "TAG" {
# "local" is to distinguish that from builds produced locally.
# "local" is to distinguish remote images from those produced locally.
default = "local"
}

variable "SOURCE_DATE_EPOCH" {
default = "0"
}

###############################################################################
# Functions
###############################################################################
Expand All @@ -37,20 +26,20 @@ function "tags" {

function "cacheFrom" {
params = [image, arch]
result = ["type=registry,ref=${CACHE_FROM_REPOSITORY}/cache:${image}-main-${arch}", "type=registry,ref=${CACHE_FROM_REPOSITORY}/cache:${image}-${TAG}-${arch}"]
result = ["type=registry,ref=${REPOSITORY}/cache:${image}-main-${arch}", "type=registry,ref=${REPOSITORY}/cache:${image}-${TAG}-${arch}"]
}

function "cacheTo" {
params = [image, arch]
result = ["type=registry,oci-mediatypes=true,mode=max,compression=estargz,compression-level=5,ref=${CACHE_TO_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 = [
"leptonica"
"leptonica",
]
}

Expand All @@ -75,7 +64,7 @@ group "ci" {
}

###############################################################################
# Common target properties.
# Targets
###############################################################################
target "common" {
args = {
Expand All @@ -86,61 +75,44 @@ target "common" {
}
}

target "amd64-common" {
platforms = ["linux/amd64"]
}

target "arm64-common" {
platforms = ["linux/arm64"]
}

target "leptonica-common" {
inherits = ["common"]
context = "leptonica"
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
# Not the one displayed on DockerHub.
# N.B. This should match the value used in:
# - <https://github.com/Islandora-Devops/isle-imagemagick>
# - <https://github.com/Islandora-Devops/isle-leptonica>
# N.B. This should match the value used in <https://github.com/Islandora-Devops/isle-buildkit>
alpine = "docker-image://alpine:3.19.1@sha256:c5b1261d6d3e43071626931fc004f70149baeba2c8ec672bd4f27761f8e1ad6b"
}
}

###############################################################################
# Default Image targets for local builds.
###############################################################################
target "leptonica" {
inherits = ["leptonica-common"]
cache-from = cacheFrom("leptonica", hostArch())
tags = tags("leptonica", "")
}

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

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

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

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

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

This file was deleted.

4 changes: 2 additions & 2 deletions leptonica/build/APKBUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Contributor: Carlo Landmeter <[email protected]>
# Maintainer: Francesco Colista <[email protected]>
pkgname=leptonica
pkgver=1.83.1
pkgver=1.84.1
pkgrel=0
pkgdesc="Software that is broadly useful for image processing and image analysis applications"
url="http://www.leptonica.com/"
Expand Down Expand Up @@ -42,6 +42,6 @@ package() {
}

sha512sums="
14c76b8795e494637cd225982cd27a1cd82d22b34c0c0d6ed061530c0ed8cec87fc1c8482bbda8f56a04f240b9fb50d481b8fffe5df846958cb146f9d2d51553 leptonica-1.83.1.tar.gz
949be33a09e1dfc04527f5401d3d682999bd6904dca0b4950b457d12564e3290ec5b62ab4b14ef14d6f499a0fbfa0ebc37c2e8ab2966913883127b9489f47e97 leptonica-1.84.1.tar.gz
37afa0a0b7e0b5ef3ed0bd5106ae221bfb48d966ba02f308076eca4a469d79e69b42d86bdd95563bdc6fe976ed218848160670fa7a261ad6a393e3755962952a disable-one-failing-test.patch
"

0 comments on commit 52f717f

Please sign in to comment.