From 8f8da246a5a4afe6294451a854c0a3534fc0899a Mon Sep 17 00:00:00 2001 From: Nwachukwu Ugwuanyi Date: Sat, 23 Dec 2017 22:04:47 +0100 Subject: [PATCH 1/5] docker compose and deploy test --- Dockerfile | 13 +++++++++++++ deployfile.sh | 17 +++++++++++++++++ docker-compose.yml | 17 +++++++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 Dockerfile create mode 100644 deployfile.sh create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6c24789 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +#use +FROM mhart/alpine-node:latest + +ADD package.json /tmp/package.json +RUN cd /tmp && npm install +RUN mkdir -p /opt/app && cp -a /tmp/node_modules /opt/app/ + +WORKDIR /opt/app +ADD . /opt/app + +EXPOSE 7000 + +CMD ["npm", "start"] \ No newline at end of file diff --git a/deployfile.sh b/deployfile.sh new file mode 100644 index 0000000..ddf87f0 --- /dev/null +++ b/deployfile.sh @@ -0,0 +1,17 @@ +if [[ $(which docker) && $(docker --version) ]]; then + echo "docker is installed" + # variables defined in .env will be exported into this script's environment: + set -a + . ./.env + + # Let's populate the variables in our compose file template, + # then deploy it! + cat docker-compose.yml | envsubst | docker-compose up --build + else + echo "Install docker" + +fi + + + + diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..36458e9 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,17 @@ +version: "3" +services: + web: + container_name: app + build: . + ports: + - "7000:7000" + links: + - mongo + mongo: + container_name: mongo + image: mongo + volumes: + - /data/mongodb/db:/data/db + ports: + - "27017:27017" + From 8c93750a79b84488a7f4c5ebf3d92394ec94f0a5 Mon Sep 17 00:00:00 2001 From: Nwachukwu Ugwuanyi Date: Sat, 23 Dec 2017 22:07:16 +0100 Subject: [PATCH 2/5] Update deployfile.sh --- deployfile.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployfile.sh b/deployfile.sh index ddf87f0..be09399 100644 --- a/deployfile.sh +++ b/deployfile.sh @@ -1,10 +1,10 @@ if [[ $(which docker) && $(docker --version) ]]; then echo "docker is installed" # variables defined in .env will be exported into this script's environment: + # Let's populate the variables in our compose file template, set -a . ./.env - # Let's populate the variables in our compose file template, # then deploy it! cat docker-compose.yml | envsubst | docker-compose up --build else From 1b63db4d3610d61bda0b11364fb3b8cac6e12110 Mon Sep 17 00:00:00 2001 From: Nwachukwu Ugwuanyi Date: Sat, 23 Dec 2017 23:51:13 +0100 Subject: [PATCH 3/5] updated environment variable settings --- docker-compose.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 36458e9..0cf2521 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,7 +4,7 @@ services: container_name: app build: . ports: - - "7000:7000" + - "${PORT}:${PORT}" links: - mongo mongo: @@ -15,3 +15,5 @@ services: ports: - "27017:27017" + + From 8c2b7d75f58be04d921a3c726aac0d416e122e14 Mon Sep 17 00:00:00 2001 From: Nwachukwu Ugwuanyi Date: Sat, 23 Dec 2017 23:52:13 +0100 Subject: [PATCH 4/5] updated environment variables settings --- deployfile.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/deployfile.sh b/deployfile.sh index be09399..a7e6375 100644 --- a/deployfile.sh +++ b/deployfile.sh @@ -1,11 +1,12 @@ if [[ $(which docker) && $(docker --version) ]]; then echo "docker is installed" - # variables defined in .env will be exported into this script's environment: + # variables defined in .env will be exported into this script's environment: # Let's populate the variables in our compose file template, set -a . ./.env # then deploy it! + cat docker-compose.yml | envsubst | docker-compose up --build else echo "Install docker" @@ -15,3 +16,8 @@ fi + + + + + From 8e1ed200f99207ec1cce5ad0540125d641fd519a Mon Sep 17 00:00:00 2001 From: Nwachukwu Ugwuanyi Date: Sat, 23 Dec 2017 23:54:03 +0100 Subject: [PATCH 5/5] updated environment variable settings --- Dockerfile | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6c24789..6069bf6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,3 @@ -#use FROM mhart/alpine-node:latest ADD package.json /tmp/package.json @@ -8,6 +7,4 @@ RUN mkdir -p /opt/app && cp -a /tmp/node_modules /opt/app/ WORKDIR /opt/app ADD . /opt/app -EXPOSE 7000 - -CMD ["npm", "start"] \ No newline at end of file +CMD ["npm", "start"]