Single-binary Web Apps in Go and Vue — Part 2
This is part 2 in a four part series where we will demonstrate building a web application using Go and Vue, and finally bundle it all together in a single binary for super-easy deployment/distribution. Part 1 can be found here.
In the first part of this series we built the Go and Vue apps. The Go application is a simple HTTP server that has a single endpoint which returns the version of this application. The Vue app is the stock Vue CLI hello world, but we added code to pull the version from the Go API and display it on our page. In part 2 we will add code to the Go application to make our life easier by starting the Vue app alongside the Go application automagically by automating the running of Node!
However, since the intent of this series is to deploy a single binary we don’t want to have to rely on having to also deploy NodeJS. So, let’s code this to meet the following criteria.
- When the server version is development, automatically start the Node server to run the Vue project
- When the server version is something else (like 1.0.0), don’t start Node. Instead just serve up the compile index.html and JavaScript files (which will eventually be embedded in our Go app in part 3 of this series)