Docker compose nginx


Catatan setup nginx di docker supaya bisa ngeload volume diluar file directorynya docker

Buat docker-compose.yml isikan baris perintah dibawah

version: '2'

services:

nginx:

image: nginx:latest

container_name: production_nginx

volumes:

- /home/onix/sites:/usr/share/nginx/html:z #directory internal:directory docker

ports:

- '8080:80'

Udah gitu aja mudah bukan

Happy Coding ..

Salam ngoprek

Advertisements

Docker manager web based


Screen Shot 2018-10-07 at 06.53.06

Docker manager mantap via web base lagi yang penasaran silahkan ke sini https://portainer.io/ dan kerennya lagi si portainernya juga bisa dijalankan lewat docker ngga perlu install manual cool right !.

docker run -d -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock portainer/portainer

Happy Coding …

Salam ngoprek …

install odoo menggunakan docker


Ada yang belum kenal odoo baca disini ya https://www.odoo.com/  ya odoo adalah open source ERP dan CRM, kedua aplikasi ini banyak digunakan untuk perusahaan untuk memanage jalannya operasional perusahaan, modulnya banyak banget dari HR, Project Management, Procurement, dll, bagi yang penasaran silahkan baca baca sendiri di websitenya odoo ya.

Kali ini saya akan sharing bagaimana caranya menginstall odoo dengan menggunakan docker caranya cukup mudah tinggal siapkan OS yang akan diinstall kemudian install docker (cari digoogle ttg cara install docker) kemudian silahkan baca dokumentasinya disini https://hub.docker.com/_/odoo/.

Untuk kali ini saya menginstall docker menggunakan OS ubuntu server, caranya gampang banget pertama tama git clone link berikut https://github.com/odoo/docker kemudian masuk ke folder versi docker yang sudah tersedia untuk kali ini saya menggunakan versi 11 karena pada saat tulisan ini dibuat versi 12 baru saja release jadi amannya pake versi sebelumnya dulu.

Setelah memilih versi odoo (saya menggunakan versi 11) tinggal jalankan command ini

docker run -d -e POSTGRES_USER=odoo -e POSTGRES_PASSWORD=odoo --name db postgres:9.4
docker run -p 8069:8069 --name odoo --link db:db -t odoo

Udah gitu aja 🙂 mudah bukan saya menyarankan ubah nama user dan password pada saat menjalankan db dibagian POSTGRES_USER dan POSTGRES_PASSWORD setelah diinstall silahkan buka browser lalu masukkan alamat ip dilanjutkan dengan nomor port contoh http://localhost:8069 atau ganti localhost dengan nomor ip sobat sekalian.

kalau ngga mau ribet masukkan port bisa juga dengan menambahkan ip tables seperti ini di

/etc/rc.local diatas exit

iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8069

Setelah reboot maka odoo bisa diakses menggunakan ip tanpa port

Silahkan mencoba dan happy coding …

Salam Ngoprek …

Membuka drive NTFS di Mac


Sekedar sharing bagaimana caranya membuka partisi ntfs di Mac, bagi sebagian pengguna Mac membuka partisi ntfs tidak semudah seperti pengguna windows karena memang mac sendiri tidak menggunakan ntfs sebagai primary partition, dan ribetnya adalah ketika akan membuka harddisk eksternal yang kebanyakan berpartisi ntfs kita tidak bisa write disitu jadi hanya read mode saja, dan ini terjadi pada diri saya yang kebetulan menggunakan Mac OS dirumah dan berbagai macam OS dikantor.

Yah langsung aja begini caranya, sebenarnya ada berbagai macam cara dan yang paling mudah adalah download aplikasi berbayar dan langsung bisa digunakan, dan cara agak ribetnya adalah tapi gratis adalah seperti dibawah ini.

Pertama tama adalah download Fuse For Mac disini terus buka terminal terus ketik ini

xcode-select --install

Kalau belum diinstall terus install, kemudian install brew ikuti langkah disini kalau udah install ntfs-3g menggunakan brew

brew install ntfs-3g

Continue reading Membuka drive NTFS di Mac

Displaying data from RHF1S001 in node-red


rhf1s001The RisingHF’s Temperature and humidity LoRaWAN sensor node RHF1S001 is aimed at outdoor application with it’s IP64 protection level. And thanks to it’s high performance internal antenna and LoRa technology used, the sensor could operate in extremely hard environment or ultra-long range application. In addition to all above, the ultra-low sleep current help it to work in a long life, 5 years (uplink every 2 minutes) or even 10 (uplink every 5 minutes) years.

