Skip to content

Commit

Permalink
build: add Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasgouveia committed Feb 15, 2023
1 parent 5340e16 commit f6f8126
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.iml
gen
.idea
*.md
.gitignore
32 changes: 32 additions & 0 deletions .github/workflows/ci.yml
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 }}
8 changes: 8 additions & 0 deletions Dockerfile
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"]
27 changes: 27 additions & 0 deletions docs/functions/node.md
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.

0 comments on commit f6f8126

Please sign in to comment.