https://github.com/shelfio/libreoffice-lambda-base-image
https://github.com/shelfio/libreoffice-lambda-base-image
Last synced: 7 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/shelfio/libreoffice-lambda-base-image
- Owner: shelfio
- License: mit
- Created: 2022-06-20T16:44:39.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2025-06-03T22:53:33.000Z (7 months ago)
- Last Synced: 2025-06-04T06:50:03.373Z (7 months ago)
- Size: 33.2 KB
- Stars: 38
- Watchers: 19
- Forks: 20
- Open Issues: 19
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# LibreOffice Lambda Base Image
> LibreOffice 7.6 base image for Lambda Node.js 20 x86_64 and Python 3.12 x86_64 to be used as a base for your own images.
## Usage
Includes CJK fonts support! 877 MB in size.
[Blog post announcement](https://vladholubiev.medium.com/running-libreoffice-in-aws-lambda-2022-edition-open-sourced-9bb0028911d8)
> Set environment variable `HOME=/tmp` in your Lambda function.
### Node.js 20 x86_64
```Dockerfile
FROM public.ecr.aws/shelf/lambda-libreoffice-base:7.6-node20-x86_64
COPY handler.js ${LAMBDA_TASK_ROOT}/
CMD [ "handler.handler" ]
```
And your `handler.js`:
```javascript
const {execSync} = require('child_process');
const {writeFileSync} = require('fs');
module.exports.handler = () => {
writeFileSync('/tmp/hello.txt', Buffer.from('Hello World!'));
execSync(`
cd /tmp
libreoffice7.6 --headless --invisible --nodefault --view --nolockcheck --nologo --norestore --convert-to pdf --outdir /tmp ./hello.txt
`);
};
```
### Python 3.12 x86_64
```Dockerfile
FROM public.ecr.aws/shelf/lambda-libreoffice-base:7.6-python3.12-x86_64
COPY handler.py ${LAMBDA_TASK_ROOT}/
CMD [ "handler.handler" ]
```
And your `handler.py`:
```python
import subprocess
def handler(event, context):
with open('/tmp/hello.txt', 'w') as f:
f.write('Hello World!')
subprocess.run([
'libreoffice7.6',
'--headless',
'--invisible',
'--nodefault',
'--view',
'--nolockcheck',
'--nologo',
'--norestore',
'--convert-to',
'pdf',
'--outdir',
'/tmp',
'/tmp/hello.txt'
], check=True)
```
## Troubleshooting
Command failed: Fatal Error: The application cannot be started. User installation could not be completed.
Set environment variable `HOME=/tmp` in your Lambda function.
## Available Tags & Versions
* `7.6-node20-x86_64`
* `7.6-python3.12-x86_64`
* `7.6-node18-x86_64`
* `7.4-node16-x86_64`
* `7.3-node16-x86_64`
## See Also
* [aws-lambda-libreoffice](https://github.com/shelfio/aws-lambda-libreoffice) - utility to work with Docker version of LibreOffice in Lambda
* [libreoffica-lambda-layer](https://github.com/shelfio/libreoffice-lambda-layer) - deprecated; this is the predecessor of this image