Skip to content

Commit 9878e77

Browse files
committed
Cubed Lithops Runtime Builder Template
0 parents  commit 9878e77

4 files changed

Lines changed: 139 additions & 0 deletions

File tree

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Build and Deploy Lithops Runtime
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- 'requirements.txt'
8+
- '.lithops/config'
9+
workflow_dispatch:
10+
11+
permissions:
12+
id-token: write
13+
contents: read
14+
15+
env:
16+
PYTHON_VERSION: '3.12'
17+
18+
jobs:
19+
build:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- name: Read AWS region from config
25+
id: config
26+
run: |
27+
region=$(python3 -c "
28+
import configparser
29+
c = configparser.ConfigParser()
30+
c.read('.lithops/config')
31+
print(c['aws']['region'].strip())
32+
")
33+
echo "region=$region" >> $GITHUB_OUTPUT
34+
35+
- name: Configure AWS credentials
36+
uses: aws-actions/configure-aws-credentials@v4
37+
with:
38+
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
39+
aws-region: ${{ steps.config.outputs.region }}
40+
41+
- name: Set up Python
42+
uses: actions/setup-python@v5
43+
with:
44+
python-version: ${{ env.PYTHON_VERSION }}
45+
46+
- name: Install Lithops
47+
run: pip install 'lithops[aws]'
48+
49+
- name: Set runtime name
50+
id: runtime
51+
run: |
52+
name=$(echo '${{ github.event.repository.name }}' | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9-]/-/g')
53+
echo "name=$name" >> $GITHUB_OUTPUT
54+
55+
- name: Copy Lithops config
56+
run: |
57+
mkdir -p ~/.lithops
58+
cp .lithops/config ~/.lithops/config
59+
60+
- name: Build runtime
61+
run: lithops runtime build ${{ steps.runtime.outputs.name }} -b aws_lambda
62+
63+
- name: Deploy runtime
64+
run: lithops runtime deploy ${{ steps.runtime.outputs.name }} -b aws_lambda

.lithops/config

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[lithops]
2+
backend = aws_lambda
3+
storage = aws_s3
4+
5+
[aws]
6+
region = us-east-1
7+
8+
[aws_lambda]
9+
execution_role = arn:aws:iam::ACCOUNT_ID:role/ROLE_NAME
10+
runtime_memory = 512
11+
runtime_timeout = 300

README.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Lithops Runtime Builder
2+
3+
A GitHub template repository for building and deploying custom [Lithops](https://lithops-cloud.github.io/) Lambda runtimes via CI — no local Docker required.
4+
5+
When you push changes to `requirements.txt`, GitHub Actions builds a Docker image with your dependencies and deploys it as a Lambda container runtime.
6+
7+
## Prerequisites
8+
9+
- An AWS account
10+
- A GitHub account
11+
12+
## Setup
13+
14+
### 1. Create this repo from the template
15+
16+
Click **Use this template****Create a new repository**.
17+
18+
### 2. Bootstrap AWS
19+
20+
You need an IAM role that GitHub Actions can assume via OIDC. Create the GitHub OIDC identity provider in your AWS account (if not already present), then create a role with a trust policy scoped to your repo:
21+
22+
```json
23+
{
24+
"Effect": "Allow",
25+
"Principal": { "Federated": "arn:aws:iam::ACCOUNT_ID:oidc-provider/token.actions.githubusercontent.com" },
26+
"Action": "sts:AssumeRoleWithWebIdentity",
27+
"Condition": {
28+
"StringLike": { "token.actions.githubusercontent.com:sub": "repo:YOUR_ORG/YOUR_REPO:*" }
29+
}
30+
}
31+
```
32+
33+
The role needs permissions for ECR, Lambda, S3, and (optionally) CodeBuild.
34+
35+
### 3. Add the secret
36+
37+
In your repo: **Settings → Secrets and variables → Actions → New repository secret**
38+
39+
| Name | Value |
40+
|------|-------|
41+
| `AWS_ROLE_ARN` | `arn:aws:iam::ACCOUNT_ID:role/ROLE_NAME` |
42+
43+
### 4. Edit `.lithops/config`
44+
45+
Replace the placeholder values:
46+
47+
```ini
48+
[aws]
49+
region = us-east-1 # your AWS region
50+
51+
[aws_lambda]
52+
execution_role = arn:aws:iam::ACCOUNT_ID:role/ROLE_NAME # Lambda execution role
53+
```
54+
55+
### 5. Add your dependencies
56+
57+
Edit `requirements.txt` and push — the CI pipeline builds and deploys your runtime automatically.
58+
59+
The runtime is named after your repository (lowercased).
60+
61+
## Manual trigger
62+
63+
You can also trigger a build manually from **Actions → Build and Deploy Lithops Runtime → Run workflow**.

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
numpy

0 commit comments

Comments
 (0)