From 4710f94793edcd7b220e21b275acd1272fea4266 Mon Sep 17 00:00:00 2001 From: Ibrahim Bali Date: Thu, 5 Jul 2018 16:34:53 +0300 Subject: [PATCH 1/3] Added Dockerfile template Added Dockerfile template to run the demo on a docker container --- Dockerfile | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..f66ea0d3 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,31 @@ +FROM node:10.5.0-alpine + +# added this step to prevent angular.json not found error +WORKDIR /usr/src + +COPY . . + +# replace ng serve with ng serve --host 0.0.0.0 so that it serves outside +# install jq for json edit +RUN apk update \ + && apk add jq + +# replace package.json +RUN input_json="package.json" \ + && tmp_json="tmp.json" \ + && jq '.scripts.start = "ng serve --host 0.0.0.0"' $input_json > $tmp_json \ + && mv $tmp_json $input_json + +# remove jq +RUN apk del jq + +RUN npm install +RUN npm audit fix +# running this a second time does seem to fix another vuln. +RUN npm audit fix +# this sometimes do get fixed beforehand +RUN npm update ws --depth 4 + +EXPOSE 4200 + +CMD ["npm", "start"] \ No newline at end of file From 619476db5cd3378fe5e6ae73a4f3584c55dab639 Mon Sep 17 00:00:00 2001 From: Ibrahim Bali Date: Thu, 5 Jul 2018 16:58:15 +0300 Subject: [PATCH 2/3] feat(serve): Dockerfile initial commit Add Dockerfile template --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index f66ea0d3..c9562b05 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,4 @@ +# base Docker image, remove "-alpine" if having trouble FROM node:10.5.0-alpine # added this step to prevent angular.json not found error @@ -28,4 +29,4 @@ RUN npm update ws --depth 4 EXPOSE 4200 -CMD ["npm", "start"] \ No newline at end of file +CMD ["npm", "start"] From 6b7a4ea4e3ad6e067ae5c4e07df6d459c04eb4af Mon Sep 17 00:00:00 2001 From: Ibrahim Bali Date: Mon, 9 Jul 2018 10:25:04 +0300 Subject: [PATCH 3/3] refactor(Dockerfile): passing --host directly Passing --host 0.0.0.0 option directly instead of editing the package.json file to hardcode it. --- Dockerfile | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/Dockerfile b/Dockerfile index c9562b05..67b7f3d4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,20 +6,6 @@ WORKDIR /usr/src COPY . . -# replace ng serve with ng serve --host 0.0.0.0 so that it serves outside -# install jq for json edit -RUN apk update \ - && apk add jq - -# replace package.json -RUN input_json="package.json" \ - && tmp_json="tmp.json" \ - && jq '.scripts.start = "ng serve --host 0.0.0.0"' $input_json > $tmp_json \ - && mv $tmp_json $input_json - -# remove jq -RUN apk del jq - RUN npm install RUN npm audit fix # running this a second time does seem to fix another vuln. @@ -29,4 +15,4 @@ RUN npm update ws --depth 4 EXPOSE 4200 -CMD ["npm", "start"] +CMD ["npm", "start", "--", "--host", "0.0.0.0"]