0.2.3 • Published 7 months ago

ecsc v0.2.3

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
7 months ago

ECSC (ECS Command-line Tool)

ECSC 是翼辉 ECS (Edge Container Stack) 的命令行工具,您可以使用它进行:

  • 创建容器 Bundle(文件夹)。
  • 打包容器 Bundle 并输出一个 OCI 容器镜像 tar 包。

开始

# install the package globally
npm install -g ecsc

# verify if the package has been installed
ecsc version

# print help document
ecsc help

工作流程

创建一个容器镜像,需要以下三个步骤:

  1. 创建一个容器 Bundle 目录。
  2. 将需要打包的文件拷贝到该 Bundle 目录内。
  3. 将 Bundle 目录打包为一个 tar 包。

1. 创建容器 Bundle

用户可以使用如下的命令创建一个空容器 Bundle:

ecsc create

以上命令将启动创建流程的交互。

  _____ ____ ____     ____                                          _       _ _              _____           _
 | ____/ ___/ ___|   / ___|___  _ __ ___  _ __ ___   __ _ _ __   __| |     | (_)_ __   ___  |_   _|__   ___ | |
 |  _|| |   \___ \  | |   / _ \| '_ ` _ \| '_ ` _ \ / _` | '_ \ / _` |_____| | | '_ \ / _ \   | |/ _ \ / _ \| |
 | |__| |___ ___) | | |__| (_) | | | | | | | | | | | (_| | | | | (_| |_____| | | | | |  __/   | | (_) | (_) | |
 |_____\____|____/   \____\___/|_| |_| |_|_| |_| |_|\__,_|_| |_|\__,_|     |_|_|_| |_|\___|   |_|\___/ \___/|_|
? What is the name of the bundle?

用户需要回答交互过程提到的如下问题:

  • Bundle 目录的名称。
  • 容器待运行的目标设备架构 (可选:x86-64, arm64, arm, mips64, ppc, loongarch)。
  • 该容器是否需要自动映射 JSRE 的运行环境 (将自动映射容器的 '/bin/javascript' 和 '/lib' 至宿主环境)。
  • 容器的启动参数。

举例,创建一个名为 demo 并运行在 x86-64 架构下的容器, 自动映射 JSRE 环境并设置启动参数为 javascript /apps/HelloVSOA.js:

? What is the name of the bundle? demo
? What is the architecture of the target device? x86-64
? Do you want to using the JSRE of the host? Yes
? What is the start argument of the image? javascript /apps/HelloVSOA.js
> create demo/config.json success!
> create demo/rootfs/apps success!
> create demo/rootfs/home success!
> create demo/rootfs/boot success!
> create demo/rootfs/qt success!
> create demo/rootfs/dev success!
> create demo/rootfs/lib success!
> create demo/rootfs/proc success!
> create demo/rootfs/root success!
> create demo/rootfs/tmp success!
> create demo/rootfs/sbin success!
> create demo/rootfs/usr success!
> create demo/rootfs/var success!
> create demo/rootfs/etc success!
> create demo/rootfs/etc/startup.sh success!

以上流程结束后,将会在当前的工作目录下生成容器的 Bundle 目录,并且将会自动生成 '/etc/startup.sh' 文件并在其中配置命令 'shstack 200000'。

以上 create 命令也支持命令行参数(适用于自动化脚本):

ecs create [options]  create bundle with options or start an interactive wizard. 

  -h | --help     print this help document
  -d directory    path to local OCI bundle directory to be created.
  -a arch         CPU architect to use, defaults to 'noarch' if not set, check
                  CPU Architect section for more information.
  -p args         container process (entrypoint) and its arguments.
  -j              if set, mount and use host JSRE files.
  -o              if set, overwrite exsiting bundle directory if exist.

CPU Architect
  noarch, x86-64, arm64, arm, riscv64, mips64, ppc, loongarch

Example
  ecs create -d ./demo -p '/bin/javascript /apps/demo.js'

拷贝文件

当前,用户需要手动将必要的文件拷贝到容器 Bundle 内。

打包容器 Bundle

用户使用如下的命令将容器 Bundle 打包为 tar 包。

ecsc  pack  tarballPath  bundle  name  tag
  • tarballPath 指定 tar 包的生成路径,其后缀必须为 '.tar'。
  • bundle 指定需要打包的容器 Bundle。
  • name 指定容器镜像包显示的名称(非容器镜像文件名)。
  • tag 指定容器的标签,如 latest

举例,将如上的 'demo' Bundle 打包为 demo.tar:

ecsc pack demo.tar demo x64_demo latest

以上命令执行后,将在当前工作目录中生成 demo.tar 容器镜像包。

注意:

除了通过上述 ecsc 交互的方式,还可通过 Ecsfile 工具进行镜像打包。具体使用请参考 Ecsfile 使用说明

0.2.3

7 months ago

0.2.2

10 months ago

0.2.1

12 months ago

0.2.0

1 year ago

0.1.11

2 years ago

0.1.9

2 years ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago

0.0.1

2 years ago