The RP is a package management tool similar to NPM, and we can use Package.json to define dependencies
Then execute the RP install, similar to the Ringo-admin function
Where packages is similar to Node Node_modules, the installed package is in the packages directory
Reference Code
├── Dockerfile // dockerfile ├── README.md├── app│ ├── app.js // app module│ ├── index.js // app module 入口│ └── package.json // app 包信息├── boot.js ├── docker-compose.yaml // docker-compose 配置├── index.js // stick web app 入口├── package.json // 定义项目以及包依赖└── user ├── package.json // user module └── user.js // user module
- Code description
Mainly the use of stick and the definition of module, reference
app/app.jsexports.app= {name: "Dalong", Age:33,type: "App"}app/index.js:const {app} =require ("./app") Exports.app=app ; App/package.json: Portal {"version": "1.0.0", "main": "App.js", "License": "MIT"}index.js:app portal similar to express framework const {APP} = re Quire ("./app") const {User} = require ("./user") const BOOT = require ("./boot") Console.dir (Boot.run ()) var {application} = Require (' stick '); var response = require ("Ringo/jsgi/response") var app2 = Exports.app = new application (); app2.configure (' route '); App2.get ('/', function (request) {return {body: [' Hello World Dalongdemo '],headers: {' content-type ': ' text/ html '},status:200}}); App2.get ("/user", function (Request) {return response.html ("<div>" +json.stringify ( request.headers) + "<br>" +json.stringify (user) + "</div>")}) if (Require.main = = module) {require (' ringo/ Httpserver '). Main (module.id);} Dockerfile:from dalongrong/ringojs-docker:1.2.1-localworkdir/appcopy. /app/run RP Install-yentrypoint ["Ringo", "Index.js", "-H", "0.0.0.0"]docker-compose.yaml:Version: "3" Services:app:image:dalongrong/ringojs-app-demo Build:./ports:-"8,080:8,080"
Build && Run
rp install
docker-compose builddocker-compose up -d
Run effect
Installed Package Pakcages
Web Runtime interface
Resources
Https://github.com/rongfengliang/ringojs-module-demo
https://ringojs.org/documentation/package_management/
Ringojs using the RP package to manage web App dependencies