Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker support #73

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
node_modules
npm-debug.log
Dockerfile*
docker-compose*
.dockerignore
.git
.gitignore
README.md
LICENSE
.vscode
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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 ./
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the yarn lock file in this step as well to improve build caching

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah the repo doesn’t lock down the transitive dependencies.

Maybe @Bogdan-Lyashenko can explain his reasoning behind it

RUN yarn install

# Bundle app source
COPY . .

EXPOSE 2018 3018 8888 9229
CMD ["yarn", "start"]
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,26 @@ Check out the example of [**standalone version running here**](https://codecrumb
<img src="/docs/main-ui-3.png" width="100%"/>

## 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*

1) Install ```codecrumbs``` globally (```yarn global add codecrumbs```)
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))

Expand Down
18 changes: 18 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion src/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down