From a8e71640dc211bd083471253523164e7b4982ec9 Mon Sep 17 00:00:00 2001 From: Christoph Date: Mon, 2 Dec 2019 11:47:32 -0500 Subject: [PATCH 1/3] SCOGT-82 - Added Dockerfile --- .gitignore | 2 ++ Dockerfile | 13 +++++++++++++ README.md | 19 +++++++++++++++++++ config/config.js | 4 ++-- nginx-default.conf | 23 +++++++++++++++++++++++ run.sh | 15 +++++++++++++++ webpack.config.js | 2 +- 7 files changed, 75 insertions(+), 3 deletions(-) create mode 100644 Dockerfile create mode 100644 nginx-default.conf create mode 100755 run.sh diff --git a/.gitignore b/.gitignore index a67440ca..1aaff52e 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,5 @@ dist/ lib/ *.tgz + +.idea/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..79218598 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM node:12.13.1 AS builder +COPY . /app/src +WORKDIR /app/src +RUN export NODE_OPTS="--max-old-space-size=8192" +RUN npm ci +RUN npm run build + +FROM nginx +COPY --from=builder /app/src/dist /usr/share/nginx/html +COPY --from=builder /app/src/run.sh /run.sh +COPY --from=builder /app/src/nginx-default.conf /etc/nginx/conf.d/default.conf +WORKDIR /usr/share/nginx/html +CMD ["/run.sh"] diff --git a/README.md b/README.md index e55f3d5a..79575d66 100644 --- a/README.md +++ b/README.md @@ -80,3 +80,22 @@ export default class App extends Component { } } ``` + +## Using the Dockerfile + +### Building the Container + +`docker build . -t ` + +### Running the Container + +```bash +docker run -p 8089:80 \ +> -e API_HOST="https://data.smartcolumbusos.com" \ +> -e GTM_ID="GTM-EXAMPLE" \ +> -e BASE_URL="localhost" \ +> -e STREETS_TILE_LAYER_URL="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" \ +> -e AUTH_0_DOMAIN="smartcolumbusos-demo.auth0.com" \ +> -e AUTH_0_CLIENT_ID="YOUR_AUTH_0_CLIENT_ID" \ +> -e AUTH_0_AUDIENCE="discovery_api" +``` \ No newline at end of file diff --git a/config/config.js b/config/config.js index 93bffba5..6f0730c2 100644 --- a/config/config.js +++ b/config/config.js @@ -1,6 +1,6 @@ -window.API_HOST = 'http://localhost:4000' +window.API_HOST = 'https://data.smartcolumbusos.com' window.GTM_ID = '' -window.BASE_URL = 'example.com' +window.BASE_URL = 'localhost' window.STREETS_TILE_LAYER_URL = 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png' window.LOGO_URL = 'https://placekitten.com/530/530' window.MAPBOX_ACCESS_TOKEN = '' diff --git a/nginx-default.conf b/nginx-default.conf new file mode 100644 index 00000000..0ed89cb9 --- /dev/null +++ b/nginx-default.conf @@ -0,0 +1,23 @@ +server { + listen 80; + server_name localhost; + add_header X-Content-Type-Options nosniff; + add_header X-XSS-Protection "1; mode=block"; + gzip on; + gzip_static on; + gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; + gzip_proxied any; + gzip_vary on; + gzip_comp_level 6; + gzip_buffers 16 8k; + gzip_http_version 1.1; + location / { + root /usr/share/nginx/html; + index index.html index.htm; + try_files $uri /index.html; + } + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } +} \ No newline at end of file diff --git a/run.sh b/run.sh new file mode 100755 index 00000000..05fe4871 --- /dev/null +++ b/run.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +cat > /usr/share/nginx/html/config.js < { ] return { - watch: true, + watch: false, entry: { main: ['@babel/polyfill', path.join(__dirname, 'src', 'index.js')] }, From e954ad58819a291b31015a6709bc217ecaac126f Mon Sep 17 00:00:00 2001 From: Christoph Date: Mon, 2 Dec 2019 13:04:09 -0500 Subject: [PATCH 2/3] fixed running the container instructions --- README.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 79575d66..f688268d 100644 --- a/README.md +++ b/README.md @@ -91,11 +91,12 @@ export default class App extends Component { ```bash docker run -p 8089:80 \ -> -e API_HOST="https://data.smartcolumbusos.com" \ -> -e GTM_ID="GTM-EXAMPLE" \ -> -e BASE_URL="localhost" \ -> -e STREETS_TILE_LAYER_URL="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" \ -> -e AUTH_0_DOMAIN="smartcolumbusos-demo.auth0.com" \ -> -e AUTH_0_CLIENT_ID="YOUR_AUTH_0_CLIENT_ID" \ -> -e AUTH_0_AUDIENCE="discovery_api" + -e API_HOST="https://data.smartcolumbusos.com" \ + -e GTM_ID="GTM-EXAMPLE" \ + -e BASE_URL="localhost" \ + -e STREETS_TILE_LAYER_URL="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" \ + -e AUTH_0_DOMAIN="smartcolumbusos-demo.auth0.com" \ + -e AUTH_0_CLIENT_ID="YOUR_AUTH_0_CLIENT_ID" \ + -e AUTH_0_AUDIENCE="discovery_api" \ + smartcitiesdata/react_discovery_ui:0.0.1 ``` \ No newline at end of file From 951d029cd8d5dd3038d9dae725234b99675f2a9f Mon Sep 17 00:00:00 2001 From: Christoph Date: Mon, 2 Dec 2019 13:57:49 -0500 Subject: [PATCH 3/3] rolled back window.API_HOST based upon smartos comment --- config/config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.js b/config/config.js index 6f0730c2..95a80099 100644 --- a/config/config.js +++ b/config/config.js @@ -1,4 +1,4 @@ -window.API_HOST = 'https://data.smartcolumbusos.com' +window.API_HOST = 'http://localhost:4000' window.GTM_ID = '' window.BASE_URL = 'localhost' window.STREETS_TILE_LAYER_URL = 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'