@3share/3share-cli 中文文档教程

发布于 5年前 浏览 27 项目主页 更新于 3年前

3share-cli

3Share CLI 帮助 AEM 开发人员节省为其项目构建本地开发环境的时间。 它利用 docker 构建独立的 AEM 环境,并将配置保存在您的项目目录中。 有一个内置的反向代理,可让您通过本地 URL 访问堆栈中的服务器。

Why use 3share-cli

很多时候您可能想要处理不同的 AEM 版本、内容和代码库。 管理正在运行的 AEM 服务器、JDK 版本和 Maven 设置可能会出现问题。 使用 cli,您将拥有一个带有正确 AEM、jdk 和具有 Maven 依赖项的构建容器的隔离环境。 使用它可以同时运行多个堆栈。

Prerequisites

为了利用 cli,您需要已经安装了 Docker 和 Node。

Installing Node

在 Mac 上安装节点的最简单方法是使用 Homebrew

brew install node

Installing Docker

请参阅此链接: [https://docs.docker.com/docker-for-mac/install/]

或如果您仍在使用 OSX Yosemite 10.10.5,请使用此链接 [https://download.docker.com/mac/stable/18950/Docker.dmg]

Install the cli

cli 是用 Javascript 编写的,并打包为可运行的 npm 模块。 要安装或更新运行:

npm install @3share/3share-cli -g

这将在全局安装 cli,并且可以从您环境中的任何位置的命令行访问它。

How to get started

对于每个要使用该工具的项目,您需要转到项目的目录(或将成为项目基础的目录)。

➜  g6 3share-cli init
? What template do you want? author
? What AEM version do you want? 6.5
? What Java JDK version do you want? 8u231
? What environment name would you like to use? g6
? What domain do you want to use, like docker.localhost? g6.localhost
? Do you want sample data installed? No
? What port do you want to access your environment on? 8280
? What port do you want your conrtol panel to be on 8281
? What is the username in you AEM license? If you do not have it go to https://licensing.adobe.com/ client-name
? What is your AEM license serial number? If you do not have it go to https://licensing.adobe.com/ xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
? Where is the project located? Use an absolute path otherwise it will be located in the .3share-cli .//
? Where is do you want the Mvnvm directory? The Mvnvm directory is where Maven files and repos are saved. .//.mvnvm

Initialize Project

创建一个新目录或进入现有项目目录。 然后键入此内容,不要忘记 sudo:

sudo 3share-cli init

回答一系列问题,现在您的项目已准备好用于 cli。


Setting Host file for local domains

➜  sudo 3share-cli hosts
Password:
Initializing hosts file
set /etc/hosts successfully!```
Running as sudo allows the cli to make changes to your hosts file.
---

Build your Containers

Build 将创建 bas 容器并将它们注册到您的本地 docker 存储库中。 如果这些基础图像具有相同的所需 jdk,则它们可以被多个堆栈使用。 这些基础图像将用于构建您的堆栈。 这可能需要一些时间并产生大量输出。 下面已将其缩写。

➜   3share-cli build
Building 3share/base
Sending build context to Docker daemon  2.577MB
Step 1/4 : FROM centos:7
 ---> 9f38484d220f
Step 2/4 : LABEL Vendor="3Share"       Maintainer="Gordon Pike"
 ---> Using cache
 ---> ad37d01f7b2e
Step 3/4 : RUN yum -y --setopt=tsflags=nodocs update &&     yum clean all &&     yum install ansible -y &&     yum install git -y
 ---> Using cache
 ---> 163199d1ea97

...

Successfully built 5572bf7d8631
Successfully tagged mvnvm:latest
child process exited with code 0

除非您升级,否则每个堆栈只需要运行一次。


Bring up Your Environment

➜  3share-cli up
Environment Name:xxx

这将启动您的新环境,启动所有容器。 默认情况下,每个服务器的所有输出都会进入控制台。 您可以通过添加 -d 或 --detach 在分离模式下运行它,

➜  3share-cli up --detach
Environment Name:xxx

这将在后台运行堆栈。


Access Traefik Dashboard

3share-cli dashboard

这将打开您的默认浏览器并将其指向 Traefik 的仪表板。 您可以看到您环境的所有后端和前端。


堆栈中的每个服务都可以从域中访问。 目前的服务包括作者、出版、调度员。

要联系作者,请键入以下内容:

3share-cli open author

您的默认浏览器将打开并定向到作者的公共 url。


Bring Down Your Environment

只要您在 docker 中有足够的空间和内存,就无需关闭容器。 如果您需要将它们关闭,请键入:

3share-cli down

这将停止容器。


Build Container for compiling project files

除了堆栈中的其他服务器外,还有一个预配置了 mvnvm (http://mvnvm.org/) 的容器,这是一个 Maven 版本管理器。 在项目的基础上创建一个 mvnvm.properties 文件,其中包含您要用于项目的 Maven 版本。 第一次使用容器构建时,它将下载适当版本的 Maven。

$ echo "mvn_version=3.0.5" > mvnvm.properties
$ git add mvnvm.properties

要使用构建容器,请在终端中运行 dev 命令。

3share-cli dev

这将在构建 docker 容器内打开一个终端。 该容器可以访问您的 /project 下的项目文件,并且可以部署给你的作者,因为它有一个别名,命令如下:

mvn -PautoInstallPackage -Padobe-public clean install  -Dmaven.test.skip=true -Dcrx.host=author -Dcrx.port=4502 -e

该包将安装在你的作者服务器上,4502 端口是作者在你的堆栈中的内部端口。


3share-cli

The 3Share CLI helps AEM developers save time in building local development environmnets for their projects. It utilizes docker to build isolated AEM environments and the configuration is save in your project directory. There is a built reverse proxy that gives you a local url access to the servers in your stack.

Why use 3share-cli

Many time you may want to work on different AEM version, content and code bases. Managing the running AEM servers, JDK versions and Maven setup can get problematic. With the cli, you have an isolated environment with the right AEM, jdk and a build conatiner that has your Maven dependencies. Using it it's possible to run multiple stacks at the same time.

Prerequisites

In order to take advantage of the cli, you need to have already installed Docker and Node.

Installing Node

The easiest way to install node on a Mac is with Homebrew

brew install node

Installing Docker

See this link: [https://docs.docker.com/docker-for-mac/install/]

or use this link if you are still on OSX Yosemite 10.10.5 [https://download.docker.com/mac/stable/18950/Docker.dmg]

Install the cli

The cli is written in Javascript and is packaged as a runnable npm module. To install or update run:

npm install @3share/3share-cli -g

This will install the cli globally and it will be accessible from the command line anywhere in your environment.

How to get started

For each project you want to use the tool for you need to go to tyhe directory for your project (or a directory that will be the base for your project).

➜  g6 3share-cli init
? What template do you want? author
? What AEM version do you want? 6.5
? What Java JDK version do you want? 8u231
? What environment name would you like to use? g6
? What domain do you want to use, like docker.localhost? g6.localhost
? Do you want sample data installed? No
? What port do you want to access your environment on? 8280
? What port do you want your conrtol panel to be on 8281
? What is the username in you AEM license? If you do not have it go to https://licensing.adobe.com/ client-name
? What is your AEM license serial number? If you do not have it go to https://licensing.adobe.com/ xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
? Where is the project located? Use an absolute path otherwise it will be located in the .3share-cli .//
? Where is do you want the Mvnvm directory? The Mvnvm directory is where Maven files and repos are saved. .//.mvnvm

Initialize Project

Create a new directory or go into an existing project directory. Then type this, don't forget the sudo:

sudo 3share-cli init

Answer a series of questions and now your project is ready for the cli.


Setting Host file for local domains

➜  sudo 3share-cli hosts
Password:
Initializing hosts file
set /etc/hosts successfully!```
Running as sudo allows the cli to make changes to your hosts file.
---

Build your Containers

Build will create bas containers and register them in your local docker repository. These base images can be used by multiple stacks if they have the same needed jdk. These base images will be used to build your stack. Thi can take some time and produce a lot of output. It's been abbreviated below.

➜   3share-cli build
Building 3share/base
Sending build context to Docker daemon  2.577MB
Step 1/4 : FROM centos:7
 ---> 9f38484d220f
Step 2/4 : LABEL Vendor="3Share"       Maintainer="Gordon Pike"
 ---> Using cache
 ---> ad37d01f7b2e
Step 3/4 : RUN yum -y --setopt=tsflags=nodocs update &&     yum clean all &&     yum install ansible -y &&     yum install git -y
 ---> Using cache
 ---> 163199d1ea97

...

Successfully built 5572bf7d8631
Successfully tagged mvnvm:latest
child process exited with code 0

This only need to be run once per stack unless you upgrade.


Bring up Your Environment

➜  3share-cli up
Environment Name:xxx

This will start your new environment spinning up all of your containers. By default all output from each server goes into the console. You can runn it in detached mode by adding -d or --detach

➜  3share-cli up --detach
Environment Name:xxx

This will run the stack in the background.


Access Traefik Dashboard

3share-cli dashboard

This will open your default browser and point it to the dashboard for Traefik. You can see all backed and frontends of your environment.


Each of the services in your stack can be accessed from the domain. Services at the moment include author, publish, dispatcher.

To reach the author type the following:

3share-cli open author

Your default browser will open and be directed to the public url for the author.


Bring Down Your Environment

There is no need to bring down the containers as long as you have enough room abd memory in docker. If you need to bring them down then type:

3share-cli down

This will stop the containers.


Build Container for compiling project files

Along with the other servers in you stack there is also a container preconfigured with mvnvm (http://mvnvm.org/) a Maven Version Manager. At the base of your project create a mvnvm.properties file that has the version of Maven you want to use for your project. The first time you build using the container it will download the appropriate version of Maven.

$ echo "mvn_version=3.0.5" > mvnvm.properties
$ git add mvnvm.properties

To use your build container run the dev command in a terminal.

3share-cli dev

This will bring up a terminal inside the build docker container. The container has access to your project files under /project and can deploy to you author because it has an alias with a command like:

mvn -PautoInstallPackage -Padobe-public clean install  -Dmaven.test.skip=true -Dcrx.host=author -Dcrx.port=4502 -e

The package would be installed on your Author server and the 4502 port is the internal port for author in your stack.


    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文