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

Rework docker build process #2163

Merged
merged 5 commits into from
Jun 22, 2017
Merged
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
1 change: 0 additions & 1 deletion ashes/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ pids
*.pid
*.seed
.git-rev
.npmrc-docker

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
Expand Down
2 changes: 2 additions & 0 deletions ashes/.npmrc-docker
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
//npm.foxcommerce.com:4873/:_authToken=${NPM_TOKEN}
@foxcomm:registry=https://npm.foxcommerce.com:4873/
16 changes: 14 additions & 2 deletions ashes/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
FROM mhart/alpine-node:7.10.0
FROM mhart/alpine-node:8.1.0
Copy link
Contributor

Choose a reason for hiding this comment

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

If we update docker image base version here, can we do it for all our node projects?


ARG NPM_TOKEN
RUN mkdir -p /ashes
WORKDIR /ashes
COPY . /ashes

COPY ./package.json /ashes/package.json
COPY ./yarn.lock /ashes/yarn.lock
COPY ./.npmrc-docker /ashes/.npmrc
COPY ./src/opt /ashes/src/opt
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd suggest using one COPY command for all files to reduce number of layers in the image.


RUN yarn --production --ignore-scripts --ignore-engines && yarn cache clean

# All other src must be copyed AFTER `yarn`, otherwise it breaks caching
COPY ./config /ashes/config
COPY ./server /ashes/server
COPY ./build /ashes/build

CMD NODE_ENV=production node ./server/index.js --optimize_for_size --max_old_space_size=1536 --stack_size=4096 2>&1 | tee /logs/ashes.log
6 changes: 5 additions & 1 deletion ashes/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ version = $(shell iojs -e "console.log(JSON.parse(require('fs').readFileSync('pa
.PHONY: docker
docker: MSG=Dockerizing
docker: notify
docker build -t $(DOCKER_IMAGE) .
docker build -t $(DOCKER_IMAGE) . --build-arg NPM_TOKEN=${NPM_TOKEN}

.PHONY: docker-run
docker-run:
docker run -it -p 4000:4000 ashes:latest

.PHONY: docker-push
docker-push: MSG=Registering
Expand Down
9 changes: 9 additions & 0 deletions ashes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,12 @@ In order to Stripe.js to work (used for creating credit cards in Stripe) you nee
You can set Stripe key by exporting `STRIPE_PUBLISHABLE_KEY` variable, or setting it in your `.env`:

`STRIPE_PUBLISHABLE_KEY=pk_test_r6t0niqmG9OOZhhaSkacUUU1`

## Building docker image

1. Install [Docker CE for Mac](https://store.docker.com/editions/community/docker-ce-desktop-mac)
2. Build your app with `make build`
3. Build docker with `NPM_TOKEN=token make docker` where `token` is your private token from `~/.npmrc`

Thats it! You can run it locally: `docker run -it -p 4000:4000 -image_id-`
Or push it with `make docker-push`.
32 changes: 16 additions & 16 deletions ashes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,28 @@
},
"contributors": "https://github.com/FoxComm/highlander/graphs/contributors",
"homepage": "https://github.com/FoxComm/highlander#readme",
"dependencies": {
"@foxcomm/wings": "^1.9.10",
"dependencies": {
"cli-color": "^1.2.0",
"co": "^4.6.0",
"dotenv": "^4.0.0",
"jsonwebtoken": "^7.4.1",
"koa": "^2.2.0",
"koa-better-static": "^1.0.5",
"koa-body": "^1.2.1",
"koa-convert": "^1.2.0",
"koa-json": "^1.1.1",
"koa-proxy": "^0.8.0",
"lodash": "^4.17.4"
},
"devDependencies": {
"@foxcomm/wings": "^1.9.12",
"chance": "^0.7.6",
"classnames": "^2.2.5",
"cli-color": "^1.0.0",
"co": "^4.5.4",
"co-body": "^4.0.0",
"core-decorators": "^0.8.0",
"crypto-js": "^3.1.9-1",
"currency-symbol-map": "^2.1.0",
"d3": "^3.5.0",
"dotenv": "^4.0.0",
"draft-js": "^0.10.1",
"draft-js-export-html": "^0.2.2",
"draft-js-export-markdown": "^0.2.0",
Expand All @@ -52,13 +62,6 @@
"invariant": "^2.2.1",
"jsen": "^0.6.1",
"jwt-decode": "^2.1.0",
"koa": "^2.2.0",
"koa-better-static": "^1.0.5",
"koa-body": "^1.2.1",
"koa-convert": "^1.2.0",
"koa-json": "^1.1.1",
"koa-proxy": "^0.8.0",
"lodash": "^4.15.0",
"moment": "^2.17.1",
"prop-types": "^15.5.8",
"react": "^15.5.4",
Expand Down Expand Up @@ -86,9 +89,7 @@
"use-named-routes": "^0.3.2",
"victory": "^0.15.0",
"zipcodes-regex": "^1.0.0",
"zxcvbn": "^4.4.2"
},
"devDependencies": {
"zxcvbn": "^4.4.2",
"babel-cli": "^6.18.0",
"babel-core": "^6.24.1",
"babel-eslint": "^7.2.1",
Expand Down Expand Up @@ -126,7 +127,6 @@
"gulp-spawn-mocha": "^2.2.2",
"ignore-styles": "^1.2.0",
"jsdom": "^9.4.1",
"jsonwebtoken": "^5.5.4",
"koa-logger": "^2.0.1",
"less": "^2.7.2",
"less-loader": "^4.0.3",
Expand Down
Loading