From e80e2fe3a7bfdaee0e078ab40cc7037f2b1d8973 Mon Sep 17 00:00:00 2001 From: kaiomagalhaes Date: Thu, 11 Feb 2016 22:32:35 -0200 Subject: [PATCH 1/3] add dockerfile with the last versions of node and npm --- Dockerfile.development | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Dockerfile.development diff --git a/Dockerfile.development b/Dockerfile.development new file mode 100644 index 0000000..2bf04bb --- /dev/null +++ b/Dockerfile.development @@ -0,0 +1,36 @@ +FROM buildpack-deps:wheezy + +# Mount any shared volumes from host to container @ /share +VOLUME ["/share"] +WORKDIR /share + +# gpg keys listed at https://github.com/nodejs/node +RUN set -ex \ + && for key in \ + 9554F04D7259F04124DE6B476D5A82AC7E37093B \ + 94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \ + 0034A06D9D9B0064CE8ADF6BF1747F4AD2306D93 \ + FD3A5288F042B6850C66B31F09FE44734EB7990E \ + 71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \ + DD8F2338BAE7501E3DD5AC78C273792F7D83545D \ + B9AE9905FFD7803F25714661B63B535A4C206CA9 \ + C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \ + ; do \ + gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \ + done + +ENV NPM_CONFIG_LOGLEVEL info +ENV NODE_VERSION 5.5.0 + +RUN curl -SLO "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.gz" \ + && curl -SLO "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \ + && gpg --verify SHASUMS256.txt.asc \ + && grep " node-v$NODE_VERSION-linux-x64.tar.gz\$" SHASUMS256.txt.asc | sha256sum -c - \ + && tar -xzf "node-v$NODE_VERSION-linux-x64.tar.gz" -C /usr/local --strip-components=1 \ + && rm "node-v$NODE_VERSION-linux-x64.tar.gz" SHASUMS256.txt.asc + +ADD package.json /share/package.json +RUN npm install + +CMD [ "node" ] +EXPOSE 3000 From 5261e1fcaaaae3662d2664fb358b885a3bfa325f Mon Sep 17 00:00:00 2001 From: kaiomagalhaes Date: Thu, 11 Feb 2016 22:33:30 -0200 Subject: [PATCH 2/3] add dev file to make easier to run the Dockerfile --- bin/dev | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100755 bin/dev diff --git a/bin/dev b/bin/dev new file mode 100755 index 0000000..cb5a184 --- /dev/null +++ b/bin/dev @@ -0,0 +1,63 @@ +#!/bin/bash +#MAINTAINER Kaio Magalhães. + +####### Project configuration example ####### +PROJECT_NAME=react-starterify +PROJECT_MAIN_LANGUAGE=javascript +############################################# + +UPPERCASE_PROJECT_NAME=$(echo $PROJECT_NAME | tr '[a-z]' '[A-Z]') +ATTACH_ON_CONTAINER=$PROJECT_MAIN_LANGUAGE +PROJECT_CONTAINER_NAME=$PROJECT_NAME-$PROJECT_MAIN_LANGUAGE + +attach_to_project_container(){ + echo 'attaching to project container' + echo 'Press or ' + docker attach $PROJECT_CONTAINER_NAME +} + +start_container(){ + for action in "stop" "start" + do + docker $action $1 + done +} + +container_exists() { + container=$(docker ps -a | grep $1) + if [ -z "$container" ]; then + echo false + else + echo true + fi +} + +run_project_container(){ + docker_id=$PROJECT_CONTAINER_NAME + + if $(container_exists $PROJECT_CONTAINER_NAME); then + echo 'Starting project container on docker' + start_container $PROJECT_CONTAINER_NAME + attach_to_project_container + else + echo 'Creating project container' + + cp Dockerfile.development Dockerfile + docker build -t $PROJECT_NAME . + rm Dockerfile + docker run -d -ti --name $PROJECT_CONTAINER_NAME \ + -v $(pwd):/share \ + -p 8079:8079 -p 8080:8080 -p 3000:3000 -p 3001:3001 \ + $PROJECT_NAME /bin/bash -l + + docker_id=$PROJECT_CONTAINER_NAME + docker start $docker_id + attach_to_project_container + fi +} + +init(){ + run_project_container +} + +init From 5abef07b0bf3c428b92ab2b3f66e1d7e3c1d5dd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kaio=20Cristian=20Costa=20Porto=20de=20Magalh=C3=A3es?= Date: Thu, 11 Feb 2016 22:40:03 -0200 Subject: [PATCH 3/3] Update Readme with docker information --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 28cfe8f..91fb71e 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,10 @@ If you are an advanced user, and you need more features, you can choose one of t [Download React Starterify](https://github.com/Granze/react-starterify/releases/latest) +__With docker:__ + +`sh bin/dev` + __Install the dependencies:__ `npm install`