From 981a8399ad339a45b02a54d2419f50b53008cd0a Mon Sep 17 00:00:00 2001 From: Sambo Chea Date: Mon, 29 Mar 2021 15:01:53 +0700 Subject: [PATCH] Add examples for nodejs and image --- .gitignore | 0 examples/README.md | 2 ++ examples/sayhello/.gitignore | 3 +++ examples/sayhello/Dockerfile | 10 ++++++++++ examples/sayhello/Makefile | 11 +++++++++++ examples/sayhello/index.js | 7 +++++++ examples/sayhello/package.json | 11 +++++++++++ 7 files changed, 44 insertions(+) create mode 100644 .gitignore create mode 100644 examples/README.md create mode 100644 examples/sayhello/.gitignore create mode 100644 examples/sayhello/Dockerfile create mode 100644 examples/sayhello/Makefile create mode 100644 examples/sayhello/index.js create mode 100644 examples/sayhello/package.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/examples/README.md b/examples/README.md new file mode 100644 index 0000000..b0b7c0e --- /dev/null +++ b/examples/README.md @@ -0,0 +1,2 @@ +# Examples +- Say Hello to Docker with Nodejs \ No newline at end of file diff --git a/examples/sayhello/.gitignore b/examples/sayhello/.gitignore new file mode 100644 index 0000000..5b07f03 --- /dev/null +++ b/examples/sayhello/.gitignore @@ -0,0 +1,3 @@ +node_modules/ +yarn.lock +package-lock.json \ No newline at end of file diff --git a/examples/sayhello/Dockerfile b/examples/sayhello/Dockerfile new file mode 100644 index 0000000..4018434 --- /dev/null +++ b/examples/sayhello/Dockerfile @@ -0,0 +1,10 @@ +FROM cubetiq/calpine-node:latest +LABEL maintainer="sombochea@cubetiqs.com" + +WORKDIR /usr/src/app + +COPY . /usr/src/app + +RUN yarn + +CMD [ "node" , "index.js"] \ No newline at end of file diff --git a/examples/sayhello/Makefile b/examples/sayhello/Makefile new file mode 100644 index 0000000..b18a979 --- /dev/null +++ b/examples/sayhello/Makefile @@ -0,0 +1,11 @@ +DOCKER_IMAGE=cubetiq/node-sayHello + +build: + @echo "Building docker image..." + docker build . -t ${DOCKER_IMAGE} + +run: + @echo "Running container..." + docker run --rm -t ${DOCKER_IMAGE} + +.PHONY: build run \ No newline at end of file diff --git a/examples/sayhello/index.js b/examples/sayhello/index.js new file mode 100644 index 0000000..97713b1 --- /dev/null +++ b/examples/sayhello/index.js @@ -0,0 +1,7 @@ +const sayHello = () => { + console.log("sayHello => ", "Hi, I'm from CUBETIQ Solution!"); + + return Math.random(); +} + +console.log(sayHello()) \ No newline at end of file diff --git a/examples/sayhello/package.json b/examples/sayhello/package.json new file mode 100644 index 0000000..207dada --- /dev/null +++ b/examples/sayhello/package.json @@ -0,0 +1,11 @@ +{ + "name": "sayhello", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "Sambo Chea ", + "license": "MIT" +}