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

Feature/add dockerfile #33

Open
wants to merge 3 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
36 changes: 36 additions & 0 deletions Dockerfile.development
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
63 changes: 63 additions & 0 deletions bin/dev
Original file line number Diff line number Diff line change
@@ -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 <Enter> or <return>'
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