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..7f55a4a0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM node:12-alpine + +# Create app directory +COPY . /usr/src/app +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 ab7d580e..fda2d2a6 100644 --- a/README.md +++ b/README.md @@ -33,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* @@ -40,6 +45,14 @@ 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 +`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 + ### Configuration Run codecrumbs with CLI params or specify static config file `codecrumbs.config.js` (see example [here](/example-project/codecrumbs.config.js)) diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..a2ea32af --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,18 @@ +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 + environment: + - APP_ENTRYPOINT_PATH + - APP_DIRECTORY="${APP_DIRECTORY:-src/}" + - NODE_ENV=development + ports: + - 2018:2018 + - 3018:3018 + - 9229:9229 + - 8888:8888 diff --git a/src/server/index.js b/src/server/index.js index d33758da..a24bf8cb 100644 --- a/src/server/index.js +++ b/src/server/index.js @@ -28,7 +28,7 @@ const setup = (options, devOptions) => { logger.info(`> started with options: ${JSON.stringify(options)}`); const PORT_IN_USE = 'open'; - const HOST = '127.0.0.1'; + const HOST = '0.0.0.0'; validateProjectPath(projectDir, entryPoint);