Skip to content
Rafał Lorenz edited this page Oct 31, 2017 · 20 revisions

Prerequisites

In order to run this project you need to have Docker > 1.17.05 installed for building the production image.

Instalation

git clone git@github.com:vardius/go-api-boilerplate.git

Configuration

Create your local .env file from dist.env files.

For each of binaries when building a docker image the environment variable file will be passed (Located in the binary directory). This repository contains example .env file for server binary. There is also .env file containing local configurations and is to be git ignored where dist.env contains versioned example of project configuration.

Remember to set PKG variable pointing to your repository, also change all imports from github.com/vardius/go-api-boilerplate/* to your-repository/*

Repository structure

Repository holds two top-level directories, pkg and cmd.

pkg directory contains directories for each of libraries.

cmd directory contains directories for each of binaries.

Directory Layout

.
├── /.vscode/            # Visual Studio Code remote debugging setttings
├── /nginx/              # Nginx docker container configuration
├── /cmd/                # Binaries
│   ├── /server/         # Server binary
│   │   └── /main.go     # Server application - glues together libraries
│   │   └── /.env        # Binary environment per binary configuration
│   ├── /...             # etc.
├── /pkg/                # Libraries
│   ├── /auth/           # Authorization tools
│   ├── /...             # etc.
│   ├── /domain/         # Domain libraries
│   │   ├── /user/       # User domain
│   │   │   ├── /main.go # Main user domain entrypoint
│   │   ├── /...         # etc.
│   ├── /http/           # Http utils
│   ├── /...             # etc.
│   ├── /...             # More internal libraries
├── /vendor/             # Vendor libraries
├── docker-compose.yml   # Defines Docker services, networks and volumes per developer environment
├── Dockerfile           # Docker image for production
├── Makefile             # Commands for building a Docker image for production and deployment
├── .env                 # Project environment configuration
└── bootstart.sh         # Configuration script for docker containers
Clone this wiki locally