@faable/faable 1.1.1 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -0
- package/bin/faable.js +3 -0
- package/dist/commands/deploy/build_docker.js +14 -0
- package/dist/commands/deploy/cmd.js +11 -0
- package/dist/commands/deploy/deploy.js +42 -0
- package/dist/commands/deploy/prepare.js +33 -0
- package/dist/commands/deploy/upload_tag.js +21 -0
- package/dist/index.js +9 -0
- package/dist/log.js +10 -0
- package/package.json +14 -17
- package/templates/Dockerfile +21 -0
- package/templates/entrypoint.sh +12 -0
- package/bin/faable +0 -3
- package/dist/commands/deploy/build_docker.d.ts +0 -6
- package/dist/commands/deploy/cmd.d.ts +0 -2
- package/dist/commands/deploy/index.d.ts +0 -7
- package/dist/commands/deploy/prepare.d.ts +0 -8
- package/dist/commands/deploy/upload_tag.d.ts +0 -8
- package/dist/faable.js +0 -12
- package/dist/index.d.ts +0 -1
- package/dist/log.d.ts +0 -7
package/README.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://faable.com">
|
|
3
|
+
<img src="https://www.faable.com/logo/Emblem.png" height="96">
|
|
4
|
+
<h3 align="center">Faable</h3>
|
|
5
|
+
</a>
|
|
6
|
+
</p>
|
|
7
|
+
|
|
8
|
+
<p align="center">
|
|
9
|
+
Your React, Node.js or Python apps, up to the cloud in seconds.
|
|
10
|
+
</p>
|
|
11
|
+
|
|
12
|
+
## Faable
|
|
13
|
+
|
|
14
|
+
Faable is the best platform to build modern architectures that scale precisely to meet demand. We handle the hard stuff so you can focus on building cloud ready apps. Make your business cloud driven and join those awesome companies.
|
|
15
|
+
|
|
16
|
+
To install the latest version of Faable CLI:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm i -g @faable/faable
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Documentation
|
|
23
|
+
|
|
24
|
+
For details on how to use Faable CLI, check out our [documentation](https://docs.faable.com/).
|
package/bin/faable.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { log } from '../../log.js';
|
|
2
|
+
import { cmd } from './cmd.js';
|
|
3
|
+
|
|
4
|
+
const build_docker = async (props) => {
|
|
5
|
+
const { app_name, workdir } = props;
|
|
6
|
+
//log.info("Building...");
|
|
7
|
+
await cmd("/bin/bash", [
|
|
8
|
+
"-c",
|
|
9
|
+
`docker build -t app ${workdir} -f .faable/Dockerfile`,
|
|
10
|
+
]);
|
|
11
|
+
log.info(`✅ Build ${app_name} successful`);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { build_docker };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { log } from '../../log.js';
|
|
2
|
+
import { build_docker } from './build_docker.js';
|
|
3
|
+
import { prepare } from './prepare.js';
|
|
4
|
+
import { upload_tag } from './upload_tag.js';
|
|
5
|
+
import fs from 'fs-extra';
|
|
6
|
+
|
|
7
|
+
const deploy = {
|
|
8
|
+
command: "deploy [app_name]",
|
|
9
|
+
describe: "Deploy a faable app",
|
|
10
|
+
builder: (yargs) => {
|
|
11
|
+
return yargs
|
|
12
|
+
.positional("app_name", {
|
|
13
|
+
type: "string",
|
|
14
|
+
description: "App name to build for",
|
|
15
|
+
default: (s) => {
|
|
16
|
+
const { name } = fs.readJSONSync("./package.json");
|
|
17
|
+
return name;
|
|
18
|
+
},
|
|
19
|
+
})
|
|
20
|
+
.option("workdir", {
|
|
21
|
+
alias: "w",
|
|
22
|
+
type: "string",
|
|
23
|
+
description: "Working directory",
|
|
24
|
+
default: process.cwd(),
|
|
25
|
+
})
|
|
26
|
+
.showHelpOnFail(false);
|
|
27
|
+
},
|
|
28
|
+
handler: async (args) => {
|
|
29
|
+
const { app_name, workdir } = args;
|
|
30
|
+
if (!app_name) {
|
|
31
|
+
throw new Error("Missing app_name");
|
|
32
|
+
}
|
|
33
|
+
log.info(`Building ${app_name}`);
|
|
34
|
+
await prepare({ from_image: "node:18.12.0", workdir });
|
|
35
|
+
await build_docker({ app_name, workdir });
|
|
36
|
+
// TODO: get this data from Faable API
|
|
37
|
+
//faablecloud#${ctx.faable_user}+deployment
|
|
38
|
+
await upload_tag({ app_name, user: "", password: "" });
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export { deploy };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
import Handlebars from 'handlebars';
|
|
3
|
+
import * as path from 'path';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
5
|
+
|
|
6
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = path.dirname(__filename);
|
|
8
|
+
const templates_dir = path.join(__dirname, "../../../templates");
|
|
9
|
+
const dockerfile = fs.readFileSync(`${templates_dir}/Dockerfile`).toString();
|
|
10
|
+
// Docker template file
|
|
11
|
+
const docker_template = Handlebars.compile(dockerfile);
|
|
12
|
+
const prepare = async (props) => {
|
|
13
|
+
const { from_image, build_script = "build", start_script = "start", workdir, } = props;
|
|
14
|
+
await fs.remove(path.join(workdir, ".faable"));
|
|
15
|
+
await fs.mkdirp(path.join(workdir, ".faable"));
|
|
16
|
+
//log.info(`Preparing Dockerfile`);
|
|
17
|
+
// Compose template with data and write to path
|
|
18
|
+
const composed_file_data = docker_template({
|
|
19
|
+
from_image,
|
|
20
|
+
build_script,
|
|
21
|
+
start_script,
|
|
22
|
+
});
|
|
23
|
+
// Create Dockerfile
|
|
24
|
+
let out = path.join(workdir, ".faable", "Dockerfile");
|
|
25
|
+
await fs.writeFile(out, composed_file_data);
|
|
26
|
+
//log.info(`Created ${out}`);
|
|
27
|
+
// Copy entrypoint file
|
|
28
|
+
let out2 = path.join(workdir, ".faable", "entrypoint.sh");
|
|
29
|
+
await fs.copyFile(path.join(templates_dir, "entrypoint.sh"), out2);
|
|
30
|
+
//log.info(`Created ${out2}`);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export { prepare };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { log } from '../../log.js';
|
|
2
|
+
import { cmd } from './cmd.js';
|
|
3
|
+
|
|
4
|
+
const upload_tag = async (props) => {
|
|
5
|
+
const { hostname = "harbor.app.faable.com", user, password, app_name, } = props;
|
|
6
|
+
const tag = `${hostname}/${user}/${app_name}`;
|
|
7
|
+
// Registry login
|
|
8
|
+
await cmd("/bin/bash", [
|
|
9
|
+
"-c",
|
|
10
|
+
`echo "${password}" | docker login --username ${user} --password-stdin ${hostname}`,
|
|
11
|
+
]);
|
|
12
|
+
log.info(`Logged in ${user}`);
|
|
13
|
+
// Tag image for production
|
|
14
|
+
await cmd("docker", ["tag", "app", tag]);
|
|
15
|
+
log.info(`Tagged image ${tag}`);
|
|
16
|
+
// Upload the image to faable registry
|
|
17
|
+
await cmd("docker", ["push", tag]);
|
|
18
|
+
log.info(`Uploaded ${tag}`);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { upload_tag };
|
package/dist/index.js
ADDED
package/dist/log.js
ADDED
package/package.json
CHANGED
|
@@ -1,29 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faable/faable",
|
|
3
|
-
"
|
|
4
|
-
"main": "dist/faable.js",
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"author": "Marc Pomar <marc@faable.com>",
|
|
7
|
-
"types": "dist/index.d.ts",
|
|
8
|
-
"bugs": {
|
|
9
|
-
"url": "https://github.com/faablecloud/faable/issues"
|
|
10
|
-
},
|
|
11
|
-
"homepage": "https://github.com/faablecloud/faable#readme",
|
|
12
|
-
"bin": {
|
|
13
|
-
"faable": "bin/faable"
|
|
14
|
-
},
|
|
3
|
+
"main": "dist/index.js",
|
|
15
4
|
"dependencies": {
|
|
16
5
|
"@actions/core": "^1.10.0",
|
|
17
6
|
"fs-extra": "^11.1.0",
|
|
18
7
|
"handlebars": "^4.7.7",
|
|
19
8
|
"promisify-child-process": "^4.1.1",
|
|
20
|
-
"yargs": "^17.6.2"
|
|
21
|
-
"tslib": "^2.4.1"
|
|
9
|
+
"yargs": "^17.6.2"
|
|
22
10
|
},
|
|
23
|
-
"
|
|
24
|
-
"
|
|
11
|
+
"bin": {
|
|
12
|
+
"faable": "bin/faable.js"
|
|
13
|
+
},
|
|
14
|
+
"type": "module",
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"author": "Marc Pomar <marc@faable.com>",
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/faablecloud/faable/issues"
|
|
25
20
|
},
|
|
26
21
|
"publishConfig": {
|
|
27
22
|
"access": "public"
|
|
28
|
-
}
|
|
23
|
+
},
|
|
24
|
+
"homepage": "https://github.com/faablecloud/faable#readme",
|
|
25
|
+
"version": "1.2.1"
|
|
29
26
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
FROM {{from_image}}
|
|
2
|
+
LABEL com.faable.cloud="FaableCloud"
|
|
3
|
+
LABEL description="Faablecloud automatic deployment"
|
|
4
|
+
|
|
5
|
+
WORKDIR /faable/app
|
|
6
|
+
|
|
7
|
+
# Environment variables for runtime
|
|
8
|
+
ENV PORT=80
|
|
9
|
+
ENV NODE_ENV=production
|
|
10
|
+
|
|
11
|
+
# Copy Usercode
|
|
12
|
+
COPY ../ /faable/app
|
|
13
|
+
|
|
14
|
+
# Build the project if requested
|
|
15
|
+
{{#if build_script}}
|
|
16
|
+
RUN echo "Running build command: {{build_script}}"
|
|
17
|
+
RUN yarn run {{build_script}}
|
|
18
|
+
{{/if}}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
ENTRYPOINT ["/bin/sh", "/faable/app/entrypoint.sh","{{start_script}}"]
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
|
|
3
|
+
NPM_RUN_COMMAND=$1
|
|
4
|
+
|
|
5
|
+
NODE_VERSION=$(node --version)
|
|
6
|
+
NPM_VERSION=$(npm --version)
|
|
7
|
+
YARN_VERSION=$(yarn --version)
|
|
8
|
+
echo "FaableCloud · Node:$NODE_VERSION NPM:$NPM_VERSION Yarn:$YARN_VERSION"
|
|
9
|
+
echo "Running npm script -> $NPM_RUN_COMMAND"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
yarn run $NPM_RUN_COMMAND
|
package/bin/faable
DELETED
package/dist/faable.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const yargs_1 = (0, tslib_1.__importDefault)(require("yargs"));
|
|
6
|
-
const helpers_1 = require("yargs/helpers");
|
|
7
|
-
const deploy_1 = require("./commands/deploy");
|
|
8
|
-
(0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
|
|
9
|
-
.scriptName("faable")
|
|
10
|
-
.command(deploy_1.deploy)
|
|
11
|
-
.demandCommand(1)
|
|
12
|
-
.parse();
|
package/dist/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|