Skip to content

Commit

Permalink
[add] dockerize the project
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiodxa committed Jan 12, 2017
1 parent d7572ad commit 81bca35
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# build-docker-dev
build-docker-dev:
cp -r project docker/dev/
cp package.json docker/dev/
cp Makefile docker/dev/
cp run-prod.sh docker/dev/
cd docker/dev/ && docker build -t "platzi/oss" .
rm -rf docker/dev/project
rm docker/dev/package.json
rm docker/dev/Makefile
rm docker/dev/run-prod.sh

# Run the microservice in the port 8000
start:
npm run start:prod

start-dev:
cd docker/dev/ && docker-compose up -d

stop-dev:
cd docker/dev/ && docker-compose stop
7 changes: 7 additions & 0 deletions docker/dev/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM node:wheezy
RUN mkdir /app
ADD project/ /app
WORKDIR /app
COPY package.json /app
RUN npm install
CMD ["npm", "run", "start:prod"]
15 changes: 15 additions & 0 deletions docker/dev/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: '2'
services:
# oss
oss:
image: platzi/oss
container_name: platzi-oss
ports:
- 9696:8000
networks:
platzi:
aliases:
- platzi-oss
networks:
platzi:
external: true
2 changes: 2 additions & 0 deletions run-prod.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
make start
29 changes: 29 additions & 0 deletions start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
make start-dev

case "$(uname -s)" in

Darwin)
export DOCKER_IP="$(dinghy ip)"
;;

Linux)
export DOCKER_IP='localhost'
;;
*)
export DOCKER_IP='localhost'
;;
esac

sleep 1s
API_STATUS=`curl -i -X GET http://$DOCKER_IP:9001/apis/oss/|awk 'NR==1{print $2}'`
if [ $API_STATUS != 200 ]; then
echo "registering oss on kong"
curl -i -X POST \
--url http://$DOCKER_IP:9001/apis/ \
--data 'name=oss' \
--data 'upstream_url=http://platzi-oss:8000/' \
--data 'request_path=/oss' \
--data 'strip_request_path=true' \
--data 'preserve_host=false' \
> /dev/null
fi

0 comments on commit 81bca35

Please sign in to comment.