事前準備事前にデモアプリをgithubからCloneします。$ git clonehttps://github.com/daihiraoka/kf94maskmap$ cd kf94maskmap/$ lsLICENSE README.md api app.js images manifest.yml package-lock.jsonpackage.json static
6.
1.Nodejsをローカル環境にインストールして立ち上げる。node.jsのインストール$ curl -sLhttps://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.785sfound 0 vulnerabilities$ npm audit fix <-監査の問題を修正するために実行しますup to date in 0.457sfixed 0 of 0 vulnerabilities in 166 scanned packagesローカル環境で実行する$ npm start> kf94maskmap@0.1.1 start /home/dai/ws/kf94maskmap> node app.jsTo view your app, open this link in your browser: http://localhost:3000
Appsody はじめの1歩% appsodyTheAppsody command-line tool (CLI) enables the rapid development of cloud native applications.Complete documentation is available at https://appsody.devUsage:appsody [command]Available Commands:build Build a local container image of your Appsody project.completion Generate tab completionsdebug 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 commandinit 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 repositoriesrun Run your Appsody project in a containerized development environment.stack Tools to help create and test Appsody stacksstop 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/logsappsodyコマンドを実行すると次のような出力が表示されます。
12.
Appsodyリポジトリー、スタック、テンプレートappsody list コマンドを実行すると次のような出力が表示されます。$appsody listREPO ID VERSION TEMPLATES DESCRIPTIONexperimental go-modules 0.1.0 *default Runtime for Go using Go 1.11+ modules for dependenciesexperimental java-spring-boot2-liberty 0.1.11 *default Spring Boot on Open Liberty & OpenJ9 usingMavenexperimental nodejs-functions 0.2.0 *simple Serverless runtime for Node.js functionsexperimental quarkus 0.2.3 *default Quarkus runtime for running Java applicationsexperimental rocket 0.1.0 *simple Rocket web framework for Rustexperimental rust 0.1.6 *simple Runtime for Rust applicationsexperimental 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 applicationsREPO列はリポジトリー、IDの列はスタック名、VERSIONの列はスタックのバージョン、TEMPLATEの列は使用可能なテンプレートのリストです。
incubatorリポジトリのincubator-index.yamlの構成apiVersion: v2stacks:- id:nodejsname: Node.jsversion: 0.3.5description: Runtime for Node.js applicationslicense: Apache-2.0language: nodejsmaintainers:- name: Sam Robertsemail: vieuxtech@gmail.comgithub-id: sam-githubdefault-template: simplesrc: https://github.com/appsody/stacks/releases/download/nodejs-v0.3.5/incubator.nodejs.v0.3.5.source.tar.gztemplates:- id: simpleurl: https://github.com/appsody/stacks/releases/download/nodejs-v0.3.5/incubator.nodejs.v0.3.5.templates.simple.tar.gzrequirements:docker-version: '>= 17.09.0'appsody-version: '>= 0.2.7'image: docker.io/appsody/nodejs:0.3.5- id: kituraname: Kituraversion: 0.2.6description: Runtime for Kitura applicationslicense: Apache-2.0language: swiftmaintainers:- name: Ian Partridgeemail: i.partridge@uk.ibm.comgithub-id: ianpartridge- name: David Jonesemail: djones6@uk.ibm.comgithub-id: djones6default-template: defaultsrc: https://github.com/appsody/stacks/releases/download/kitura-v0.2.6/incubator.kitura.v0.2.6.source.tar.gz
16.
incubator.nodejs.v0.3.5.source.tar.gzの構成$ lsREADME.md stack.yamltemplates$ ls -l ./templates/合計 0drwxrwxr-x. 4 dai dai 95 3月 13 01:15 imagedrwxrwxr-x. 3 dai dai 98 3月 13 01:15 simple$ ls -l ./templates/image/合計 16-rw-rw-r--. 1 dai dai 982 3月 13 01:15 Dockerfile-stack-rw-rw-r--. 1 dai dai 11356 3月 13 01:15 LICENSEdrwxrwxr-x. 2 dai dai 29 3月 28 00:42 configdrwxrwxr-x. 2 dai dai 65 3月 28 00:42 project$ ls -l ./templates/image/config/合計 4-rw-rw-r--. 1 dai dai 272 3月 13 01:15 app-deploy.yaml$ ls -l ./templates/image/project/合計 8-rw-rw-r--. 1 dai dai 879 3月 28 00:42 Dockerfile-rw-rw-r--. 1 dai dai 335 3月 13 01:15 package.json$ lsREADME.md stack.yaml templates$ cat stack.yamlname: Node.jsversion: 0.3.5description: Runtime for Node.js applicationslicense: Apache-2.0language: nodejsmaintainers:- name: Sam Robertsemail: vieuxtech@gmail.comgithub-id: sam-githubdefault-template: simplerequirements:docker-version: ">= 17.09.0"appsody-version: ">= 0.2.7"
17.
incubator.nodejs.v0.3.5.templates.simple.tar.gzの構成$ ls -la合計20drwxrwxr-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 .gitignoredrwxrwxr-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
18.
Appsodyで新しいプロジェクトを作成する$ appsody initincubator/nodejs noneNo 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.gzDownload complete. Do not unzip the template project. Only extracting .appsody-config.yaml file from/home/dai/ws/kf94maskmap/nodejs-express.tar.gzSetting up the development environmentYour Appsody project name has been set to kf94maskmapPulling docker image docker.io/appsody/nodejs-express:0.3Running command: docker pull docker.io/appsody/nodejs-express:0.30.3: Pulling from appsody/nodejs-expressDigest: sha256:3558c07499dbb9df5bbccf417e57b82019eeb2d2995d7edea314903372f53568Status: Image is up to date for appsody/nodejs-express:0.3docker.io/appsody/nodejs-express:0.3Running 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を指定して実行します。
19.
Appsodyを使ってデモアプリを立ち上げる$ appsody runRunningdevelopment environment...Pulling docker image docker.io/appsody/nodejs:0.3Running command: docker pull docker.io/appsody/nodejs:0.30.3: Pulling from appsody/nodejsDigest: sha256:c0bc3aef3a2d5a631acfebc8fc33e2dfc230c37a0783d5ae2b6d61f93af1fe39Status: Image is up to date for appsody/nodejs:0.3docker.io/appsody/nodejs:0.3Running command: docker run --rm -p 3000:3000 -p 9229:9229 --name kf94maskmap-dev -v /home/dai/ws/kf94maskmap/:/pro[Container] Running APPSODY_PREP command: npm installaudited 166 packages in 1.01s[Container] found 0 vulnerabilities[Container]Running command: npm start --node-options --require=appmetrics-dash/attach[Container][Container] > kf94maskmap@0.1.1 start /project/user-app[Container] > node app.js[Container][Container] [Fri Mar 27 14:59:36 2020] com.ibm.diagnostics.healthcenter.loader INFO: Node Application Metrics 5.1.1.202003121[Container] [Fri Mar 27 14:59:37 2020] com.ibm.diagnostics.healthcenter.mqtt INFO: Connecting to broker localhost:1883[Container] To view your app, open this link in your browser: http://localhost:3000appsody run コマンドを実行してデモアプリを起動
Appsodyを使ってデモアプリを立ち上げる$ docker psCONTAINERID IMAGE COMMAND CREATED STATUS PORTS NAMES0baf731a99a2 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/tcpdocker psコマンドを実行するとDockerコンテナが起動していることが確認できる