Skip to content

Commit 8a6ce12

Browse files
committed
feat: publish python version as well
1 parent c847b9b commit 8a6ce12

File tree

4 files changed

+97
-12
lines changed

4 files changed

+97
-12
lines changed

.circleci/config.yml

+54-7
Original file line numberDiff line numberDiff line change
@@ -6,47 +6,71 @@ orbs:
66
docker: circleci/[email protected]
77

88
parameters:
9-
docker_image_tag:
9+
node_image_tag:
1010
type: string
1111
default: '7.6-node20-x86_64'
12+
python_image_tag:
13+
type: string
14+
default: '7.6-python3.12-x86_64'
1215

1316
jobs:
14-
build:
17+
build_node:
1518
executor: 'aws-ecr/default'
1619
steps:
1720
- checkout
1821
- aws-ecr/build_image:
1922
dockerfile: Dockerfile.node20-x86_64
2023
no_output_timeout: 10m
21-
tag: << pipeline.parameters.docker_image_tag >>
24+
tag: << pipeline.parameters.node_image_tag >>
25+
region: ${AWS_DEFAULT_REGION}
26+
skip_when_tags_exist: false
27+
push_image: false
28+
repo: lambda-libreoffice-base
29+
30+
build_python:
31+
executor: 'aws-ecr/default'
32+
steps:
33+
- checkout
34+
- aws-ecr/build_image:
35+
dockerfile: Dockerfile.python3_12-x86_64
36+
no_output_timeout: 10m
37+
tag: << pipeline.parameters.python_image_tag >>
2238
region: ${AWS_DEFAULT_REGION}
2339
skip_when_tags_exist: false
2440
push_image: false
2541
repo: lambda-libreoffice-base
2642

2743
workflows:
28-
build_and_push_image:
44+
build_and_push_images:
2945
jobs:
3046
- docker/hadolint:
31-
dockerfiles: Dockerfile.node20-x86_64
47+
dockerfiles: Dockerfile.node20-x86_64,Dockerfile.python3_12-x86_64
3248
executor-class: medium
3349
ignore-rules: 'DL3033,SC3040,DL4006,DL3003,DL3032,SC2015,DL3041,SC2035'
3450

35-
- build:
51+
- build_node:
52+
context: prod-us
53+
filters:
54+
branches:
55+
only:
56+
- /feature\/.*/
57+
58+
- build_python:
3659
context: prod-us
3760
filters:
3861
branches:
3962
only:
4063
- /feature\/.*/
4164

4265
- aws-ecr/build_and_push_image:
66+
name: push_node_image
4367
auth:
4468
- aws-cli/setup
4569
context: prod-us
4670
executor: aws-ecr/default
4771
create_repo: false
4872
repo: lambda-libreoffice-base
49-
tag: << pipeline.parameters.docker_image_tag >>
73+
tag: << pipeline.parameters.node_image_tag >>
5074
dockerfile: Dockerfile.node20-x86_64
5175
no_output_timeout: 20m
5276
public_registry: true
@@ -60,3 +84,26 @@ workflows:
6084
branches:
6185
only:
6286
- master
87+
88+
- aws-ecr/build_and_push_image:
89+
name: push_python_image
90+
auth:
91+
- aws-cli/setup
92+
context: prod-us
93+
executor: aws-ecr/default
94+
create_repo: false
95+
repo: lambda-libreoffice-base
96+
tag: << pipeline.parameters.python_image_tag >>
97+
dockerfile: Dockerfile.python3_12-x86_64
98+
no_output_timeout: 20m
99+
public_registry: true
100+
push_image: true
101+
region: ${AWS_DEFAULT_REGION}
102+
repo_scan_on_push: true
103+
skip_when_tags_exist: false
104+
account_id: AWS_ACCOUNT_ID
105+
public_registry_alias: shelf
106+
filters:
107+
branches:
108+
only:
109+
- master

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.aider*
2+
.DS_Store

Dockerfile.python3_12-x86_64

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM public.ecr.aws/lambda/python:3.12
1+
FROM public.ecr.aws/lambda/python:3.12-x86_64
22

33
ENV PATH=/var/lang/bin:/usr/local/bin:/usr/bin/:/bin:/opt/bin
44

README.md

+40-4
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
# LibreOffice Lambda Base Image
22

3-
> LibreOffice 7.6 base image for Lambda Node.js 20 x86_64 to be used as a base for your own images.
3+
> 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.
44
55
## Usage
66

77
Includes CJK fonts support! 877 MB in size.
88

99
[Blog post announcement](https://vladholubiev.medium.com/running-libreoffice-in-aws-lambda-2022-edition-open-sourced-9bb0028911d8)
1010

11-
### Node.js 20 x86_64
12-
1311
> Set environment variable `HOME=/tmp` in your Lambda function.
1412
13+
### Node.js 20 x86_64
14+
1515
```Dockerfile
1616
FROM public.ecr.aws/shelf/lambda-libreoffice-base:7.6-node20-x86_64
1717

@@ -36,7 +36,42 @@ module.exports.handler = () => {
3636
};
3737
```
3838

39-
Other platforms are not supported yet. PRs are welcome!
39+
### Python 3.12 x86_64
40+
41+
```Dockerfile
42+
FROM public.ecr.aws/shelf/lambda-libreoffice-base:7.6-python3.12-x86_64
43+
44+
COPY handler.py ${LAMBDA_TASK_ROOT}/
45+
46+
CMD [ "handler.handler" ]
47+
```
48+
49+
And your `handler.py`:
50+
51+
```python
52+
import subprocess
53+
54+
def handler(event, context):
55+
with open('/tmp/hello.txt', 'w') as f:
56+
f.write('Hello World!')
57+
58+
subprocess.run([
59+
'libreoffice7.6',
60+
'--headless',
61+
'--invisible',
62+
'--nodefault',
63+
'--view',
64+
'--nolockcheck',
65+
'--nologo',
66+
'--norestore',
67+
'--convert-to',
68+
'pdf',
69+
'--outdir',
70+
'/tmp',
71+
'/tmp/hello.txt'
72+
], check=True)
73+
74+
```
4075

4176
## Troubleshooting
4277

@@ -49,6 +84,7 @@ Set environment variable `HOME=/tmp` in your Lambda function.
4984
## Available Tags & Versions
5085

5186
* `7.6-node20-x86_64`
87+
* `7.6-python3.12-x86_64`
5288
* `7.6-node18-x86_64`
5389
* `7.4-node16-x86_64`
5490
* `7.3-node16-x86_64`

0 commit comments

Comments
 (0)