Skip to content

Commit

Permalink
Issue [metacall#28](metacall#28): merge with master
Browse files Browse the repository at this point in the history
  • Loading branch information
HeeManSu committed Jun 3, 2024
2 parents 47542c5 + bc5f8a8 commit 70481b2
Show file tree
Hide file tree
Showing 35 changed files with 1,362 additions and 979 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
**
!src
!types
!package.json
!package-lock.json
!tsconfig.json
13 changes: 7 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,15 @@ jobs:
# TODO: Have working unit tests generated
# - name: Run Unit Tests
# run: |
# npm run unit

# TODO: Integration tests requires metacall/FaaS or dashboard.metacall.io credentials
# TODO: unComment when we are ready for integration tests
# - name: Run Tests
# run: |
# npm run test

- name: Run Integration Tests
shell: bash
run: |
docker compose build
docker compose up test
docker compose down
- name: Publish
uses: JS-DevTools/npm-publish@v1
if: startsWith(github.ref, 'refs/tags/')
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
node_modules
dist
*.env
/logs/app.log
logs
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.yml
17 changes: 17 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": ["<node_internals>/**"],
"program": "${workspaceFolder}/dist/server.js",
"preLaunchTask": "npm: buildDebug",
"outFiles": ["${workspaceFolder}/dist/**/*.js"]
}
]
}
56 changes: 56 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#
# MetaCall FaaS Script by Parra Studios
# Reimplementation of MetaCall FaaS platform written in TypeScript.
#
# Copyright (C) 2016 - 2024 Vicente Eduardo Ferrer Garcia <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

FROM node:20-bookworm-slim AS base

# Image descriptor
LABEL copyright.name="Vicente Eduardo Ferrer Garcia" \
copyright.address="[email protected]" \
maintainer.name="Vicente Eduardo Ferrer Garcia" \
maintainer.address="[email protected]" \
vendor="MetaCall Inc." \
version="0.1"

WORKDIR /metacall

FROM base AS deps

COPY . .

RUN npm install \
&& npm run build

FROM base as faas

RUN apt-get update \
&& apt-get install wget ca-certificates -y --no-install-recommends \
&& wget -O - https://raw.githubusercontent.com/metacall/install/master/install.sh | sh

COPY --from=deps /metacall/node_modules node_modules
COPY --from=deps /metacall/dist dist

EXPOSE 9000

CMD ["node", "dist/index.js"]

FROM base AS test

RUN apt-get update \
&& apt-get install curl ca-certificates jq -y --no-install-recommends \
&& npm install -g @metacall/deploy
35 changes: 23 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,56 @@

Reimplementation of MetaCall FaaS platform written in TypeScript. This project requires MetaCall installed in order to run it. For more information about installation: https://github.com/metacall/install

### Development:
### Development

```sh
npm install
npm start
```

### About Project :
### About Project

