-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
2 changed files
with
123 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
name: Build | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
release: | ||
types: [published] | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | ||
cancel-in-progress: true | ||
|
||
env: | ||
MUPDF_VERSION: 1.24.10 | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
container: amazonlinux:2023 | ||
steps: | ||
- name: Install the necessary tools | ||
run: | | ||
yum update -y | ||
yum groupinstall "Development Tools" -y | ||
yum install -y tar wget dnf awscli | ||
- name: Build MuPDF | ||
# https://mupdf.readthedocs.io/en/latest/quick-start-guide.html | ||
run: | | ||
wget https://mupdf.com/downloads/archive/mupdf-${{ env.MUPDF_VERSION }}-source.tar.gz | ||
tar -xzf mupdf-${{ env.MUPDF_VERSION }}-source.tar.gz | ||
cd mupdf-${{ env.MUPDF_VERSION }}-source | ||
make HAVE_X11=no HAVE_GLUT=no prefix=/usr/local install | ||
- name: Create the layer | ||
run: | | ||
mkdir -p layer/bin | ||
cp /usr/local/bin/mutool layer/bin/ | ||
cp /usr/local/bin/muraster layer/bin/ | ||
mkdir -p layer/lib | ||
ldd /usr/local/bin/mutool | grep '=>' | awk '{print $3}' | xargs -I '{}' cp -v '{}' layer/lib | ||
ldd /usr/local/bin/muraster | grep '=>' | awk '{print $3}' | xargs -I '{}' cp -v '{}' layer/lib | ||
cd layer | ||
zip -r9 ../mupdf-layer.zip . | ||
cd .. | ||
- name: Login to AWS | ||
if: github.event_name == 'release' | ||
run: | | ||
aws configure set aws_access_key_id ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws configure set region ${{ secrets.AWS_REGION }} | ||
- name: Upload to S3 | ||
if: github.event_name == 'release' | ||
run: | | ||
aws s3 cp mupdf-layer.zip s3://${{ secrets.S3_BUCKET }}/mupdf-layer.zip | ||
- name: Deploy the layer to the artifact registry | ||
if: github.event_name == 'release' | ||
run: | | ||
aws lambda publish-layer-version \ | ||
--layer-name mupdf \ | ||
--content S3Bucket=${{ secrets.S3_BUCKET }},S3Key=mupdf-layer.zip \ | ||
--description "MuPDF CLI tools v${{ env.MUPDF_VERSION }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,57 @@ | ||
# mupdf-aws-lambda-layer | ||
|
||
[![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) | ||
|
||
An AWS Lambda Layer containing MuPDF CLI tools (mutool and muraster) built for Amazon Linux 2023. | ||
|
||
## Overview | ||
|
||
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. | ||
|
||
## Version | ||
|
||
Current MuPDF version: [1.24.10](https://mupdf.com/releases/history) | ||
|
||
## Contents | ||
|
||
The layer includes: | ||
- `bin/mutool` - An all purpose tool for dealing with PDF files | ||
- `bin/muraster` - Can be used to convert PDF pages to raster images | ||
- `lib/*` - All required shared libraries | ||
|
||
## Usage | ||
|
||
### Manual Layer Usage | ||
|
||
1. Download the layer ZIP from the [latest release](https://github.com/rwv/mupdf-aws-lambda-layer/releases/latest) | ||
2. Create a new Lambda Layer in your AWS account | ||
3. Upload the ZIP file | ||
4. Attach the layer to your Lambda function | ||
|
||
### Automated Layer Deployment | ||
|
||
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: | ||
|
||
- `AWS_ACCESS_KEY_ID`: Your AWS access key ID | ||
- `AWS_SECRET_ACCESS_KEY`: Your AWS secret access key | ||
- `AWS_REGION`: The AWS region to deploy to | ||
- `S3_BUCKET`: The S3 bucket name for storing the layer ZIP file | ||
|
||
## Building | ||
|
||
The layer is automatically built using GitHub Actions. The workflow: | ||
1. Sets up an Amazon Linux 2023 container | ||
2. Builds MuPDF from source | ||
3. Packages the binaries and dependencies | ||
4. Creates a ZIP file | ||
5. Publishes to S3 and Lambda Layer registry (on release only) | ||
|
||
To build locally, you can follow the steps in the GitHub Actions workflow file. | ||
|
||
## License | ||
|
||
This project is provided under the same license as MuPDF. See [MuPDF's license](https://mupdf.com/#licensing) for details. | ||
|
||
## Contributing | ||
|
||
Contributions are welcome! Please feel free to submit a Pull Request. |