-
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.
- Loading branch information
1 parent
5340e16
commit f6f8126
Showing
4 changed files
with
72 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,5 @@ | ||
*.iml | ||
gen | ||
.idea | ||
*.md | ||
.gitignore |
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,32 @@ | ||
on: | ||
push: | ||
branches: [ main ] | ||
|
||
jobs: | ||
package: | ||
name: Build container images | ||
runs-on: ubuntu-22.04 | ||
permissions: | ||
contents: read | ||
packages: write | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: docker/setup-qemu-action@v2 | ||
- uses: docker/setup-buildx-action@v2 | ||
- uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- uses: docker/metadata-action@v4 | ||
id: meta | ||
with: | ||
images: ghcr.io/${{ github.repository }} | ||
- uses: docker/build-push-action@v3 | ||
with: | ||
context: . | ||
push: true | ||
file: Dockerfile | ||
platforms: linux/amd64, linux/arm64 | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |
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,8 @@ | ||
FROM golang:1.19 as build | ||
WORKDIR /build | ||
COPY . . | ||
RUN go build -o alpha main.go | ||
|
||
FROM scratch | ||
COPY --from=build /build/alpha ./alpha | ||
ENTRYPOINT ["alpha"] |
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,27 @@ | ||
# Create an Alpha-compliant Node.js function | ||
|
||
This guide will help you to set up your first Node.js function and execute it through Alpha. | ||
|
||
## Requirements | ||
|
||
- **Git repository** to host your function code (or similar, you will simply need something where you can store files and download them) | ||
|
||
## Create the function | ||
|
||
Once you've cloned / created your git repository, open it locally into your favourite code editor, and create an **index.js** file inside with the following placeholder content : | ||
|
||
> **The name of the file must be exactly `index.js`**. | ||
```javascript | ||
exports.handler = function (ctx, params) { | ||
ctx.logger.log("Hello from my first JS function !") | ||
|
||
let name = params["name"] || "world"; | ||
return { message: `Hello ${name} !`}; | ||
}; | ||
``` | ||
|
||
- First, we export a function called **handler**. The name, like the file name, is important and can't be changed for now. | ||
- Your function takes 2 parameters : `ctx` and `params`. `ctx` is an object provided by the runtime that contains helpers like logger. `params` is simply a Javascript object that contains the variables given to the function. | ||
- The `return` statement at the end MUST return a valid JSON object representation. | ||
|