Closed y12studio closed 10 years ago
y12io/projects/dockerfile/loopback-example.df at master · y12studio/y12io
$ wget https://raw.githubusercontent.com/y12studio/y12io/master/projects/dockerfile/loopback-example.df
$ cat /loopback-example.df
$ sudo docker.io build -t="test/lbex" - < loopback-example.df
// or sudo docker.io build -t="test/lbex" dockerfile_github_raw_url
$ sudo docker.io run -d -p 3000:3000 test/lbex
257e6d0a07672470451ae4a385574abcc2fbdd54bf83c77148086c533c81b4ee
lin@ubuntu73:~/docker$ sudo docker.io ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
257e6d0a0767 test/lbex:latest /bin/sh -c cd /root/ 5 seconds ago Up 5 seconds 0.0.0.0:3000->3000/tcp stoic_albattani
$ curl http://localhost:3000/
Creating a LoopBack application - StrongLoop - Documentation
$ sudo apt-get install npm
// http://stackoverflow.com/questions/20886217/browserify-error-usr-bin-env-node-no-such-file-or-directory
$ sudo apt-get install nodejs-legacy
$ sudo npm install -g strong-cli
$ slc lb project lb-hello
$ tree -L 2 lb-hello
lb-hello
├── app.js
├── app.json
├── datasources.json
├── models
├── models.json
├── node_modules
│ ├── loopback
│ ├── loopback-datasource-juggler
│ ├── loopback-explorer
│ └── loopback-push-notification
└── package.json
6 directories, 5 files
$ cd lb-hello
$ slc lb model person -i
// first last
$ node .
// browser to http://localhost:3000/explorer
// PUT new person
// Request http://192.168.2.73:3000/api/people
{
"id": 1,
"first": "Lin",
"last": "None"
}
y12io/projects/loopback-hello at master · y12studio/y12io
$ git clone https://github.com/y12studio/y12io
$ cd y12io/projects/loopback-hello/
$ sudo docker.io build -t="text/lbho" .
$ sudo docker.io run -d -p 80:3000 test/lbho
$ curl http://localhost/
y12io/projects/lbho-mongodb at master · y12studio/y12io
// start a mongo container to test
$ sudo docker.io run -d -p 27017:27017 robinvdvleuten/mongo
$ sudo docker.io ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
deaf1f7d0b4e robinvdvleuten/mongo:latest usr/bin/mongod 20 seconds ago Up 19 seconds 0.0.0.0:27017->27017/tcp clever_mccarthy
$ mongo
MongoDB shell version: 2.4.9
connecting to: test
Welcome to the MongoDB shell.
$ git clone https://github.com/y12studio/y12io
$ cd y12io/projects/lbho-mongodb/
// mongodb://devUser:devPassword@127.0.0.1:27017/devDB
$ mongo devDB mongo_adduser.js
MongoDB shell version: 2.4.9
connecting to: devDB
{
"_id" : ObjectId("5359e357d11083596fe6b045"),
"user" : "devUser",
"readOnly" : true,
"pwd" : "16f4876802b759bfa69ef124a13d2cc0"
}
$ node .
build docker image
$ sudo docker.io build -t="test/lbho-mongo" .
$ sudo docker.io run -t -i test/lbho-mongo /bin/bash
$ /start.sh
// check start.sh ok then exit
$ sudo docker.io run -d -p 80:3000 test/lbho-mongo
$ curl http://localhost/explorer/
loopback's app and mongodb in same container.
y12io/projects/lbho-mongolib at master · y12studio/y12io MongoDB Hosting: Database-as-a-Service by MongoLab
$ git clone https://github.com/y12studio/y12io
$ cd y12io/projects/lbho-mongolib
$ cat datasources.json
[...]
"mongodb": {
"defaultForType": "mongodb",
"connector": "loopback-connector-mongodb",
"url": "mongodb://myuser:mypass@ds1234.mongolab.com:28017/mydb"
}
[...]
$ sudo docker.io build -t="test/lbmo3" .
$ sudo docker.io run -d -p 80:3000 test/lbmo3 /start.sh mongodb://myuser:mypass@ds1234.mongolab.com:28017/mydb
put new person to http://localhost/explorer/ mongolab console
db.person.stats() Raw Output
{
"serverUsed": "xxx.mongolab.com/10.1.1.1:21111",
"ns": "xxxdb.person",
"count": 1,
"size": 88,
"avgObjSize": 88,
"storageSize": 8192,
"numExtents": 1,
"nindexes": 1,
"lastExtentSize": 8192,
"paddingFactor": 1,
"systemFlags": 1,
"userFlags": 0,
"totalIndexSize": 8176,
"indexSizes": {
"_id_": 8176
},
"ok": 1
}
src
ref