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..f688268d 100644 --- a/README.md +++ b/README.md @@ -80,3 +80,23 @@ 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" \ + smartcitiesdata/react_discovery_ui:0.0.1 +``` \ No newline at end of file diff --git a/config/config.js b/config/config.js index 93bffba5..95a80099 100644 --- a/config/config.js +++ b/config/config.js @@ -1,6 +1,6 @@ window.API_HOST = 'http://localhost:4000' 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')] },