microservice-template

module
v0.0.0-...-3b40034 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2023 License: MIT

README

Golang microservice template

Version: 0.3.1

This template is mainly used for custom projects.

It is mainly made for small cloud projects. Contains simple graceful shutdown, healthchecks, config system and a default library code.

How to use this template

  1. Use the repo as template
  2. Edit go.mod file - change the name of the service (like username/my_service)
  3. Configure the CI pipeline actions in the Makefile at line 60 in the release action (Optional)
  4. Code
  5. Deploy
Development opeartions

This is a section which suggests useful tools for devlopment and standatises the workflow.

  1. make to run application
  2. make build or make dist to create a binary distribution of your service. build creates binary and dist creates a binary and packs it into a zip folder
  3. make docker to create a docker container image using the docker file
  4. make dock to run your docker container
  5. make clean to remove dist and build artifacts
  6. make major/minor/patch to bump the version and start a CI pipeline
CI pipeline configuration actions
  • bump - changes the software version in the Makefile. Don't change it, usually it would not do anything bad. If release is called iw would do nothing. If major/minor/patch called it changes the version.

  • build - builds the binary of your software. It uses the build matrix defined by 2 vars: TARGET_OS and TARGET_ARCH. By default windows and darwin OS, as well as arm64, i386 and arm architectures are commented. Uncomment to enable them.

  • dist - runs buildand packs every binary in an archive with corresponding name

  • git_full - runs git_commit and git_tag

  • git_commit - adds Makefile changes and commits the code with the "Version ${version}" message, then pushes to default remote

  • git_tag - adds the annotated tag with the version and pushes to default remote

  • gh_release - uses Github's CLI tool to create Github Releases and pushes the current version with results of dist action

  • docker - builds a docker image tagged by latest and by the last version

  • docker_push - if DOCKER_PREFIX is present, pushes the latest docker image with both version and latest tag to the remote

Directories

Path Synopsis
src
cmd
server
Main server package of the app
Main server package of the app

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL