Golang DDD Boilerplate


This is a simple boilerplate for boostraping microservices in go lang following Domain driven design architecture.

This boilerplate is using the following techs:

  • HTTP: Echo
  • Database: Postgres (default driver)
  • Dependency Injection: Wire
  • Mocks generation: gomock
  • Github Deployment Workflow to heroku.

Running in locally

  1. download and build dependencies
  $ make build
  1. Provide a .env file as .env.example or export this environment variables

  2. Run generated bin

  $ export APP_ENV=development && ./app

Docker

  1. Generate a docker image
  $ make build-docker
  1. Run it
  $ docker run --env-file .env --net=host golang-ddd-template

Deploy app to heroku

Auto-deployment has been set up using github workflow to push a container to heroku. If you decide to deploy via heroku cli, see the steps below.

  1. Login to heroku
$ heroku login
  1. Create an application (if none exists)
$ heroku apps:create your-app-name
  1. Dockerize and push container to heroku container registry
$ heroku container:push web --app your-app-name
  1. Release container to your newly created application
$ heroku container:release web --app your-app-name

https://devcenter.heroku.com/articles/build-docker-images-heroku-yml