Skip to content

Commit

Permalink
tesseract: add new image (#2469)
Browse files Browse the repository at this point in the history
Signed-off-by: Dimitri John Ledkov <[email protected]>
  • Loading branch information
xnox authored Apr 11, 2024
1 parent 3df9d3c commit 67d3768
Show file tree
Hide file tree
Showing 11 changed files with 173 additions and 0 deletions.
40 changes: 40 additions & 0 deletions images/tesseract/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!--monopod:start-->
# tesseract
| | |
| - | - |
| **OCI Reference** | `cgr.dev/chainguard/tesseract` |


* [View Image in Chainguard Academy](https://edu.chainguard.dev/chainguard/chainguard-images/reference/tesseract/overview/)
* [View Image Catalog](https://console.enforce.dev/images/catalog) for a full list of available tags.
* [Contact Chainguard](https://www.chainguard.dev/chainguard-images) for enterprise support, SLAs, and access to older tags.*

---
<!--monopod:end-->

<!--overview:start-->
Minimal image that contains tesseract
<!--overview:end-->

<!--getting:start-->
## Download this Image
The image is available on `cgr.dev`:

```
docker pull cgr.dev/chainguard/tesseract:latest
```
<!--getting:end-->

<!--body:start-->
# Usage

tessaract sample Example: OCR a eurotext.png file to .txt

```
docker run --rm \
-v "${PWD}":/work \
-w /work \
cgr.dev/chainguard/tesseract:latest
eurotext.png -
```
<!--body:end-->
20 changes: 20 additions & 0 deletions images/tesseract/config/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
terraform {
required_providers {
apko = { source = "chainguard-dev/apko" }
}
}

variable "extra_packages" {
description = "The additional packages to install"
# Install tesseract itself, orientation & size & english datasets
default = ["tesseract", "tesseract-osd", "tesseract-eng"]
}

data "apko_config" "this" {
config_contents = file("${path.module}/template.apko.yaml")
extra_packages = var.extra_packages
}

output "config" {
value = jsonencode(data.apko_config.this.config)
}
14 changes: 14 additions & 0 deletions images/tesseract/config/template.apko.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
accounts:
groups:
- groupname: nonroot
gid: 65532
users:
- username: nonroot
uid: 65532
gid: 65532
run-as: 65532

entrypoint:
command: /usr/bin/tesseract

cmd: --help
38 changes: 38 additions & 0 deletions images/tesseract/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
terraform {
required_providers {
oci = { source = "chainguard-dev/oci" }
}
}

variable "target_repository" {
description = "The docker repo into which the image and attestations should be published."
}

module "latest-config" { source = "./config" }

module "latest" {
source = "../../tflib/publisher"

name = basename(path.module)

target_repository = var.target_repository
config = module.latest-config.config
build-dev = true
}

module "test-latest" {
source = "./tests"
digest = module.latest.image_ref
}

resource "oci_tag" "latest" {
depends_on = [module.test-latest]
digest_ref = module.latest.image_ref
tag = "latest"
}

resource "oci_tag" "latest-dev" {
depends_on = [module.test-latest]
digest_ref = module.latest.dev_ref
tag = "latest-dev"
}
11 changes: 11 additions & 0 deletions images/tesseract/metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: tesseract
image: cgr.dev/chainguard/tesseract
endoflife: ""
console_summary: ""
short_description: Minimal image that contains tesseract
compatibility_notes: ""
readme_file: README.md
upstream_url: https://tesseract-ocr.github.io/
keywords:
- application
- tools
1 change: 1 addition & 0 deletions images/tesseract/tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
eurotext.txt
12 changes: 12 additions & 0 deletions images/tesseract/tests/01-eurotext-ocr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

## Using example image from
## https://tesseract-ocr.github.io/tessdoc/images/eurotext.png

set -o errexit -o nounset -o errtrace -o pipefail -x

docker run --rm \
-v "${PWD}:/work" \
-w /work \
"${IMAGE_NAME}" \
eurotext.png - | diff -u eurotext.exp -
12 changes: 12 additions & 0 deletions images/tesseract/tests/eurotext.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
The (quick) [brown] {fox} jumps!
Over the $43,456.78 <lazy> #90 dog
& duck/goose, as 12.5% of E-mail
from [email protected] is spam.
Der ,schnelle” braune Fuchs springt
iiber den faulen Hund. Le renard brun
«rapide» saute par-dessus le chien
paresseux. La volpe marrone rapida
salta sopra il cane pigro. El zorro
marrén rapido salta sobre el perro
perezoso. A raposa marrom ripida
salta sobre o cdo preguigoso.
Binary file added images/tesseract/tests/eurotext.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions images/tesseract/tests/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
terraform {
required_providers {
oci = { source = "chainguard-dev/oci" }
}
}

variable "digest" {
description = "The image digest to run tests over."
}

data "oci_exec_test" "help" {
digest = var.digest
script = "docker run --rm $IMAGE_NAME --help"
}

data "oci_exec_test" "convert" {
digest = var.digest
script = "./01-eurotext-ocr.sh"
working_dir = path.module
}
5 changes: 5 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -1441,6 +1441,11 @@ module "terraform" {
target_repository = "${var.target_repository}/terraform"
}

module "tesseract" {
source = "./images/tesseract"
target_repository = "${var.target_repository}/tesseract"
}

module "thanos" {
source = "./images/thanos"
target_repository = "${var.target_repository}/thanos"
Expand Down

0 comments on commit 67d3768

Please sign in to comment.