Ringojs using the RP package to manage web App dependencies

Source: Internet
Author: User
Tags docker run

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
    • Project structure
├── 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
    • Run locally
rp  install  
    • Docker run
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.