MetaCall organization has its own cloud platform known as [MetaCall Hub](https://metacall.io/), a production-ready and high-performance FaaS/Cloud platform where you can deploy services, web apps, and lambdas in seconds. However, the ```Real``` version of MetaCall FaaS is commercialized and requires a plan to deploy your polyglot applications, which can be found [Here](https://metacall.io/pricing/).
MetaCall organization has its own cloud platform known as [MetaCall Hub](https://metacall.io/), a production-ready and high-performance FaaS/Cloud platform where you can deploy services, web apps, and lambdas in seconds. However, the `Real` version of MetaCall FaaS is commercialized and requires a plan to deploy your polyglot applications, which can be found [Here](https://metacall.io/pricing/).

When referring to the ```Real``` version of MetaCall FaaS, it should be noted that this refers to the commercialized FaaS cloud service, whereas ```Local``` refers to the mimic version.
When referring to the `Real` version of MetaCall FaaS, it should be noted that this refers to the commercialized FaaS cloud service, whereas `Local` refers to the mimic version.

Soon, we realized that many contributors joining the community needed an paid account on the ```Real FaaS``` for testing their polyglot applications. To remove this barrier, we proposed a project that would mimic the ```Real FaaS```.
Soon, we realized that many contributors joining the community needed an paid account on the `Real FaaS` for testing their polyglot applications. To remove this barrier, we proposed a project that would mimic the `Real FaaS`.

With this project, developers can now use it to deploy and test their polyglot applications (built using [MetaCall Core](https://github.com/metacall/core)), web apps, and lambdas. The process is simple:

- Step 1 : Spin up the "Local FaaS" by running the following command:
- Step 1 : Spin up the "Local FaaS" by running the following command:

```sh
cd faas
npm start
```

- Step 2 : Install the [metacall-deploy](https://www.npmjs.com/package/@metacall/deploy) NPM package, and wire the ```--dev``` flag with the ```metacall-deploy``` command in your application directory using the following command:
- Step 2 : Install the [metacall-deploy](https://www.npmjs.com/package/@metacall/deploy) NPM package, and wire the `--dev` flag with the `metacall-deploy` command in your application directory using the following command:

```sh
cd move-to-application-directory
metacall-deploy --dev
```

### Things that need to be implemented:
### Things that need to be implemented

- In order to mimic the "Real FaaS", we need to create all the API endpoints that the "Real FaaS" supports, which can be found listed [Here](https://github.com/metacall/protocol/blob/master/src/protocol.ts).
- In order to mimic the "Real FaaS", we need to create all the API endpoints that the "Real FaaS" supports, which can be found listed [Here](https://github.com/metacall/protocol/blob/master/src/protocol.ts).

### Important Note

- This project is still under development and there is one extra thing you need to install before running this project and its [MetaCall Core](https://github.com/metacall/core/blob/develop/docs/README.md#41-installation).
- This project is still under development and there is one extra thing you need to install before running this project and its [MetaCall Core](https://github.com/metacall/core/blob/develop/docs/README.md#41-installation).

- This project is developed using [MetaCall Core] itself in order to provide polyglot support, we are using its [Node Port](https://github.com/metacall/core/tree/develop/source/ports/node_port) of this library to use all the functions and methods `MetaCall Core C API` provides.

- Also, [Here](https://github.com/metacall/faas/blob/master/types/metacall.d.ts) are all the functions of `MetaCall Core` we are using.

- This project is developed using [MetaCall Core] itself in order to provide polyglot support, we are using its [Node Port](https://github.com/metacall/core/tree/develop/source/ports/node_port) of this library to use all the functions and methods ```MetaCall Core C API``` provides.
### Testing

- Also, [Here](https://github.com/metacall/faas/blob/master/types/metacall.d.ts) are all the functions of ```MetaCall Core``` we are using.
This will run a test, and if the `docker compose up test` command exits with exit code 0, it will mean that the test has passed.
If you want to see the output of the FaaS, run `docker compose up` instead. But when running this, the command won't terminate once the test finishes and the FaaS will keep running. You will need to press `Ctrl+C` in order to close it.

```sh
docker compose build
docker compose up test
docker compose down
```
1 change: 0 additions & 1 deletion TODO.md

This file was deleted.

45 changes: 45 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#
# MetaCall FaaS Script by Parra Studios
# Reimplementation of MetaCall FaaS platform written in TypeScript.
#
# Copyright (C) 2016 - 2024 Vicente Eduardo Ferrer Garcia <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

version: '3.7'

services:
faas:
image: metacall/faas
container_name: metacall_faas
build:
context: .
dockerfile: Dockerfile
target: faas
ports:
- "9000:9000"

test:
image: metacall/faas:test
container_name: metacall_faas_test
build:
context: .
dockerfile: Dockerfile
target: test
network_mode: host
depends_on:
- faas
volumes:
- ./test/:/metacall/
command: /metacall/test.sh
Loading

0 comments on commit 70481b2

Please sign in to comment.