goStatic - A really small static web server for Docker - Golang
954
A really small static web server for Docker
My goal is to create to smallest docker container for my web static files. The advantage of Go is that you can generate a fully static binary, so that you don't need anything else.
Because the official Golang image is wayyyy to big (around 1/2Gb as you can see below) and could be unsecure.
For me, the whole point of containers is to have a light container... Many links should provide you with additional info to see my point of view:
// HTTPS server
docker run -d -p 443:443 -v path/to/website:/srv/http --name goStatic gleez/gostatic
// HTTP server
docker run -d -p 80:80 -v path/to/website:/srv/http --name goStatic gleez/gostatic --forceHTTP --forceHTML5
https://echo.labstack.com/cookbook/auto-tls
Needs this folder mounted "/var/www/.cache"
I'm using echo as a micro web framework because he has great performance, and generate the static binary
I'm also using the https://github.com/broady/cacerts for the certs to avoid this error:
x509: failed to load system roots and no roots provided
set -e -x
apt-get update
apt-get install -y ca-certificates
cp /etc/ssl/certs/ca-certificates.crt .
Get the latest version from github
git clone https://github.com/gleez/docker-images
cd docker-images/goStatic
Build it
sudo docker run --rm -it -v "$PWD":/usr/src/myapp -w /usr/src/myapp golang:1.7.5 bash
$ ./debian_cpcerts.bash
$ CGO_ENABLED=0 go build -ldflags '-s' -v -o goStatic
sudo docker build --force-rm=true --tag="$USER/gostatic" .
Enjoy !!
Content type
Image
Digest
Size
2 MB
Last updated
over 9 years ago
docker pull gleez/gostatic