|
| 1 | +# Cubed Lithops Runtime Builder |
| 2 | + |
| 3 | +A GitHub template repository for building and deploying [Lithops](https://lithops-cloud.github.io/) Lambda runtimes for [Cubed](https://github.com/cubed-dev/cubed) via CI — no local Docker required. |
| 4 | + |
| 5 | +When you push changes to the `Dockerfile`, GitHub Actions builds a Docker image and deploys it as a Lambda container runtime named `cubed-runtime`. |
| 6 | + |
| 7 | +## Prerequisites |
| 8 | + |
| 9 | +- An AWS account |
| 10 | +- A GitHub account |
| 11 | +- The [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html) |
| 12 | + |
| 13 | +## Setup |
| 14 | + |
| 15 | +### 1. Create this repo from the template |
| 16 | + |
| 17 | +Click **Use this template** → **Create a new repository**. You can name it anything you like — `cubed-lithops-runtime-builder` is a good default. |
| 18 | + |
| 19 | +Then clone it to your local machine: |
| 20 | + |
| 21 | +```bash |
| 22 | +git clone https://github.com/YOUR_ORG/YOUR_REPO.git |
| 23 | +cd YOUR_REPO |
| 24 | +``` |
| 25 | + |
| 26 | +### 2. Bootstrap AWS |
| 27 | + |
| 28 | +Run this once from your local machine. Replace `YOUR_ORG` with your GitHub username or organisation (e.g. `octocat`) and `YOUR_REPO` with the name you gave this repository. |
| 29 | + |
| 30 | +```bash |
| 31 | +aws cloudformation deploy \ |
| 32 | + --template-file cloudformation/github-oidc-role.yml \ |
| 33 | + --stack-name cubed-lithops-github-actions \ |
| 34 | + --parameter-overrides GitHubOrg=YOUR_ORG GitHubRepo=YOUR_REPO \ |
| 35 | + --capabilities CAPABILITY_NAMED_IAM |
| 36 | +``` |
| 37 | + |
| 38 | +> **Already have a GitHub OIDC provider?** Use `--parameter-overrides GitHubOrg=YOUR_ORG GitHubRepo=YOUR_REPO CreateOIDCProvider=false` to skip creating one. |
| 39 | +
|
| 40 | +This creates a GitHub OIDC identity provider (if one doesn't already exist), an IAM role for GitHub Actions, and an IAM role for Lambda to assume when running functions. When it completes, retrieve both ARNs: |
| 41 | + |
| 42 | +```bash |
| 43 | +aws cloudformation describe-stacks \ |
| 44 | + --stack-name cubed-lithops-github-actions \ |
| 45 | + --query 'Stacks[0].Outputs' \ |
| 46 | + --output table \ |
| 47 | + --no-cli-pager |
| 48 | +``` |
| 49 | + |
| 50 | +### 3. Add the secret |
| 51 | + |
| 52 | +In your repo: **Settings → Secrets and variables → Actions → New repository secret** |
| 53 | + |
| 54 | +| Name | Value | |
| 55 | +|------|-------| |
| 56 | +| `AWS_ROLE_ARN` | `GitHubActionsRoleArn` from the previous step | |
| 57 | + |
| 58 | +### 4. Edit `.lithops/config` |
| 59 | + |
| 60 | +Replace the placeholder values: |
| 61 | + |
| 62 | +```yaml |
| 63 | +aws: |
| 64 | + region: us-east-1 # your AWS region |
| 65 | + |
| 66 | +aws_lambda: |
| 67 | + execution_role: arn:aws:iam::... # LambdaExecutionRoleArn from the previous step |
| 68 | + user_id: AROAXXXXXXXXXXXXXXXXX # GitHubActionsRoleId from the previous step |
| 69 | +``` |
| 70 | +
|
| 71 | +### 5. Add your dependencies |
| 72 | +
|
| 73 | +Edit the `Dockerfile` to add extra packages (there is a clearly marked section near the bottom), then commit and push with git — the CI pipeline builds and deploys the `cubed-runtime` Lambda runtime automatically. |
| 74 | + |
| 75 | +## Security note |
| 76 | + |
| 77 | +The `.lithops/config` you commit contains your AWS account ID (inside the `execution_role` ARN). This is also visible in CI build logs. AWS [does not consider the account ID a secret](https://docs.aws.amazon.com/accounts/latest/reference/manage-acct-identifiers.html), but as a precaution you may want to keep your repository private. |
| 78 | + |
| 79 | +## Manual trigger |
| 80 | + |
| 81 | +You can also trigger a build from **Actions → Build and Deploy Lithops Runtime → Run workflow**. |
| 82 | + |
| 83 | +## Customisation |
| 84 | + |
| 85 | +### Changing the runtime name |
| 86 | + |
| 87 | +The runtime is named `cubed-runtime` by default. To use a different name, edit the `RUNTIME_NAME` env var at the top of `.github/workflows/build-runtime.yml`: |
| 88 | + |
| 89 | +```yaml |
| 90 | +env: |
| 91 | + RUNTIME_NAME: 'my-runtime-name' |
| 92 | +``` |
| 93 | + |
| 94 | +Remember to also update the `runtime` key in your local Lithops config if you change this. |
| 95 | + |
| 96 | +### Using the latest Cubed from GitHub |
| 97 | + |
| 98 | +To use the latest development version of Cubed from the `main` branch instead of the PyPI release, replace the `cubed` line in the `Dockerfile`: |
| 99 | + |
| 100 | +```dockerfile |
| 101 | +RUN pip install \ |
| 102 | + 'git+https://github.com/cubed-dev/cubed.git#egg=cubed' \ |
| 103 | + obstore |
| 104 | +``` |
0 commit comments