-
Notifications
You must be signed in to change notification settings - Fork 693
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Dockerfile and docker-compose for development (#281)
* Add Dockerfile and docker-compose for development * Update Docker-Compose files as per .env changes * Replace npm with yarn in Dockerfile * Replace npmrc with yarnrc * Remove yarn installation steps from Dockerfile * Add docker-compose test
- Loading branch information
1 parent
eebfabc
commit 490b285
Showing
10 changed files
with
165 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules | ||
jspm_packages | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional REPL history | ||
.node_repl_history |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
save-prefix false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# take default image of node boron i.e node 6.x | ||
FROM node:6.10.1 | ||
|
||
MAINTAINER Kunal Kapadia <kunalkapadia12@gmail.com> | ||
|
||
# create app directory in container | ||
RUN mkdir -p /app | ||
|
||
# set /app directory as default working directory | ||
WORKDIR /app | ||
|
||
# only copy package.json initially so that `RUN yarn` layer is recreated only | ||
# if there are changes in package.json | ||
ADD package.json yarn.lock /app/ | ||
|
||
# --pure-lockfile: Don’t generate a yarn.lock lockfile | ||
RUN yarn --pure-lockfile | ||
|
||
# copy all file from current dir to /app in container | ||
COPY . /app/ | ||
|
||
# expose port 4040 | ||
EXPOSE 4040 | ||
|
||
# cmd to start service | ||
CMD [ "yarn", "start" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
# --build: Build images before starting containers. | ||
# --abort-on-container-exit: Stops all containers if any container is stopped | ||
docker-compose up --build --abort-on-container-exit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env bash | ||
|
||
# --build: Build images before starting containers. | ||
# --abort-on-container-exit: Stops all containers if any container is stopped | ||
docker-compose -f 'docker-compose.test.yml' -p ci up --build --abort-on-container-exit | ||
exit $(docker wait ci_express-mongoose-es6-rest-api_1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
version: '2' | ||
|
||
services: | ||
express-mongoose-es6-rest-api: | ||
build: | ||
context: . | ||
|
||
image: express-mongoose-es6-rest-api:latest | ||
|
||
volumes: | ||
# Mounts the project directory on the host to /app inside the container, | ||
# allowing you to modify the code without having to rebuild the image. | ||
- .:/app | ||
# Just specify a path and let the Engine create a volume. | ||
# Data present in the base image at the specified mount point will be copied | ||
# over to the new volume upon volume initialization. | ||
# node_modules from this new volume will be used and not from your local dev env. | ||
- /app/node_modules/ | ||
|
||
# Set environment variables from this file | ||
env_file: | ||
- .env | ||
|
||
# Overwrite any env var defined in .env file (if required) | ||
environment: | ||
- MONGO_HOST=mongodb://mongo/express-mongoose-es6-rest-api-test | ||
- DEBUG=express-mongoose-es6-rest-api:* | ||
|
||
# Link to containers in another service. | ||
# Links also express dependency between services in the same way as depends_on, | ||
# so they determine the order of service startup. | ||
links: | ||
- mongo | ||
|
||
command: | ||
- /bin/bash | ||
- -c | ||
- yarn --pure-lockfile && yarn test | ||
mongo: | ||
image: "mongo:3.4.2" | ||
ports: | ||
- "27017:27017" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
version: '2' | ||
|
||
services: | ||
express-mongoose-es6-rest-api: | ||
build: | ||
context: . | ||
volumes: | ||
# Mounts the project directory on the host to /app inside the container, | ||
# allowing you to modify the code without having to rebuild the image. | ||
- .:/app | ||
# Just specify a path and let the Engine create a volume. | ||
# Data present in the base image at the specified mount point will be copied | ||
# over to the new volume upon volume initialization. | ||
# node_modules from this new volume will be used and not from your local dev env. | ||
- /app/node_modules/ | ||
|
||
# Expose ports [HOST:CONTAINER} | ||
ports: | ||
- "4040:4040" | ||
|
||
# Set environment variables from this file | ||
env_file: | ||
- .env | ||
|
||
# Overwrite any env var defined in .env file (if required) | ||
environment: | ||
- MONGO_HOST=mongodb://mongo/express-mongoose-es6-rest-api-development | ||
- DEBUG=express-mongoose-es6-rest-api:* | ||
|
||
# Link to containers in another service. | ||
# Links also express dependency between services in the same way as depends_on, | ||
# so they determine the order of service startup. | ||
links: | ||
- mongo | ||
mongo: | ||
image: "mongo:3.4.2" | ||
ports: | ||
- "27017:27017" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters