Deploy Zypress (or Static Website) in a standalone Golang binary
Starting with Golang 1.16, file embedding is supported in Go without the need for an external package. I leveraged this feature and added the support to build and deploy Zypress (or any SPA / Static Web Sites) in standalone binary for all operating systems i.e. Linux, Mac OS, Windows built using Golang’s latest file embedding feature.
The zypress code repo now contains the following code files at the root of the project to build the binary in your local system and run anywhere.
main.gobuild.shsystemd
This requires Go to be installed in your machine and configured in your PATH variable. No worries, if you don’t know Golang or don’t want to build it in your system!.. I added support for cloud build using github action to generate the binary named zypress-server and upload the artifacts for [download] (http://)
Running the website directlly by executing a single binary will be super helpful to deploy the website (any static web site) on-prem or to share your work privately with anyone or your client privately as email attachment or upload in a dropbox / google drive. The size of the binary is < 10mb.
Build zypress binaries
Simple
go build main.go -o zypress-server
or
Advanced
A utility bash script provided to create the following artifacts:
- Build and generate the binaries for Linux, Mac and Windows for both 32 bit and 64 bit operating system
- Linux systemd service file to run
zypress-serveras service with auto-restart during server reboot install.shutility shell scriptreadme.mdfile- release bundle as `tar’ file.
sh server.build.sh
How to run zypress server?
./zypress-server [-p] [-e] [-s] [-i] [-d]
- [-p] port. Default value is
8080 - [-e] environment. Default value is
dev - [-s] Website source type. Default value is
embedmeaning the website source is embedded inside the binary. - [-i] index document to serve. Default value is
index.html - [-d] Directory where the website source is located. Default value is
./distrelative to thezypressserver.
Run with default configurations
./zypress-server
Overriden port to 5000
./zypress-server -p 5000
Run with file-system mode.
./zypress-server -p 5000 -e 'prod' -s 'fs' -f 'index.html' -d '/opt/www/zypresse'