Bläddra i källkod

Adding parcel-cache to gitignore
Adding Docker-entrypoint script to UI docker container to allow for building the UI container with the ability to override the BASE_URL
Modifying the dockerfile for the UI to containe the entrypoint and to no longer build the container with a BASE_URL baked in
Adding a Makefile to the UI project to ease development
Removing the default from the AllocationService within the UI to be a placeholder
Dependencies updated themselves in package-lock

Signed-off-by: Logan Ballard <loganballard@gmail.com>

Logan Ballard 3 år sedan
förälder
incheckning
53d311607a
5 ändrade filer med 34 tillägg och 2 borttagningar
  1. 1 0
      .gitignore
  2. 5 1
      ui/Dockerfile
  3. 15 0
      ui/Makefile
  4. 12 0
      ui/docker-entrypoint.sh
  5. 1 1
      ui/src/services/allocation.js

+ 1 - 0
.gitignore

@@ -2,6 +2,7 @@
 .idea
 *.iml
 
+ui/.parcel-cache
 ui/.cache
 ui/dist
 ui/node_modules/

+ 5 - 1
ui/Dockerfile

@@ -3,10 +3,14 @@ ADD package*.json /opt/ui/
 WORKDIR /opt/ui
 RUN npm install
 ADD src /opt/ui/src
-ENV BASE_URL=/model
 RUN npx parcel build src/index.html
 
 FROM nginx:alpine
 COPY --from=builder /opt/ui/dist /var/www
 COPY default.nginx.conf /etc/nginx/conf.d/
 COPY nginx.conf /etc/nginx/
+
+ENV BASE_URL=/model
+
+COPY ./docker-entrypoint.sh /usr/local/bin/
+ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]

+ 15 - 0
ui/Makefile

@@ -0,0 +1,15 @@
+BASE_URL := "/model"
+
+.PHONY: build
+build:
+	echo "building with base url ${BASE_URL}"
+	BASE_URL=${BASE_URL} npx parcel build src/index.html
+
+.PHONY: serve
+serve:
+	echo "serving with base url ${BASE_URL}"
+	BASE_URL=${BASE_URL} npx parcel serve src/index.html
+
+.PHONY: clean
+clean:
+	rm -rf dist/*

+ 12 - 0
ui/docker-entrypoint.sh

@@ -0,0 +1,12 @@
+#!/bin/sh
+set -e
+
+if [[ ! -z "$BASE_URL_OVERRIDE" ]]; then
+    echo "running with BASE_URL=${BASE_URL_OVERRIDE}"
+    sed -i "s^{PLACEHOLDER_BASE_URL}^$BASE_URL_OVERRIDE^g" /var/www/*.js
+else 
+    echo "running with BASE_URL=${BASE_URL}"
+    sed -i "s^{PLACEHOLDER_BASE_URL}^$BASE_URL^g" /var/www/*.js
+fi
+
+exec "$@"

+ 1 - 1
ui/src/services/allocation.js

@@ -1,7 +1,7 @@
 import axios from 'axios';
 
 class AllocationService {
-  BASE_URL = process.env.BASE_URL || 'http://localhost:9090/model';
+  BASE_URL = process.env.BASE_URL || '{PLACEHOLDER_BASE_URL}';
 
   async fetchAllocation(win, aggregate, options) {
     const { accumulate, filters, } = options;