Example simple microservice project template providing:
- quick bootstrap of Golang microservice development,
- useful project structure,
- some best practices for microservices,
ginkgo
BDD-style unit and integration tests,- optional
.config.json
initialisation file, - environment variable configurations,
http.HandlerFunc
middleware compatible examples,- uses performant
httprouter
(HTTP-handling otherwise based on the standard Go libraries), - JSON stream processing of incoming data (array of JSON objects),
- ETL schema-based and ELT schemaless JSON data transformation examples,
- CI/CD scripts help ship microservice container artifact,
- minimally sized container image from
scratch
, - single static executable as only possible entrypoint,
- based on secure and lightweight system call library
musl-libc
(Alpine Linux), - includes ca-certificates for Golang HTTPS/TLS connectivity.
/.config.json
is an empty optional configuration file which is included into the Docker build.
- It is recommended to use the
gopls
Golang Language Server when working with Golang files. The Language Server was introduced in summer 2019 and is still in alpha state by October 2019, but is already very usable, efficient and works well with Golang modules.
.vscode/tasks.json
includes a default build task (ctrl+b) which executes.ci/build-docker.sh
script.
- Build scripts in
.ci/
will build the microservice static executable using Alpine Linux for a more secure system calls library (musl-libc
) and being very lightweight with minimal bloat to the executable.
- microservice executable placed as
/service
in Docker image, - single entrypoint for container image,
Dockerfile
can accept some arguments via the build environment (but must otherwise must be edited for e.g static resources).