From ae84b7b062e1c85972eb89c520b4421893b8cbda Mon Sep 17 00:00:00 2001 From: Ivan Verevkin Date: Thu, 18 Jul 2019 11:33:48 +0200 Subject: [PATCH 1/5] feat: added basic Docker --- .dockerignore | 10 ++++++++++ Dockerfile | 14 ++++++++++++++ README.md | 8 ++++++++ docker-compose.yml | 14 ++++++++++++++ src/server/index.js | 2 +- 5 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..6b386486 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,10 @@ +node_modules +npm-debug.log +Dockerfile* +docker-compose* +.dockerignore +.git +.gitignore +README.md +LICENSE +.vscode diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..b3bbd09a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM node:10-alpine + +# Create app directory +WORKDIR /usr/src/app + +# Install app dependencies +COPY package*.json ./ +RUN yarn install + +# Bundle app source +COPY . . + +EXPOSE 2018 3018 8888 9229 +CMD [ "yarn", "start" ] diff --git a/README.md b/README.md index 7a4da67f..6b0eb0a4 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,8 @@ Case studies + Docker + Support @@ -137,6 +139,12 @@ The tool (codecrumbs) allows us to learn, document and explain a codebase much f The ultimate goal is to have many case studies hosting at [https://codecrumbs.io](https://codecrumbs.io/). **The library of projects "explained with codecrumbs", the place for collaborative learning**. More features around that coming soon, stay tuned. +## Docker +To start dockerise application run +`docker build -t codecrumbs .` +and once docker image will be build successfully +`docker run -p 2018:2018 -d codecrumbs` + ## Support Any support is very much appreciated! 馃憤 馃槝 鉂わ笍 If you like this project, please, **put a :star: and tweet about it**. Thanks! diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..f6ec1303 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,14 @@ +version: '3' + +services: + codecrumbs: + build: . + volumes: + - .:/usr/src/app + - /usr/src/app/node_modules + ports: + - 2018:2018 + - 3018:3018 + - 9229:9229 + - 8888:8888 + command: yarn start diff --git a/src/server/index.js b/src/server/index.js index 1930d535..40a67745 100644 --- a/src/server/index.js +++ b/src/server/index.js @@ -25,7 +25,7 @@ const setup = (options, devOptions) => { } = options; const PORT_IN_USE = 'open'; - const HOST = '127.0.0.1'; + const HOST = '0.0.0.0'; validateProjectPath(projectDir, entryPoint); From bcdca219b30ef2a4bc930e42704141fc8ff6cf9e Mon Sep 17 00:00:00 2001 From: Ivan Verevkin Date: Fri, 19 Jul 2019 10:42:33 +0200 Subject: [PATCH 2/5] feat: added basic Docker --- README.md | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 6b0eb0a4..09e79813 100644 --- a/README.md +++ b/README.md @@ -15,8 +15,6 @@ Case studies - Docker - Support @@ -35,6 +33,11 @@ Check out the example of [**standalone version running here**](https://codecrumb ## Get started + +So basically you have 2 ways: +- Install and run +- Run with Docker + ### Install and run >Pre-condition: update/install `NodeJS` version to be >= *8.11.1* @@ -42,6 +45,12 @@ Check out the example of [**standalone version running here**](https://codecrumb 2) Run ```codecrumbs -d project-src-dir -e project-src-dir/index.js```. Change parameters to match your project:```-d``` is *directory with source code*, ```-e``` is *entry point file* . 3) Go to [http://localhost:2018](http://localhost:2018/#) in the browser to check it out. +### Docker +To start dockerise application run +`docker build -t codecrumbs .` +and once docker image will be build successfully +`docker run -p 2018:2018 -d codecrumbs` + ### CLI Parameter | Description | Example --- | --- | --- @@ -139,12 +148,6 @@ The tool (codecrumbs) allows us to learn, document and explain a codebase much f The ultimate goal is to have many case studies hosting at [https://codecrumbs.io](https://codecrumbs.io/). **The library of projects "explained with codecrumbs", the place for collaborative learning**. More features around that coming soon, stay tuned. -## Docker -To start dockerise application run -`docker build -t codecrumbs .` -and once docker image will be build successfully -`docker run -p 2018:2018 -d codecrumbs` - ## Support Any support is very much appreciated! 馃憤 馃槝 鉂わ笍 If you like this project, please, **put a :star: and tweet about it**. Thanks! From 552bb348c47103db3366adb93c3c5640468d4f1b Mon Sep 17 00:00:00 2001 From: Ivan Verevkin Date: Mon, 22 Jul 2019 16:02:31 +0200 Subject: [PATCH 3/5] feat: added basic Docker --- Dockerfile | 9 ++++++--- README.md | 3 ++- docker-compose.yml | 4 +++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index b3bbd09a..33439f14 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,9 @@ -FROM node:10-alpine +FROM node:12-alpine # Create app directory -WORKDIR /usr/src/app +# WORKDIR /usr/src/app +COPY . /app +WORKDIR /app # Install app dependencies COPY package*.json ./ @@ -11,4 +13,5 @@ RUN yarn install COPY . . EXPOSE 2018 3018 8888 9229 -CMD [ "yarn", "start" ] +ENTRYPOINT [ "node", "cli/index.cli.js" ] +CMD ["codecrumbs"] diff --git a/README.md b/README.md index 09e79813..cb8b877e 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,8 @@ So basically you have 2 ways: To start dockerise application run `docker build -t codecrumbs .` and once docker image will be build successfully -`docker run -p 2018:2018 -d codecrumbs` +`TARGET_APP_PATH=$PWD docker-compose run codecrumbs -d target/ -e target/index.dev.js` +where `TARGET_APP_PATH` is path to project source code directory ### CLI Parameter | Description | Example diff --git a/docker-compose.yml b/docker-compose.yml index f6ec1303..0c01c8db 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,9 +6,11 @@ services: volumes: - .:/usr/src/app - /usr/src/app/node_modules + - $TARGET_APP_PATH/src:/app/target + environment: + - TARGET_APP_PATH ports: - 2018:2018 - 3018:3018 - 9229:9229 - 8888:8888 - command: yarn start From 07ed2b76a2e0254323c0924529a4d4844e47682a Mon Sep 17 00:00:00 2001 From: Ivan Verevkin Date: Tue, 3 Sep 2019 11:39:16 +0200 Subject: [PATCH 4/5] feat: added basic Docker --- README.md | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/README.md b/README.md index 45a01745..fda2d2a6 100644 --- a/README.md +++ b/README.md @@ -53,16 +53,6 @@ and once docker image will be build successfully `TARGET_APP_PATH=$PWD docker-compose run codecrumbs -d target/ -e target/index.dev.js` where `TARGET_APP_PATH` is path to project source code directory -### CLI -Parameter | Description | Example ---- | --- | --- -```-d```, ```--dir``` | Relative path to project source code directory | ```-d src``` -```-e```, ```--entry``` | Relative path to project source entry point file (must be inside ```dir```) | ```-e src/app.js``` -```-x```, ```--excludeDir``` | Relative path(or paths separated by ```,```) to directories for exclusion | ```-x src/doc,src/thirdparty``` -```-i```, ```--ideCmd``` | command to open file in IDE from bash (default 'webstorm') | ```-i code``` -```-p```, ```--port``` | Port for Codecrumbs client (optional, default *2018*) | ```-p 2019``` -```-n```, ```--projectName``` | Project name alias (optional, default same as ```-d``` value) | ```-n my-hello-world``` - ### Configuration Run codecrumbs with CLI params or specify static config file `codecrumbs.config.js` (see example [here](/example-project/codecrumbs.config.js)) From 2505b7bc4c20e65b1bb7c13f4b6fdbeb25ee84e4 Mon Sep 17 00:00:00 2001 From: Ivan Verevkin Date: Thu, 5 Sep 2019 15:53:55 +0200 Subject: [PATCH 5/5] feat: added basic Docker --- Dockerfile | 8 +++----- docker-compose.yml | 6 ++++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 33439f14..7f55a4a0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,8 @@ FROM node:12-alpine # Create app directory -# WORKDIR /usr/src/app -COPY . /app -WORKDIR /app +COPY . /usr/src/app +WORKDIR /usr/src/app # Install app dependencies COPY package*.json ./ @@ -13,5 +12,4 @@ RUN yarn install COPY . . EXPOSE 2018 3018 8888 9229 -ENTRYPOINT [ "node", "cli/index.cli.js" ] -CMD ["codecrumbs"] +CMD ["yarn", "start"] diff --git a/docker-compose.yml b/docker-compose.yml index 0c01c8db..a2ea32af 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,12 +3,14 @@ version: '3' services: codecrumbs: build: . + command: [yarn, start, codecrumbs, -D, -d, $APP_DIRECTORY/, -e, $APP_DIRECTORY/$APP_ENTRYPOINT_PATH] volumes: - .:/usr/src/app - /usr/src/app/node_modules - - $TARGET_APP_PATH/src:/app/target environment: - - TARGET_APP_PATH + - APP_ENTRYPOINT_PATH + - APP_DIRECTORY="${APP_DIRECTORY:-src/}" + - NODE_ENV=development ports: - 2018:2018 - 3018:3018