Skip to content

Commit 89034cd

Browse files
authored
feat: build and publish mupdf layer (#1)
* feat: publish layer using github actions * fix: fix build mupdf * fix: install mesa-libGL-devel * feat: build only command line tool * fix: fix mupdf link * fix: install lzip * fix: tar -xv --lzip -f * fix: download mupdf-1.24.10-source.tar.gz * feat: pack /usr/local/bin * fix: add Workaround for the nodejs20.x runtime * fix: copy shared lib as well * fix: remove sudo for dnf * fix: use amazonlinux:2023 * fix: remove lzip yum install * fix: remove upload artifact for now * fix: install awscli * fix: uploadd to s3 * fix: remove useless command * docs: add description * refactor: use secret S3_BUCKET * refactor: use env.MUPDF_VERSION in workflow * ci: only publish when release * ci: change layer name to mupdf * docs: add README
1 parent 4a3a64a commit 89034cd

File tree

2 files changed

+123
-0
lines changed

2 files changed

+123
-0
lines changed

.github/workflows/build.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
release:
9+
types: [published]
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
13+
cancel-in-progress: true
14+
15+
env:
16+
MUPDF_VERSION: 1.24.10
17+
18+
jobs:
19+
test:
20+
runs-on: ubuntu-latest
21+
container: amazonlinux:2023
22+
steps:
23+
- name: Install the necessary tools
24+
run: |
25+
yum update -y
26+
yum groupinstall "Development Tools" -y
27+
yum install -y tar wget dnf awscli
28+
29+
- name: Build MuPDF
30+
# https://mupdf.readthedocs.io/en/latest/quick-start-guide.html
31+
run: |
32+
wget https://mupdf.com/downloads/archive/mupdf-${{ env.MUPDF_VERSION }}-source.tar.gz
33+
tar -xzf mupdf-${{ env.MUPDF_VERSION }}-source.tar.gz
34+
cd mupdf-${{ env.MUPDF_VERSION }}-source
35+
make HAVE_X11=no HAVE_GLUT=no prefix=/usr/local install
36+
37+
- name: Create the layer
38+
run: |
39+
mkdir -p layer/bin
40+
cp /usr/local/bin/mutool layer/bin/
41+
cp /usr/local/bin/muraster layer/bin/
42+
mkdir -p layer/lib
43+
ldd /usr/local/bin/mutool | grep '=>' | awk '{print $3}' | xargs -I '{}' cp -v '{}' layer/lib
44+
ldd /usr/local/bin/muraster | grep '=>' | awk '{print $3}' | xargs -I '{}' cp -v '{}' layer/lib
45+
cd layer
46+
zip -r9 ../mupdf-layer.zip .
47+
cd ..
48+
49+
- name: Login to AWS
50+
if: github.event_name == 'release'
51+
run: |
52+
aws configure set aws_access_key_id ${{ secrets.AWS_ACCESS_KEY_ID }}
53+
aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY }}
54+
aws configure set region ${{ secrets.AWS_REGION }}
55+
56+
- name: Upload to S3
57+
if: github.event_name == 'release'
58+
run: |
59+
aws s3 cp mupdf-layer.zip s3://${{ secrets.S3_BUCKET }}/mupdf-layer.zip
60+
61+
- name: Deploy the layer to the artifact registry
62+
if: github.event_name == 'release'
63+
run: |
64+
aws lambda publish-layer-version \
65+
--layer-name mupdf \
66+
--content S3Bucket=${{ secrets.S3_BUCKET }},S3Key=mupdf-layer.zip \
67+
--description "MuPDF CLI tools v${{ env.MUPDF_VERSION }}"

README.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,57 @@
11
# mupdf-aws-lambda-layer
2+
3+
[![Build](https://github.com/rwv/mupdf-aws-lambda-layer/actions/workflows/build.yml/badge.svg)](https://github.com/rwv/mupdf-aws-lambda-layer/actions/workflows/build.yml)
4+
5+
An AWS Lambda Layer containing MuPDF CLI tools (mutool and muraster) built for Amazon Linux 2023.
6+
7+
## Overview
8+
9+
This project provides a Lambda Layer that packages MuPDF command-line tools, making them available for use in AWS Lambda functions. The layer is built using Amazon Linux 2023 to ensure compatibility with Lambda's runtime environment.
10+
11+
## Version
12+
13+
Current MuPDF version: [1.24.10](https://mupdf.com/releases/history)
14+
15+
## Contents
16+
17+
The layer includes:
18+
- `bin/mutool` - An all purpose tool for dealing with PDF files
19+
- `bin/muraster` - Can be used to convert PDF pages to raster images
20+
- `lib/*` - All required shared libraries
21+
22+
## Usage
23+
24+
### Manual Layer Usage
25+
26+
1. Download the layer ZIP from the [latest release](https://github.com/rwv/mupdf-aws-lambda-layer/releases/latest)
27+
2. Create a new Lambda Layer in your AWS account
28+
3. Upload the ZIP file
29+
4. Attach the layer to your Lambda function
30+
31+
### Automated Layer Deployment
32+
33+
The layer is automatically published to AWS Lambda's layer registry on each release. You can fork this repository and add the following repository secrets to enable automated deployments:
34+
35+
- `AWS_ACCESS_KEY_ID`: Your AWS access key ID
36+
- `AWS_SECRET_ACCESS_KEY`: Your AWS secret access key
37+
- `AWS_REGION`: The AWS region to deploy to
38+
- `S3_BUCKET`: The S3 bucket name for storing the layer ZIP file
39+
40+
## Building
41+
42+
The layer is automatically built using GitHub Actions. The workflow:
43+
1. Sets up an Amazon Linux 2023 container
44+
2. Builds MuPDF from source
45+
3. Packages the binaries and dependencies
46+
4. Creates a ZIP file
47+
5. Publishes to S3 and Lambda Layer registry (on release only)
48+
49+
To build locally, you can follow the steps in the GitHub Actions workflow file.
50+
51+
## License
52+
53+
This project is provided under the same license as MuPDF. See [MuPDF's license](https://mupdf.com/#licensing) for details.
54+
55+
## Contributing
56+
57+
Contributions are welcome! Please feel free to submit a Pull Request.

0 commit comments

Comments
 (0)