{"id":624,"date":"2018-06-19T10:55:01","date_gmt":"2018-06-19T03:55:01","guid":{"rendered":"http:\/\/www.oopsbox.com\/?p=624"},"modified":"2018-06-19T11:01:17","modified_gmt":"2018-06-19T04:01:17","slug":"%e0%b8%aa%e0%b8%a3%e0%b9%89%e0%b8%b2%e0%b8%87-docker-container-%e0%b8%aa%e0%b8%b3%e0%b8%ab%e0%b8%a3%e0%b8%b1%e0%b8%9a%e0%b8%97%e0%b8%b3-rest-api-%e0%b8%81%e0%b8%b1%e0%b8%99-full-fake-data","status":"publish","type":"post","link":"https:\/\/www.oopsbox.com\/?p=624","title":{"rendered":"\u0e2a\u0e23\u0e49\u0e32\u0e07 docker container \u0e2a\u0e33\u0e2b\u0e23\u0e31\u0e1a\u0e17\u0e33 REST API \u0e01\u0e31\u0e19 &#8211; Full fake data"},"content":{"rendered":"<p>\u0e43\u0e19\u0e27\u0e31\u0e19\u0e17\u0e35\u0e48\u0e15\u0e49\u0e2d\u0e07 Mock API \u0e41\u0e1a\u0e1a\u0e14\u0e48\u0e27\u0e19 \u0e46 \u0e2a\u0e33\u0e2b\u0e23\u0e31\u0e1a\u0e17\u0e14\u0e2a\u0e2d\u0e1a Front-end (\u0e41\u0e15\u0e48 Back-end \u0e08\u0e23\u0e34\u0e07 \u0e46 \u0e21\u0e31\u0e19\u0e22\u0e31\u0e07\u0e2d\u0e22\u0e39\u0e48\u0e41\u0e04\u0e48\u0e43\u0e19\u0e23\u0e48\u0e32\u0e07\u0e2d\u0e2d\u0e01\u0e41\u0e1a\u0e1a) \u0e07\u0e31\u0e49\u0e19\u0e01\u0e47\u0e40\u0e23\u0e34\u0e48\u0e21\u0e01\u0e31\u0e19\u0e40\u0e25\u0e22<\/p>\n<p>\u0e40\u0e23\u0e32\u0e43\u0e0a\u0e49 <a href=\"https:\/\/github.com\/typicode\/json-server\">json-server<\/a> \u0e40\u0e1b\u0e47\u0e19\u0e15\u0e31\u0e27\u0e0a\u0e48\u0e27\u0e22\u0e17\u0e33 Mock API \u0e0b\u0e36\u0e48\u0e07\u0e01\u0e47\u0e15\u0e2d\u0e1a\u0e42\u0e08\u0e17\u0e22\u0e4c\u0e41\u0e25\u0e30\u0e40\u0e23\u0e47\u0e27\u0e2a\u0e38\u0e14\u0e25\u0e30 \u0e2a\u0e34\u0e48\u0e07\u0e17\u0e35\u0e48\u0e40\u0e23\u0e32\u0e15\u0e49\u0e2d\u0e07\u0e17\u0e33\u0e40\u0e1e\u0e34\u0e48\u0e21\u0e04\u0e37\u0e2d\u0e2a\u0e23\u0e49\u0e32\u0e07\u0e0a\u0e38\u0e14\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e2a\u0e33\u0e2b\u0e23\u0e31\u0e1a\u0e17\u0e14\u0e2a\u0e2d\u0e1a\u0e40\u0e17\u0e48\u0e32\u0e19\u0e31\u0e49\u0e19\u0e40\u0e2d\u0e07<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">npm install -g json-server<\/pre>\n<p>\u0e2a\u0e48\u0e27\u0e19\u0e01\u0e32\u0e23\u0e2a\u0e23\u0e49\u0e32\u0e07\u0e0a\u0e38\u0e14\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e01\u0e47\u0e43\u0e0a\u0e49 <a href=\"https:\/\/github.com\/marak\/Faker.js\/\">faker.js<\/a> (\u0e40\u0e23\u0e32\u0e43\u0e0a\u0e49 <a href=\"https:\/\/lodash.com\/\">lodash<\/a> \u0e40\u0e1e\u0e34\u0e48\u0e21 \u0e01\u0e47\u0e15\u0e34\u0e14\u0e15\u0e31\u0e49\u0e07\u0e40\u0e02\u0e49\u0e32\u0e44\u0e1b\u0e1e\u0e23\u0e49\u0e2d\u0e21\u0e01\u0e31\u0e19\u0e40\u0e25\u0e22)<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">npm install faker lodash<\/pre>\n<p>\u0e2a\u0e23\u0e49\u0e32\u0e07\u0e0a\u0e38\u0e14\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e41\u0e1a\u0e1a random \u0e14\u0e49\u0e27\u0e22\u0e44\u0e1f\u0e25\u0e4c\u0e0a\u0e37\u0e48\u0e2d generator.js \u0e40\u0e02\u0e49\u0e32\u0e44\u0e1b<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\">\/\/ generator.js\r\nmodule.exports = function () {\r\n    var faker = require(\"faker\");\r\n    var _ = require(\"lodash\");\r\n    return {\r\n        customers: _.times(Math.floor((Math.random() * 1000) + 1), function (n) {\r\n            return {\r\n                id: n+1,\r\n                firstname: faker.name.firstName(),\r\n                lastname: faker.name.lastName(),\r\n                birthdate: faker.date.past(50, new Date(\"Sat Sep 20 1992 21:35:02 GMT+0700 (ICT)\")),\r\n                address: faker.address.streetAddress(),\r\n                city: faker.address.city(),\r\n                country: faker.address.country(),\r\n                email: faker.internet.email(),\r\n                avatar: faker.internet.avatar()\r\n            }\r\n        })\r\n    }\r\n}<\/pre>\n<p>\u0e2b\u0e25\u0e31\u0e07\u0e08\u0e32\u0e01\u0e17\u0e35\u0e48\u0e40\u0e23\u0e32 Start Server \u0e14\u0e49\u0e27\u0e22\u0e04\u0e33\u0e2a\u0e31\u0e48\u0e07\u00a0<code class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">json-server generator.js\u00a0<\/code>\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e17\u0e35\u0e48\u0e40\u0e23\u0e32 generate \u0e02\u0e36\u0e49\u0e19\u0e2b\u0e19\u0e49\u0e32\u0e15\u0e32\u0e01\u0e47\u0e1b\u0e23\u0e30\u0e21\u0e32\u0e13\u0e19\u0e35\u0e49<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-626\" src=\"https:\/\/www.oopsbox.com\/wp-content\/uploads\/Screenshot-20180619103851-619x459.png\" alt=\"\" width=\"619\" height=\"459\" srcset=\"https:\/\/www.oopsbox.com\/wp-content\/uploads\/Screenshot-20180619103851-619x459.png 619w, https:\/\/www.oopsbox.com\/wp-content\/uploads\/Screenshot-20180619103851-619x459-300x222.png 300w\" sizes=\"auto, (max-width: 619px) 100vw, 619px\" \/><\/p>\n<p>\u0e17\u0e49\u0e32\u0e22\u0e2a\u0e38\u0e14\u0e40\u0e23\u0e32\u0e01\u0e47\u0e41\u0e1e\u0e47\u0e04\u0e25\u0e07 Container \u0e40\u0e25\u0e22 \u0e42\u0e14\u0e22\u0e2a\u0e23\u0e49\u0e32\u0e07 Dockerfile \u0e44\u0e27\u0e49\u0e43\u0e0a\u0e49\u0e07\u0e32\u0e19\u0e22\u0e32\u0e27 \u0e46\u00a0 (\u0e40\u0e1b\u0e47\u0e19\u0e25\u0e32\u0e07\u0e27\u0e48\u0e32 Back-end \u0e08\u0e30\u0e22\u0e31\u0e07\u0e44\u0e21\u0e48\u0e40\u0e2a\u0e23\u0e47\u0e08\u0e43\u0e19\u0e40\u0e23\u0e47\u0e27\u0e27\u0e31\u0e19\u0e43\u0e0a\u0e48\u0e44\u0e2b\u0e21 55555)<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">FROM node:10-alpine\r\n\r\nLABEL author=\"mf\"\r\nLABEL version=\"latest\"\r\n\r\nENV NPM_CONFIG_LOGLEVEL info\r\nENV TZ Asia\/Bangkok\r\n\r\nRUN apk add --no-cache tzdata \\\r\n    &amp;&amp; cp \/usr\/share\/zoneinfo\/Asia\/Bangkok \/etc\/localtime \\\r\n    &amp;&amp; echo \"Asia\/Bangkok\" &gt;  \/etc\/timezone \\\r\n    &amp;&amp; rm -rf \/var\/cache\/apk\/*\r\n\r\n# Create application directory\r\nRUN mkdir -p \/data \\\r\n    &amp;&amp; npm install -g json-server lodash faker\r\nWORKDIR \/data\r\n\r\nVOLUME [ \"\/data\" ]\r\nEXPOSE 3000\r\n\r\n# Default command\r\nENTRYPOINT [\"json-server\"]\r\nCMD [\"--help\"]<\/pre>\n<p>\u0e2b\u0e25\u0e31\u0e07\u0e08\u0e32\u0e01 build Dockerfile \u0e41\u0e25\u0e49\u0e27\u0e01\u0e47\u0e25\u0e2d\u0e07\u0e23\u0e31\u0e19\u0e01\u0e31\u0e19\u0e40\u0e25\u0e22 \u0e16\u0e49\u0e32\u0e44\u0e21\u0e48\u0e17\u0e33\u0e2d\u0e30\u0e44\u0e23\u0e1c\u0e34\u0e14\u0e1e\u0e25\u0e32\u0e14\u0e1c\u0e25\u0e25\u0e31\u0e1e\u0e18\u0e4c\u0e21\u0e31\u0e19\u0e01\u0e47\u0e04\u0e27\u0e23\u0e08\u0e30\u0e40\u0e1b\u0e47\u0e19\u0e14\u0e31\u0e07\u0e23\u0e39\u0e1b<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">docker run -d -p 3000:3000 -v `pwd`\/app:\/data mf\/mockup-api --watch generator.js --host 0.0.0.0<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-627\" src=\"https:\/\/www.oopsbox.com\/wp-content\/uploads\/Screenshot-20180619105052-968x690.png\" alt=\"\" width=\"968\" height=\"690\" srcset=\"https:\/\/www.oopsbox.com\/wp-content\/uploads\/Screenshot-20180619105052-968x690.png 968w, https:\/\/www.oopsbox.com\/wp-content\/uploads\/Screenshot-20180619105052-968x690-300x214.png 300w, https:\/\/www.oopsbox.com\/wp-content\/uploads\/Screenshot-20180619105052-968x690-768x547.png 768w, https:\/\/www.oopsbox.com\/wp-content\/uploads\/Screenshot-20180619105052-968x690-700x499.png 700w\" sizes=\"auto, (max-width: 968px) 100vw, 968px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-632\" src=\"https:\/\/www.oopsbox.com\/wp-content\/uploads\/Screenshot-20180619110033-996x715.png\" alt=\"\" width=\"996\" height=\"715\" srcset=\"https:\/\/www.oopsbox.com\/wp-content\/uploads\/Screenshot-20180619110033-996x715.png 996w, https:\/\/www.oopsbox.com\/wp-content\/uploads\/Screenshot-20180619110033-996x715-300x215.png 300w, https:\/\/www.oopsbox.com\/wp-content\/uploads\/Screenshot-20180619110033-996x715-768x551.png 768w, https:\/\/www.oopsbox.com\/wp-content\/uploads\/Screenshot-20180619110033-996x715-700x503.png 700w\" sizes=\"auto, (max-width: 996px) 100vw, 996px\" \/><\/p>\n<p>\u0e08\u0e1a\u0e1b\u0e34\u0e4a\u0e07\u0e07 ^_^<\/p>\n<div id=\"s-share-buttons\" class=\"\"><div class=\"s-single-share\">\n\t\t\t\t\t\t\t\t\t\t\t\t<div class=\"fb-share-button\" data-href=\"https:\/\/www.oopsbox.com\/?p=624\" data-type=\"button_count\"><\/div><\/div><div class=\"s-single-share\"><a href=\"https:\/\/twitter.com\/share\" class=\"twitter-share-button\"><\/a>\n\t\t\t\t\t\t\t\t\t\t\t\t<\/div><div class=\"s-single-share\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t<div class=\"g-plusone\" data-size=\"medium\"><\/div>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div><div class=\"s-single-share\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t<a href=\"\/\/www.pinterest.com\/pin\/create\/button\/\" data-pin-do=\"buttonBookmark\"  data-pin-color=\"red\"><img decoding=\"async\" src=\"\/\/assets.pinterest.com\/images\/pidgets\/pinit_fg_en_rect_red_20.png\" \/><\/a>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<script type=\"text\/javascript\" async defer src=\"\/\/assets.pinterest.com\/js\/pinit.js\"><\/script>\n\t\t\t\t\t\t\t\t\t\t\t\t<\/div><div class=\"s-single-share\">\n\t\t\t\t\t\t\t\t\t\t\t\t<a href=\"mailto:?Subject=\u0e2a\u0e23\u0e49\u0e32\u0e07%20docker%20container%20\u0e2a\u0e33\u0e2b\u0e23\u0e31\u0e1a\u0e17\u0e33%20REST%20API%20\u0e01\u0e31\u0e19%20&#8211;%20Full%20fake%20data&Body=Here%20is%20the%20link%20to%20the%20article:%20https:\/\/www.oopsbox.com\/?p=624\" title=\"Email\" class=\"s3-email\"><img decoding=\"async\" src=\"https:\/\/www.oopsbox.com\/wp-content\/plugins\/simple-social-share\/includes\/..\/images\/share-email.png\"><\/a>\n\t\t\t\t\t\t\t\t\t\t\t<\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>\u0e43\u0e19\u0e27\u0e31\u0e19\u0e17\u0e35\u0e48\u0e15\u0e49\u0e2d\u0e07 Mock API \u0e41\u0e1a\u0e1a\u0e14\u0e48\u0e27\u0e19 \u0e46 \u0e2a\u0e33\u0e2b\u0e23\u0e31\u0e1a\u0e17\u0e14\u0e2a\u0e2d\u0e1a Front-end (\u0e41\u0e15\u0e48 Back-end \u0e08\u0e23\u0e34\u0e07 \u0e46 \u0e21\u0e31\u0e19\u0e22\u0e31\u0e07\u0e2d\u0e22\u0e39\u0e48\u0e41\u0e04\u0e48\u0e43\u0e19\u0e23\u0e48\u0e32\u0e07\u0e2d\u0e2d\u0e01\u0e41\u0e1a\u0e1a) \u0e07\u0e31\u0e49\u0e19\u0e01\u0e47\u0e40\u0e23\u0e34\u0e48\u0e21\u0e01\u0e31\u0e19\u0e40\u0e25\u0e22 \u0e40\u0e23\u0e32\u0e43\u0e0a\u0e49 json-server \u0e40\u0e1b\u0e47\u0e19\u0e15\u0e31\u0e27\u0e0a\u0e48\u0e27\u0e22\u0e17\u0e33 Mock API \u0e0b\u0e36\u0e48\u0e07\u0e01\u0e47\u0e15\u0e2d\u0e1a\u0e42\u0e08\u0e17\u0e22\u0e4c\u0e41\u0e25\u0e30\u0e40\u0e23\u0e47\u0e27\u0e2a\u0e38\u0e14\u0e25\u0e30 \u0e2a\u0e34\u0e48\u0e07\u0e17\u0e35\u0e48\u0e40\u0e23\u0e32\u0e15\u0e49\u0e2d\u0e07\u0e17\u0e33\u0e40\u0e1e\u0e34\u0e48\u0e21\u0e04\u0e37\u0e2d\u0e2a\u0e23\u0e49\u0e32\u0e07\u0e0a\u0e38\u0e14\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e2a\u0e33\u0e2b\u0e23\u0e31\u0e1a\u0e17\u0e14\u0e2a\u0e2d\u0e1a\u0e40\u0e17\u0e48\u0e32\u0e19\u0e31\u0e49\u0e19\u0e40\u0e2d\u0e07 npm install -g json-server \u0e2a\u0e48\u0e27\u0e19\u0e01\u0e32\u0e23\u0e2a\u0e23\u0e49\u0e32\u0e07\u0e0a\u0e38\u0e14\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e01\u0e47\u0e43\u0e0a\u0e49 faker.js (\u0e40\u0e23\u0e32\u0e43\u0e0a\u0e49 lodash \u0e40\u0e1e\u0e34\u0e48\u0e21 \u0e01\u0e47\u0e15\u0e34\u0e14\u0e15\u0e31\u0e49\u0e07\u0e40\u0e02\u0e49\u0e32\u0e44\u0e1b\u0e1e\u0e23\u0e49\u0e2d\u0e21\u0e01\u0e31\u0e19\u0e40\u0e25\u0e22) npm install faker lodash \u0e2a\u0e23\u0e49\u0e32\u0e07\u0e0a\u0e38\u0e14\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e41\u0e1a\u0e1a random \u0e14\u0e49\u0e27\u0e22\u0e44\u0e1f\u0e25\u0e4c\u0e0a\u0e37\u0e48\u0e2d generator.js \u0e40\u0e02\u0e49\u0e32\u0e44\u0e1b \/\/ generator.js module.exports = function () { var faker = require(&#8220;faker&#8221;); var _ = require(&#8220;lodash&#8221;); return &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.oopsbox.com\/?p=624\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;\u0e2a\u0e23\u0e49\u0e32\u0e07 docker container \u0e2a\u0e33\u0e2b\u0e23\u0e31\u0e1a\u0e17\u0e33 REST API \u0e01\u0e31\u0e19 &#8211; Full fake data&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":628,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[6],"tags":[47,67,66],"class_list":["post-624","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-lab","tag-docker","tag-json-server","tag-rest-api","entry"],"views":4157,"_links":{"self":[{"href":"https:\/\/www.oopsbox.com\/index.php?rest_route=\/wp\/v2\/posts\/624","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.oopsbox.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.oopsbox.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.oopsbox.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.oopsbox.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=624"}],"version-history":[{"count":4,"href":"https:\/\/www.oopsbox.com\/index.php?rest_route=\/wp\/v2\/posts\/624\/revisions"}],"predecessor-version":[{"id":633,"href":"https:\/\/www.oopsbox.com\/index.php?rest_route=\/wp\/v2\/posts\/624\/revisions\/633"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.oopsbox.com\/index.php?rest_route=\/wp\/v2\/media\/628"}],"wp:attachment":[{"href":"https:\/\/www.oopsbox.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=624"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.oopsbox.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=624"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.oopsbox.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=624"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}