Skip to content
This repository has been archived by the owner on May 27, 2021. It is now read-only.

Add Docker Support, closes #68 #69

Open
wants to merge 6 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
32 changes: 32 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Modified Brett Fisher's node-docker-good-defaults https://github.com/BretFisher/node-docker-good-defaults/blob/master/Dockerfile
FROM thegreenhouse/nodejs-dev:0.4.0

# set our node environment, either development or production
# defaults to production, compose overrides this to development on build and run
ARG NODE_ENV=production
ENV NODE_ENV $NODE_ENV

# default to port 8000 for prod, 1981 for dev, and 9876 for testing
ARG PORT=8000
ENV PORT $PORT
EXPOSE $PORT 1981 9876

RUN npm i npm@latest -g

# install dependencies first, in a different location for easier app bind mounting for local development
WORKDIR /opt
COPY package.json package-lock.json* ./
RUN npm install && \
npm install --only=dev && \
npm cache clean --force
ENV PATH /opt/node_modules/.bin:$PATH

WORKDIR /opt/app
COPY . /opt/app
RUN echo "node_modules" > .eslintignore

RUN npm run build

# use `docker run --init in production`
# so that signals are passed properly.
CMD [ "ws" ]
56 changes: 55 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,58 @@ For convenience, Create Evergreen App comes with the dependencies needed to run
- For information on adding more browsers, see [the Karma docs](http://karma-runner.github.io/3.0/config/browsers.html).
- For more information on testing in general, see [our wiki!](https://github.com/ProjectEvergreen/create-evergreen-app/wiki).

> Chrome headless is enabled by default since it is the most portable between local and continuous integration environments.
> Chrome headless is enabled by default since it is the most portable between local and continuous integration environments.

#### Docker

Create Evergreen App comes Docker-ready with a built in Dockerfile

To build and tag a docker image with any image/release name for your app:

```bash
$ docker build -t imagename:releasename .
```

To run the docker image in production:

```bash
$ docker run --init --name mycontainer imagename:releasename
```

**Note** Use the `--init` flag so that the exit signals are passed correctly.

Which should display something like:

```
Serving at http://e899fd0ef42c:8000, http://127.0.0.1:8000, http://172.17.0.2:8000
```

You will need to access your app using the container's IP and port(yours will be different, but it's the third URL shown above).

Otherwise, you can get your container `IPAddress` with:

```
docker inspect mycontainer
```

#### Docker Development

You can run your application's webpack-dev-server within a container by modifiying the webpack.config.develop.js with your container's IP address(yours will be different, see above)

```
host: '172.17.0.2',
```

You can mount and run your application's `src` folder so that your changes are immediately reflected within a running container with:

```
docker run --init --name mycontainer -v "$(pwd)"/src:/opt/app/src imagename:releasename npm run develop
```

#### Docker Testing

To test the docker image:

```bash
$ docker run --init imagename:releasename npm test
```
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
".editorconfig",
".eslintrc",
".gitattributes",
"Dockerfile",
"yarn.lock",
"package-lock.json",
"babel.config.js",
Expand Down