Skip to content

Commit 8f2cbf3

Browse files
committed
Add base for test with docker compose.
1 parent ab1755b commit 8f2cbf3

12 files changed

+97
-17
lines changed

.dockerignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
**
22
!src
3+
!types
34
!package.json
45
!package-lock.json
56
!tsconfig.json

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
node_modules
22
dist
33
*.env
4-
/logs/app.log
4+
logs

.prettierignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.yml

Dockerfile

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#
2+
# MetaCall FaaS Script by Parra Studios
3+
# Reimplementation of MetaCall FaaS platform written in TypeScript.
4+
#
5+
# Copyright (C) 2016 - 2024 Vicente Eduardo Ferrer Garcia <[email protected]>
6+
#
7+
# Licensed under the Apache License, Version 2.0 (the "License");
8+
# you may not use this file except in compliance with the License.
9+
# You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
#
19+
20+
FROM node:20-bookworm-slim
21+
22+
# Image descriptor
23+
LABEL copyright.name="Vicente Eduardo Ferrer Garcia" \
24+
copyright.address="[email protected]" \
25+
maintainer.name="Vicente Eduardo Ferrer Garcia" \
26+
maintainer.address="[email protected]" \
27+
vendor="MetaCall Inc." \
28+
version="0.1"
29+
30+
WORKDIR /metacall
31+
32+
RUN apt-get update \
33+
&& apt-get install wget ca-certificates -y --no-install-recommends \
34+
&& wget -O - https://raw.githubusercontent.com/metacall/install/master/install.sh | sh
35+
36+
COPY . .
37+
38+
RUN npm install \
39+
&& npm run build
40+
41+
EXPOSE 9000
42+
43+
CMD ["node", "dist/index.js"]

docker-compose.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#
2+
# MetaCall Library by Parra Studios
3+
# Docker compose infrastructure for MetaCall.
4+
#
5+
# Copyright (C) 2016 - 2024 Vicente Eduardo Ferrer Garcia <[email protected]>
6+
#
7+
# Licensed under the Apache License, Version 2.0 (the "License");
8+
# you may not use this file except in compliance with the License.
9+
# You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
#
19+
20+
version: '3.7'
21+
22+
services:
23+
faas:
24+
image: metacall/faas
25+
container_name: metacall_faas
26+
build:
27+
context: .
28+
dockerfile: Dockerfile
29+
ports:
30+
- "9000:9000"

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@metacall/faas",
33
"version": "0.1.0",
44
"description": "Reimplementation of MetaCall FaaS platform written in TypeScript.",
5-
"main": "dist/server.js",
5+
"main": "dist/index.js",
66
"scripts": {
77
"test": "npm run build && mocha dist/test",
88
"unit": "npm run test -- --ignore **/integration**",
@@ -11,7 +11,7 @@
1111
"build": "npm run lint && tsc",
1212
"lint": "eslint . --max-warnings=0 --ignore-pattern dist",
1313
"fix": "eslint . --max-warnings=0 --ignore-pattern dist --fix",
14-
"start": "npm run build && node dist/server.js"
14+
"start": "npm run build && node dist/index.js"
1515
},
1616
"repository": {
1717
"type": "git",

src/constants.ts

+2-9
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,9 @@ export const createInstallDependenciesScript = (
2525
return installDependenciesScript[runner];
2626
};
2727

28-
export type DeployBody = {
29-
suffix: string; // name of deployment
30-
resourceType: 'Package' | 'Repository';
31-
release: string; // release date
32-
env: string[];
33-
plan: string;
34-
version: string;
35-
};
36-
3728
export type tpackages = Record<string, unknown>;
3829

30+
// TODO: Isn't this available inside protocol package? We MUST reuse it
3931
export interface IApp {
4032
status: DeployStatus;
4133
prefix: string;
@@ -45,6 +37,7 @@ export interface IApp {
4537
ports: number[];
4638
}
4739

40+
// TODO: Isn't this available inside protocol package? We MUST reuse it
4841
export class App implements IApp {
4942
public status: DeployStatus;
5043
public prefix: string;

src/controller/delete.ts

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const deleteStatusMessage = (
2222
appShouldntExist: `The application shouldnt exist after deleting it`
2323
});
2424

25+
// TODO: Isn't this available inside protocol package? We MUST reuse it
2526
type DeleteBody = {
2627
suffix: string; // name of deployment
2728
prefix: string;

src/controller/deploy.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { hostname } from 'os';
44
import path from 'path';
55

66
import {
7-
DeployBody,
87
ProtocolMessageType,
98
WorkerMessageUnknown,
109
allApplications,
@@ -23,6 +22,16 @@ import {
2322

2423
import { PackageError } from '@metacall/protocol/package';
2524

25+
// TODO: Isn't this available inside protocol package? We MUST reuse it
26+
export type DeployBody = {
27+
suffix: string; // name of deployment
28+
resourceType: 'Package' | 'Repository';
29+
release: string; // release date
30+
env: string[];
31+
plan: string;
32+
version: string;
33+
};
34+
2635
export const deploy = catchAsync(
2736
async (
2837
req: Omit<Request, 'body'> & { body: DeployBody },

src/controller/repository.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ import AppError from '../utils/appError';
55
import { appsDirectory } from '../utils/config';
66
import { catchAsync, execPromise } from '../utils/utils';
77

8+
// TODO: Isn't this available inside protocol package? We MUST reuse it
89
type FetchFilesFromRepoBody = {
9-
branch: 'string';
10-
url: 'string';
10+
branch: string;
11+
url: string;
1112
};
1213

14+
// TODO: Isn't this available inside protocol package? We MUST reuse it
1315
type FetchBranchListBody = {
14-
url: 'string';
16+
url: string;
1517
};
1618

1719
const dirName = (gitUrl: string): string =>

src/server.ts src/index.ts

File renamed without changes.

types/metacall.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-disable */
1+
/* eslint-disable @typescript-eslint/no-explicit-any */
22

33
declare module 'metacall' {
44
export function metacall(name: string, ...args: any): any;

0 commit comments

Comments
 (0)