This is a demo application that uses SPA Reloader and SPA Reloader Vue Plugin.
npm i spa-reloader-vue
import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import spaReloader from "spa-reloader-vue";
import vuetify from "./plugins/vuetify";
Vue.config.productionTip = false;
Vue.use(spaReloader, {
spaReloaderURL: "ws://" + location.hostname + "/ws",
});
new Vue({
router,
store,
vuetify,
render: (h) => h(App),
}).$mount("#app");
...
mounted() {
this.$spaSubscribe(this.callbackFunction);
},
methods: {
callbackFunction: function(image) {
this.showDialog = true;
if (image !== undefined && image !== null) {
this.dialogText = `Image changed from: ${image.previous_image.name}, to: ${image.current_image.name}`;
} else {
this.dialogText = "Image change detected.";
}
}
}
...
docker build -t docker.io/toucansoftware/spa-reloader-demo:v1 .
git checkout v2
docker build -t docker.io/toucansoftware/spa-reloader-demo:v2 .
We are deploying the application as Kubernetes Deployment which exposes the container port 80
as ClusterIP
Service. This port is exposed to clients outside the cluster through an Ingress.
Please follows the install steps of NGINX Ingress Controller to install the corresponding Ingress Controller for your settings.
In this demo we are using Docker for Mac Kubernetes, so we need to run the following commands to install the Ingress Controller.
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.41.1/deploy/static/provider/cloud/deploy.yaml
kubectl apply -f https://raw.githubusercontent.com/ToucanSoftware/spa-reloader-demo/main/deploy/01-spa-reloader.yaml
kubectl apply -f https://raw.githubusercontent.com/ToucanSoftware/spa-reloader-demo/main/deploy/02-demo.yaml
kubectl set image deployment/spa-demo spa-demo=docker.io/toucansoftware/spa-reloader-demo:v2 -n spa-demo
kubectl delete -f https://raw.githubusercontent.com/ToucanSoftware/spa-reloader-demo/main/deploy/02-demo.yaml
kubectl delete -f https://raw.githubusercontent.com/ToucanSoftware/spa-reloader-demo/main/deploy/01-spa-reloader.yaml
kubectl delete -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.41.1/deploy/static/provider/cloud/deploy.yaml