Skip to content

Boilerplate for Go based REST API with PosgreSQL both in seperate docker containers, with live reload using CompileDaemon

Notifications You must be signed in to change notification settings

gpng/go-docker-api-boilerplate

Repository files navigation

Go Docker API Boilerplate

Boilerplate for Go based REST API with PostgreSQL, with live reload using CompileDaemon.

Builds a docker container for PostgreSQL Database. Builds a docker container with live reload for Go REST API and links to Postgres container

Table of Contents

Dependencies

goose

sqlc

swaggo

Usage

  1. Create .env using .env.sample as example

  2. Start docker containers

    make
    
  3. View logs

    make logs
    
  4. Visit localhost:4000/ to check if API is responding

  5. Generate docs from swagger comments

    make gen-docs
    
  6. Visit localhost:4000/docs for documentation

  7. Stop docker containers

    make down
    

Migrations

Create new migrations

goose -dir db/migrations create <migration_name> sql

Run migrations

env $(cat .env) make migrate

Rollback migrations

env $(cat .env) make rollback

Generating models

make gen-models

Test

make test

Maintainers

@gpng

License

MIT © 2020 Gerald Png

About

Boilerplate for Go based REST API with PosgreSQL both in seperate docker containers, with live reload using CompileDaemon

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published