1.Nodejsをローカル環境にインストール して立ち上げる。 node.jsのインストール $ curl -sL https://rpm.nodesource.com/setup_13.x | sudo bash - $ sudo yum install nodejs $ npm install <- ノードの依存関係をインストールするために実行 added 58 packages from 49 contributors and audited 166 packages in 1.785s found 0 vulnerabilities $ npm audit fix <-監査の問題を修正するために実行します up to date in 0.457s fixed 0 of 0 vulnerabilities in 166 scanned packages ローカル環境で実行する $ npm start > [email protected] start /home/dai/ws/kf94maskmap > node app.js To view your app, open this link in your browser: http://localhost:3000
Appsody はじめの1歩 % appsody The Appsody command-line tool (CLI) enables the rapid development of cloud native applications. Complete documentation is available at https://appsody.dev Usage: appsody [command] Available Commands: build Build a local container image of your Appsody project. completion Generate tab completions debug Debug your Appsody project. deploy Build and deploy your Appsody project to Kubernetes. extract Extract your Appsody project to a local directory. help Help about any command init Initialize an Appsody project. list List the available Appsody stacks. operator Install or uninstall the Appsody operator from your Kubernetes cluster. ps List the Appsody containers running in the local Docker environment. repo Manage your Appsody repositories run Run your Appsody project in a containerized development environment. stack Tools to help create and test Appsody stacks stop Stop the local, running Appsody container. test Test your project in the local Appsody environment. version Show the version of the Appsody CLI. Flags: --config string The absolute path to the Appsody config file. Use this option when you want to specify your own, customized config file (default '$HOME/.appsody/.appsody.yaml') --dryrun Shows the commands that are called by this command, without running them. -h, --help help for appsody -v, --verbose Prints more detailed log output, to the console and to a file in $HOME/.appsody/logs appsodyコマンドを実行すると次のような出力が表示されます。
Appsodyリポジトリー、スタック、テンプレート appsody list コマンドを実行すると次のような出力が表示されます。 $ appsody list REPO ID VERSION TEMPLATES DESCRIPTION experimental go-modules 0.1.0 *default Runtime for Go using Go 1.11+ modules for dependencies experimental java-spring-boot2-liberty 0.1.11 *default Spring Boot on Open Liberty & OpenJ9 using Maven experimental nodejs-functions 0.2.0 *simple Serverless runtime for Node.js functions experimental quarkus 0.2.3 *default Quarkus runtime for running Java applications experimental rocket 0.1.0 *simple Rocket web framework for Rust experimental rust 0.1.6 *simple Runtime for Rust applications experimental vertx 0.1.4 *default Eclipse Vert.x runtime for running Java applications *incubator node-red 0.1.2 *simple Node-RED runtime for running flows *incubator nodejs 0.3.5 *simple Runtime for Node.js applications *incubator nodejs-express 0.4.6 scaffold, *simple Express web framework for Node.js *incubator nodejs-loopback 0.2.3 *scaffold LoopBack 4 API Framework for Node.js *incubator python-flask 0.2.2 *simple Flask web Framework for Python *incubator starter 0.1.2 *simple Runnable starter stack, copy to create a new stack *incubator swift 0.2.5 *simple Appsody runtime for Swift applications REPO列はリポジトリー、IDの列はスタック名、VERSIONの列はスタックのバージョン、 TEMPLATEの列は使用可能なテンプレートのリストです。
incubator.nodejs.v0.3.5.templates.simple.tar.gz の構成 $ ls -la 合計 20 drwxrwxr-x. 3 dai dai 126 3月 28 00:41 . drwxrwxr-x. 4 dai dai 164 3月 28 02:16 .. -rw-rw-r--. 1 dai dai 35 3月 13 01:16 .appsody-config.yaml -rw-rw-r--. 1 dai dai 1316 3月 13 01:15 .gitignore drwxrwxr-x. 2 dai dai 43 3月 13 01:15 .vscode -rw-rw-r--. 1 dai dai 37 3月 13 01:15 app.js -rw-rw-r--. 1 dai dai 76 3月 13 01:15 package-lock.json -rw-rw-r--. 1 dai dai 358 3月 13 01:15 package.json
Appsodyで新しいプロジェクトを作成する $ appsody init incubator/nodejs none No stack requirements set. Skipping... Running appsody init... Downloading nodejs-express template project from https://github.com/appsody/stacks/releases/download/nodejs- express-v0.3.0/incubator.nodejs-express.v0.3.0.templates.simple.tar.gz Download complete. Do not unzip the template project. Only extracting .appsody-config.yaml file from /home/dai/ws/kf94maskmap/nodejs-express.tar.gz Setting up the development environment Your Appsody project name has been set to kf94maskmap Pulling docker image docker.io/appsody/nodejs-express:0.3 Running command: docker pull docker.io/appsody/nodejs-express:0.3 0.3: Pulling from appsody/nodejs-express Digest: sha256:3558c07499dbb9df5bbccf417e57b82019eeb2d2995d7edea314903372f53568 Status: Image is up to date for appsody/nodejs-express:0.3 docker.io/appsody/nodejs-express:0.3 Running command: docker run --rm --entrypoint /bin/bash docker.io/appsody/nodejs-express:0.3 -c "find /project -type f -name .appsody-init.sh" Successfully initialized Appsody project with the appsodyhub030/nodejs-express stack and no template. appsody initコマンドを使って新しいプロジェクトを作成します。 例えば、incubatorリポジトリのnodejsスタックを使って、 ソースコードは既にあるソースコード(kf94maskmap)を使うので templateは使わない noneを指定して実行します。
Appsodyを使ってデモアプリを立ち上げる $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 0baf731a99a2 appsody/nodejs:0.3 "/.appsody/appsody-c…" 3 minutes ago Up 3 minutes 0.0.0.0:3000->3000/tcp, 0.0.0.0:9229->9229/tcp docker psコマンドを実行するとDockerコンテナが起動していることが確認できる