Go & Vue.js - Demo Web Application .This is a simple web application with a Go server/backend and a Vue.js SPA (Single Page Application) frontend.
The app has been designed with cloud native demos & containers in mind, in order to provide a real working application for deployment, something more than “hello-world” but with the minimum of pre-reqs. It is not intended as a complete example of a fully functioning architecture or complex software design.
Typical uses would be deployment to Kubernetes, demos of Docker, CI/CD (build pipelines are provided), deployment to cloud (Azure) monitoring, auto-scaling
/
├── spa Root of the Vue.js project
│ └── src Vue.js source code
├── azure Supporting files for Azure deployment etc
└── server Go backend server
└── vendor Vendor libraries used by the server
The Go server component performs two tasks
GET /api/info
- Returns system information and various properties as JSONGET /api/metrics
- Returns monitoring metrics for CPU, memory, disk and network. This data comes from the gopsutils libraryGET /api/weather
- Returns weather data for the location determined automatically from the calling IP address, uses IPStack and DarkSky REST APIsgit clone https://github.com/benc-uk/vuego-demoapp.git
To build and bundle the SPA run the following. This will output the resulting app (HTML, CSS, JS, assets, etc) to spa/dist
cd spa
npm install
npm run build
To build the Go server component run the following. This will create an executable called server
or server.exe
cd server
go build
To start the app, launch the server exe and pass the directory containing the content you wish to serve as a command line parameter. The server will listen on port 4000 by default, change this by setting the environmental variable PORT
cd server
./server ../spa/dist
Then access http://localhost:4000/
npm run serve
, this will start a dev server on port 8080. This will serve the app content and will auto reload when code changes. However the API endpoint will not be available so the ‘Sys Info’ & ‘Monitor’ pages will not receive any datago run *.go
or go run *.go ../spa/dist
Public Docker image is available on Dockerhub
Run with docker run -d -p 4000:4000 bencuk/vuego-demoapp
WEATHER_API_KEY
- Enable the weather feature with a DarkSky API keyIPSTACK_API_KEY
- Enable the weather feature with a IPStack API keyWaiting for golang support
A working CI and release GitHub Actions workflow is provided .github/workflows/build-deploy-aks.yml
, automated builds are run in GitHub hosted runners
Templates for deployment to Azure with “quick deploy” buttons are here
When | What |
---|---|
April 2018 | Project created |
July 2018 | Updated Vue CLI config & moved to Golang 1.11 |
Sept 2018 | Updated with weather API and weather view |
Sept 2019 | New release pipelines and config moved to env vars |
Dec 2019 | Github Actions and AKS |
Author: benc-uk
Source Code: https://github.com/benc-uk/vuego-demoapp
#vuejs #vue #javascript #golang #vue-js