Skip to content

Commit

Permalink
Add base for test with docker compose.
Browse files Browse the repository at this point in the history
  • Loading branch information
viferga committed Apr 11, 2024
1 parent ab1755b commit 8f2cbf3
Show file tree
Hide file tree
Showing 12 changed files with 97 additions and 17 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
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
43 changes: 43 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#
# MetaCall FaaS Script by Parra Studios
# Reimplementation of MetaCall FaaS platform written in TypeScript.
#
# Copyright (C) 2016 - 2024 Vicente Eduardo Ferrer Garcia <vic798@gmail.com>
#
# 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

# Image descriptor
LABEL copyright.name="Vicente Eduardo Ferrer Garcia" \
copyright.address="vic798@gmail.com" \
maintainer.name="Vicente Eduardo Ferrer Garcia" \
maintainer.address="vic798@gmail.com" \
vendor="MetaCall Inc." \
version="0.1"

WORKDIR /metacall

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 . .

RUN npm install \
&& npm run build

EXPOSE 9000

CMD ["node", "dist/index.js"]
30 changes: 30 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#
# MetaCall Library by Parra Studios
# Docker compose infrastructure for MetaCall.
#
# Copyright (C) 2016 - 2024 Vicente Eduardo Ferrer Garcia <vic798@gmail.com>
#
# 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
ports:
- "9000:9000"
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@metacall/faas",
"version": "0.1.0",
"description": "Reimplementation of MetaCall FaaS platform written in TypeScript.",
"main": "dist/server.js",
"main": "dist/index.js",
"scripts": {
"test": "npm run build && mocha dist/test",
"unit": "npm run test -- --ignore **/integration**",
Expand All @@ -11,7 +11,7 @@
"build": "npm run lint && tsc",
"lint": "eslint . --max-warnings=0 --ignore-pattern dist",
"fix": "eslint . --max-warnings=0 --ignore-pattern dist --fix",
"start": "npm run build && node dist/server.js"
"start": "npm run build && node dist/index.js"
},
"repository": {
"type": "git",
Expand Down
11 changes: 2 additions & 9 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,9 @@ export const createInstallDependenciesScript = (
return installDependenciesScript[runner];
};

export type DeployBody = {
suffix: string; // name of deployment
resourceType: 'Package' | 'Repository';
release: string; // release date
env: string[];
plan: string;
version: string;
};

export type tpackages = Record<string, unknown>;

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

// TODO: Isn't this available inside protocol package? We MUST reuse it
export class App implements IApp {
public status: DeployStatus;
public prefix: string;
Expand Down
1 change: 1 addition & 0 deletions src/controller/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const deleteStatusMessage = (
appShouldntExist: `The application shouldnt exist after deleting it`
});

// TODO: Isn't this available inside protocol package? We MUST reuse it
type DeleteBody = {
suffix: string; // name of deployment
prefix: string;
Expand Down
11 changes: 10 additions & 1 deletion src/controller/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { hostname } from 'os';
import path from 'path';

import {
DeployBody,
ProtocolMessageType,
WorkerMessageUnknown,
allApplications,
Expand All @@ -23,6 +22,16 @@ import {

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

// TODO: Isn't this available inside protocol package? We MUST reuse it
export type DeployBody = {
suffix: string; // name of deployment
resourceType: 'Package' | 'Repository';
release: string; // release date
env: string[];
plan: string;
version: string;
};

export const deploy = catchAsync(
async (
req: Omit<Request, 'body'> & { body: DeployBody },
Expand Down
8 changes: 5 additions & 3 deletions src/controller/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ import AppError from '../utils/appError';
import { appsDirectory } from '../utils/config';
import { catchAsync, execPromise } from '../utils/utils';

// TODO: Isn't this available inside protocol package? We MUST reuse it
type FetchFilesFromRepoBody = {
branch: 'string';
url: 'string';
branch: string;
url: string;
};

// TODO: Isn't this available inside protocol package? We MUST reuse it
type FetchBranchListBody = {
url: 'string';
url: string;
};

const dirName = (gitUrl: string): string =>
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion types/metacall.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable */
/* eslint-disable @typescript-eslint/no-explicit-any */

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

0 comments on commit 8f2cbf3

Please sign in to comment.