Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,4 @@ scratch

# pycharm
.idea/

56 changes: 28 additions & 28 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
FROM python:3.10-slim-bullseye
FROM python:3.13-slim-trixie
COPY --from=ghcr.io/astral-sh/uv:0.8.13 /uv /uvx /bin/

ENV KAKADU_APPS_LOCATION s3://dlcs-dlcservices-bootstrap-objects/kdu77-apps.tar.gz
ENV APPETISER_DIR /opt/appetiser
ENV TMPDIR $APPETISER_DIR/tmp
ENV OUTPUT_DIR $APPETISER_DIR/out/
ENV HTTP_TIMEOUT 60
ENV APPETISER_DIR=/opt/appetiser
ENV TMPDIR=$APPETISER_DIR/tmp
ENV OUTPUT_DIR=$APPETISER_DIR/out/

RUN apt-get update -y && apt-get install -y cmake \
netpbm \
ghostscript \
libffi-dev \
libjpeg-turbo-progs \
libtiff5-dev \
libjpeg62-turbo-dev \
zlib1g-dev \
libfreetype6-dev \
liblcms2-dev \
libwebp-dev \
tcl8.6-dev \
tk8.6-dev \
python3-tk \
libharfbuzz-dev \
libfribidi-dev
RUN apt-get update -y && apt-get install -y \
cmake=3.31.6-2 \
netpbm=2:11.10.02-1 \
ghostscript=10.05.1~dfsg-1 \
libffi-dev=3.4.8-2 \
libjpeg-turbo-progs=1:2.1.5-4 \
libtiff5-dev=4.7.0-3 \
libjpeg62-turbo-dev=1:2.1.5-4 \
zlib1g-dev=1:1.3.dfsg+really1.3.1-1+b1 \
#libfreetype6-dev \
liblcms2-dev=2.16-2 \
libwebp-dev=1.5.0-0.1 \
tcl8.6-dev=8.6.16+dfsg-1 \
tk8.6-dev=8.6.16-1 \
python3-tk=3.13.5-1\
libharfbuzz-dev=10.2.0-1+b1 \
libfribidi-dev=1.0.16-1

COPY requirements.txt $APPETISER_DIR/requirements.txt
RUN pip3 install --no-cache-dir -r $APPETISER_DIR/requirements.txt
COPY ./appetiser/ $APPETISER_DIR/appetiser/
COPY ./pyproject.toml $APPETISER_DIR
COPY ./uv.lock $APPETISER_DIR
COPY ./run_appetiser.sh $APPETISER_DIR

COPY . $APPETISER_DIR
RUN chmod +x $APPETISER_DIR/run_tests.sh
RUN chmod +x $APPETISER_DIR/run_appetiser.sh

LABEL org.opencontainers.image.source=https://github.com/dlcs/appetiser

RUN mkdir $TMPDIR $OUTPUT_DIR
WORKDIR $APPETISER_DIR
RUN uv sync --locked --no-dev

EXPOSE 80
CMD $APPETISER_DIR/run_appetiser.sh
CMD ["./run_appetiser.sh"]
36 changes: 0 additions & 36 deletions Jenkinsfile

This file was deleted.

75 changes: 37 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,58 +2,57 @@

Replacement for jp2iser/tizer. Converts various image resources into JPEG2000 and a collection of thumbnails.

## Getting Started

The easiest way to get this running is using Docker.
## Dependencies

```bash
# build
docker build -t appetiser:latest .
### Kakadu

# run
docker run -it --rm -p 5080:80 appetiser:latest
Appetiser is dependent on being able to access the compiled binaries for Kakadu as a tarball. In production it is expected that this will be an S3 file location that appetiser has access to at run-time, set with the environment variable:

```sh
KDU_BINARIES=s3://bucket/path-/to/kdu/binaries.tar
```

Appetiser needs access to Kakadu binaries. The default location of these binaries is specified by the `KAKADU_APPS_LOCATION` environment variable. Relevant AWS credentials will need to be passed to the docker container.
This is downloaded to the location `/kdu_src/kdu.tar` within the running container. convert

You will also need a volume mount for reading/writing images. Files are not passed as part of the request, instead a `source` parameter points to the file on disk.
For local development using docker compose, the `./local_data/kdu_src` directory is mapped to `/kdu_src` within the appetiser container. A copy of the Kakadu binaries should be placed in the `./local_data/kdu_src/` directory, and symlinked to `./local_data/kdu_src/kdu.tar`

e.g.
```bash
docker run -it --rm -p 5080:80 \
-e KAKADU_APPS_LOCATION=s3://my-s3-bucket/kdu77-apps.tar.gz \
-e AWS_ACCESS_KEY_ID=mykey \
-e AWS_SECRET_ACCESS_KEY=mysecretkey \
-v /path/to/scratch:/scratch \
appetiser:latest
```
### Python
Python dependencies for appetiser are managed using [uv](https://docs.astral.sh/uv/). This is the case both for app dependencies, that are installed by uv in the docker image, and development dependencies, that are used for testing and tooling.

### Docker Compose
Development and testing dependencies should be added using the `--dev` flag, e.g.

There is a docker-compose file to ease running above, see .env.dist for example .env file.
```sh
uv add --dev httpx
```

```bash
docker-compose up
Although the app is containerised, it will be necessary to install the project dependencies for local development via:
```sh
uv sync
```

## Converting an Image
### OS

Pillow has a number of OS level dependencies for dealing with various image formats that are installed in the Docker image. As we're installing Pillow through `uv` (previously `pip`) rather than `apt` this is required to ensure support for the required image formats. These seem to correspond with the [External libraries](https://pillow.readthedocs.io/en/stable/installation/building-from-source.html) in the Pillow docs.

## Running locally

Make a POST to `/convert` to start conversion process. The source image must be in a folder location that is accessible to the appetiser application.
A [docker-compose.yml](./docker-compose.yml) file is provided for local development. This contains a number of volume mappings for local files, so the following must exist in the local directory:

Sample payload (all folder locations are relative to `/opt/appetiser/`):
- `./local_data/kdu_src`: Directory containing the Kakadu binaries as described [above](#kakadu). gitingored.
- `./local_data/output`: Output directory mapped to `/test_output` and used in API examples and tests. gitignored.

```json
{
"imageId": "test-appetiser",
"jobId": "test-appetiser_job",
"source": "/scratch/test-image.jpg",
"thumbSizes": [ 30, 100, 400 ],
"operation": "ingest",
"optimisation": "kdu_med",
"origin": "my_origin",
"destination": "/scratch/out/the_converted.jp2",
"thumbDir": "/scratch/out/thumbnails/"
}
## Running tests

Integration tests can be found in [./tests](./tests) and should be run with:
```sh
uv run pytest
```

> Note that the destination _must_ end in "jp2" or kdu_compress call will fail.
These tests are dependent on `pytest-docker`, and use the [./tests/docker-compose.test.yml](./tests/docker-compose.test.yml) file.


## API Documentation

OpenAPI docs for the appetiser API can be found at [http://localhost:8000/docs](http://localhost:8000/docs) on a locally running instance of appetiser. These provide documentation and examples for the `convert/` endpoint, along with expected types.

Empty file removed app/jp2/__init__.py
Empty file.
154 changes: 0 additions & 154 deletions app/jp2/convert.py

This file was deleted.

Loading
Loading