Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an example for Node.js #252

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions examples/example_http_expressjs/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.zip
*.squashfs
*.key
15 changes: 15 additions & 0 deletions examples/example_http_expressjs/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node:16-bullseye

RUN apt-get update && apt-get -y upgrade && apt-get install -y \
libsecp256k1-dev \
squashfs-tools \
python3-pip \
git \
&& rm -rf /var/lib/apt/lists/*

RUN pip install aleph-client

WORKDIR /usr/src/example_http_js
COPY . .

RUN npm i
19 changes: 19 additions & 0 deletions examples/example_http_expressjs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

podman-prepare:
podman build -t aleph-example-js .

podman-publish:
podman run --rm -ti aleph-example-js make publish

podman-client:
podman rmi aleph-example-js

docker-prepare:
docker build -t aleph-example-js .

docker-publish:
docker run --rm -ti aleph-example-js make publish

publish:
chmod +x ./src/run.sh
aleph program ./src "run.sh"
32 changes: 32 additions & 0 deletions examples/example_http_expressjs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Aleph VM JS Example

A simple example program written in JS that can run in an Aleph VM.

## About

This example is a simple HTTP server listening on port 8080.
It does not depend on third-party libraries.

Test it on http://localhost:8080.

## Publish the program

### Locally

```shell
make publish
```

### Using Podman

```shell
make podman-prepare
make podman-publish
```

### Using Docker

```shell
make docker-prepare
make docker-publish
```
Loading