GSS (Go serve SPA) is a containerized web server for single-page applications written in Go.
- Optimized for single-page apps.
- Automatically serves pre-compressed brotli and gzip files if available.
- Sensible default cache configuration.
- Optional out-of-the-box metrics.
- Deployable as a container.
- Lightweight.
GSS works as a Docker container. By default it serves a directory in the container named dist
at port 8080
.
docker run -p [container-port]:8080 -v [local-folder-to-serve-path]:/dist lewislbr/gss
Example:
Having a local folder named
public
with SPA files:docker run -p 3000:8080 -v $PWD/public:/dist lewislbr/gss
The server with the contents from
public
will be accessible at port3000
.
FROM lewislbr/gss:latest
COPY [local-folder-to-serve-path] ./dist
Example:
FROM lewislbr/gss:latest COPY /public ./distdocker build -t custom-image .
docker run -p 3000:8080 custom-image
The server with the contents from
public
will be accessible at port3000
.
Optionally, the server can be configured with a YAML file named /gss.yaml
.
The configuration file should go into the container, such as:
docker run -p 3000:8080 -v $PWD/gss.yaml:/gss.yaml -v $PWD/public:/dist lewislbr/gss
FROM lewislbr/gss:latest COPY gss.yaml ./ COPY /public ./dist
Configures the port where files will be served. 8080
by default.
Example:
# gss.yaml filesPort: 3000
Configures the port where metrics, if enabled, will be available. 8081
by default.
Example:
# gss.yaml metricsPort: 3001
Enables metrics collection and exposes an endpoint at :<metricsPort>/metrics
. Collected metrics include request duration, request status, total requests, and bytes written. False by default.
Example:
# gss.yaml metrics: true
This project started as a way to learn and to solve a need I had. If you think it can be improved in any way, you are very welcome to contribute!