From 8a2eac77f428d2b4918d6814df9a6e73cabb4119 Mon Sep 17 00:00:00 2001 From: Josh Mize Date: Tue, 3 May 2016 03:07:27 -0500 Subject: [PATCH 1/2] Add Dockerfile and Makefile --- Dockerfile | 14 ++++++++++++++ Makefile | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 Dockerfile create mode 100644 Makefile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..4e1ad2729 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM debian:jessie + +ENV PYTHONDONTWRITEBYTECODE=1 + +# need python and build-essential for node-gyp +RUN apt-get update && \ + apt-get install -y --no-install-recommends python2.7 build-essential nodejs npm +RUN update-alternatives --install /usr/bin/node node /usr/bin/nodejs 10 + +WORKDIR /app +COPY . /app +RUN npm install + + diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..bd6d60082 --- /dev/null +++ b/Makefile @@ -0,0 +1,44 @@ +VERSION ?= $(shell git describe --tags --exact-match 2>/dev/null || git rev-parse --short HEAD) +REGISTRY ?= quay.io/ +IMAGE_PREFIX ?= mozmar +IMAGE_NAME ?= kumascript +IMAGE ?= ${REGISTRY}${IMAGE_PREFIX}/${IMAGE_NAME}\:${VERSION} +MOUNT_DIR ?= $(shell pwd) +APP_DIR ?= /app +PORT ?= 9080 +DOCKER_RUN_ARGS ?= -v ${MOUNT_DIR}\:${APP_DIR} -w ${APP_DIR} +DOCKER_PORT_ARGS ?= -p "${PORT}:${PORT}" +DEIS_PROFILE ?= usw +DEIS_APP ?= kumascript-dev +PRIVATE_IMAGE ?= ${PRIVATE_REGISTRY}/${DEIS_APP}\:${VERSION} + + +build: + docker build -t ${IMAGE} . + +push: + docker push ${IMAGE} + +run: + docker run ${DOCKER_RUN_ARGS} ${DOCKER_PORT_ARGS} ${IMAGE} node run.js + +test: + docker run ${DOCKER_RUN_ARGS} ${IMAGE} ./node_modules/.bin/nodeunit tests + +bash: + docker run -it ${DOCKER_RUN_ARGS} ${IMAGE} bash + +deis-pull: + deis pull ${IMAGE} -a ${DEIS_APP} + +push-private-registry: + docker tag ${IMAGE} ${PRIVATE_IMAGE} + docker push ${PRIVATE_IMAGE} + +deis-pull-private: + deis pull ${DEIS_APP}:${VERSION} -a ${DEIS_APP} + +build-deploy: build push deis-pull +build-private-deploy: build push-private-registry deis-pull-private + +.PHONY: build push run test bash deis-pull push-private-registry deis-pull-private build-deploy build-private-deploy From c146eae05858a168b14704a194cff78139d5952c Mon Sep 17 00:00:00 2001 From: Josh Mize Date: Tue, 10 May 2016 14:49:13 -0500 Subject: [PATCH 2/2] Set ENV NODE_PATH=/node_modules and install there --- Dockerfile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4e1ad2729..72b1fc981 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,8 +7,9 @@ RUN apt-get update && \ apt-get install -y --no-install-recommends python2.7 build-essential nodejs npm RUN update-alternatives --install /usr/bin/node node /usr/bin/nodejs 10 -WORKDIR /app -COPY . /app +ENV NODE_PATH=/node_modules +COPY package.json / RUN npm install - +WORKDIR /app +COPY . /app