Here is sample code to displaying data to dashboard node-red, Raw data taken from MQTT convert to JSON Object.

Screenshot from 2018-07-03 07-53-19

[{"id":"4e63f2ca.376b64","type":"mqtt in","z":"b6605d08.a927b","name":"","topic":"thrf/#","qos":"2","broker":"ce3645f8.a18d78","x":70,"y":2920,"wires":[["9c30a7cc.16ac38"]]},{"id":"a4fb0e04.52f6b","type":"function","z":"b6605d08.a927b","name":"decode temp","func":"var obj = msg.payload;\nvar data = obj.data;\n\nvar temp1 = data.toString().substr(2, 2);\nvar temp2 = data.toString().substr(4, 2);\nvar temp = temp2 + temp1;\n// var tmp = \"0x\" + temp; \n\nfunction hexToDec(hex) {\n return hex.toLowerCase().split('').reduce( (result, ch) =>\n result * 16 + '0123456789abcdefgh'.indexOf(ch), 0);\n}\n\nvar value = hexToDec(temp);\n\nvar t = ((175 * value)/65536) - 46.85;\n\nmsg.payload = t.toFixed(2);\n// return msg;\n// msg.payload = obj.data;\nreturn msg;","outputs":1,"noerr":0,"x":430,"y":2980,"wires":[["db7f0faf.eec008"]]},{"id":"de0b9d41.21bd3","type":"function","z":"b6605d08.a927b","name":"data","func":"var obj = msg.payload;\nmsg.payload = obj.data;\nreturn msg;","outputs":1,"noerr":0,"x":410,"y":2920,"wires":[["88553271.5b5678"]]},{"id":"88553271.5b5678","type":"debug","z":"b6605d08.a927b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":590,"y":2920,"wires":[]},{"id":"9c30a7cc.16ac38","type":"json","z":"b6605d08.a927b","name":"","property":"payload","action":"obj","pretty":true,"x":210,"y":2920,"wires":[["de0b9d41.21bd3","a4fb0e04.52f6b","3ef4e4a1.49fcac","cbbcecc.d9fbc9"]]},{"id":"3ef4e4a1.49fcac","type":"function","z":"b6605d08.a927b","name":"decode hum","func":"var obj = msg.payload;\nvar data = obj.data;\n\n\nvar humidity = data.toString().substr(6, 2);\n// var hum = \"0x\" + humidity; \n\nfunction hexToDec(hex) {\n return hex.toLowerCase().split('').reduce( (result, ch) =>\n result * 16 + '0123456789abcdefgh'.indexOf(ch), 0);\n}\n\nvar value = hexToDec(humidity);\n\n\nvar RH = (((125 * value)/256) -6);\n\nmsg.payload = RH.toFixed(2);\n\n// return msg;\n// msg.payload = obj.data;\nreturn msg;","outputs":1,"noerr":0,"x":430,"y":3040,"wires":[["3dd9c892.32f9b8"]]},{"id":"cbbcecc.d9fbc9","type":"function","z":"b6605d08.a927b","name":"decode batt","func":"var obj = msg.payload;\nvar data = obj.data;\nvar batt = data.toString().substr(16, 2);\n\nfunction hexToDec(hex) {\n return hex.toLowerCase().split('').reduce( (result, ch) =>\n result * 16 + '0123456789abcdefgh'.indexOf(ch), 0);\n}\n\n\n\nmsg.payload = (hexToDec(batt) + 150) * 0.01;\n\n// msg.payload = RH.toFixed(2);\n\n// return msg;\n// msg.payload = obj.data;\nreturn msg;","outputs":1,"noerr":0,"x":430,"y":3100,"wires":[["c70731a.a7ba85"]]},{"id":"3dd9c892.32f9b8","type":"ui_chart","z":"b6605d08.a927b","name":"","group":"44b692c4.bec04c","order":0,"width":0,"height":0,"label":"hum rhf","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":640,"y":3040,"wires":[[],[]]},{"id":"c70731a.a7ba85","type":"ui_chart","z":"b6605d08.a927b","name":"","group":"44b692c4.bec04c","order":0,"width":0,"height":0,"label":"batt rhf","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":640,"y":3100,"wires":[[],[]]},{"id":"db7f0faf.eec008","type":"ui_chart","z":"b6605d08.a927b","name":"","group":"44b692c4.bec04c","order":0,"width":0,"height":0,"label":"temperture rhf","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":660,"y":2980,"wires":[[],[]]},{"id":"ce3645f8.a18d78","type":"mqtt-broker","z":"","name":"loralocal","broker":"00.00.00.00","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"44b692c4.bec04c","type":"ui_group","z":"","name":"RHF","tab":"b031aecd.a463f","order":1,"disp":true,"width":"6","collapse":false},{"id":"b031aecd.a463f","type":"ui_tab","z":"","name":"GATEWAY","icon":"desktop_mac","order":2}]

Datasheet sensor

http://www.risinghf.com/#/product-details?product_id=1&lang=en

Membuat services di Ubuntu


Terkadang kita menginginkan sebuah program supaya bisa jalan otomatis pada saat kita restart atau pada saat system kita jalan, nah cara mudahnya adalah dengan membuat services yang meng-execute program kita tersebut.

Caranya mudah pada kali ini saya contohkan membuat services untuk mengexecute node-red setiap kali system start atau restart di ubuntu.

Pertama tama pastikan node-red sudah terinstall dan saya tidak akan membahasnya disini saya hanya akan membuat servicesnya caranya buat file node-red.service didirectory dibawah ini

sudo nano /etc/systemd/system/node-red.service

Lalu masukkan baris ini didalamnya

[Unit]
Description=Node-RED
After=syslog.target network.target

[Service]
ExecStart=/usr/bin/node-red --max-old-space-size=128 -v
Restart=on-failure
KillSignal=SIGINT

# log output to syslog as 'node-red'
SyslogIdentifier=node-red
StandardOutput=syslog

# non-root user to run as
WorkingDirectory=/home/onix/ #nama username mu
User=onix
Group=onix

[Install]
WantedBy=multi-user.target

Udah gitu aja gampang kan, ini bisa digunakan untuk menjalankan apa saja tinggal ganti ExecStartnya saja.

Untuk menjalankan servicesnya tinggal tuliskan perintah ini di terminal

sudo systemctl start node-red.services #ini kalau nama servicesnya node-red

Untuk melihat statusnya tinggal ganti start dengan status dengan command yang sama

Atau untuk menjadikan aplikasinya jalan pada saat reboot ganti start dengan enable dengan command yang sama.

Selamat Mencoba

Salam Ngoprek …

Happy Coding …

Parsing value json di node-red


Kali ini saya akan share bagaimana caranya parsing data json (dari mqtt) di node-red untuk mengambil valuenya saja yang nantinya data tersebut bebas kita gunakan untuk mentrigger sesuatu atau hanya untuk ditampilkan di ui node-red. Setelah browsing sana sini, tanya sana sini akhirnya entah kenapa tiba tiba malah bisa memparsing data dari mqtt yang bentuknya json, simplenya silahkan copas aja langsung flow node-red dibawah ini

[{"id":"cf8a386d.c705e8","type":"inject","z":"527576f4.5e79c8","name":"","topic":"lora","payload":"{\"temperature\":26,\"humidity\":30}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":900,"wires":[["5979b9b5.eb2a48"]]},{"id":"5979b9b5.eb2a48","type":"json","z":"527576f4.5e79c8","name":"","property":"payload","action":"obj","pretty":true,"x":290,"y":900,"wires":[["28036454.a91e2c","422cfaee.d99884"]]},{"id":"28036454.a91e2c","type":"function","z":"527576f4.5e79c8","name":"data","func":"var obj = msg.payload;\nmsg.payload = obj.temperature;\nreturn msg;","outputs":1,"noerr":0,"x":450,"y":900,"wires":[["b7bc5dc0.c6099"]]},{"id":"422cfaee.d99884","type":"function","z":"527576f4.5e79c8","name":"data","func":"var obj = msg.payload;\nmsg.payload = obj.humidity;\nreturn msg;","outputs":1,"noerr":0,"x":450,"y":960,"wires":[["71392630.791538"]]},{"id":"b7bc5dc0.c6099","type":"debug","z":"527576f4.5e79c8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":650,"y":900,"wires":[]},{"id":"71392630.791538","type":"debug","z":"527576f4.5e79c8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":650,"y":960,"wires":[]}]

Disini saya mencontohkan untuk menginjek data berupa json kalau mau ngambil dari mqtt juga bisa cuman untuk praktisnya saja saya masukkan kedalam inject, datanya simple sebenarnya hanya berupa json seperti dibawah ini

{
"temperature": 26,
"humidity": 30
}

Kemudian data tersebut saya ubah didalam function sehingga nanti value dari temperature dan humiditynya saja yang diambil untuk diolah lebih lanjut. Demikian catatan saya kali ini semoga bermanfaat.

Happy Coding …

Salam Ngoprek …