Skip to content

CESARBR/knot-babeltower

Repository files navigation

KNoT Babeltower

Codacy Badge Build and test

Contents

Basic installation and usage

Requirements

  • Go version 1.13+.
  • Be sure the local packages binaries path is in the system's PATH environment variable:
$ export PATH=$PATH:<your_go_workspace>/bin

Configuration

You can set the ENV environment variable to development and update the internal/config/development.yaml when necessary. On the other way, you can use environment variables to configure your installation. In case you are running the published Docker image, you'll need to stick with the environment variables.

The configuration parameters are the following (the environment variable name is in parenthesis):

  • server
    • port (SERVER_PORT) Number Server port number. (Default: 80)

Setup

make tools

Compiling and running

make run

You can use the make watch command to run the application on watching mode, allowing it to be restarted automatically when the code changes.

Docker installation and usage

Requirements

Building and Running

Production

A container is specified at docker/Dockerfile. To use it, execute the following steps:

  1. Build the image:

    docker build . -f docker/Dockerfile -t cesarbr/knot-babeltower
  2. Create a file containing the configuration as environment variables.

  3. Run the container:

    docker run --env-file knot-babeltower.env -ti cesarbr/knot-babeltower

Development

A development container is specified at docker/Dockerfile-dev. To use it, execute the following steps:

  1. Build the image:

    docker build . -f docker/Dockerfile-dev -t cesarbr/knot-babeltower:dev
  2. Create a file containing the configuration as environment variables.

  3. Run the container:

    docker run --env-file knot-babeltower.env -p 8080:80 -v `pwd`:/usr/src/app -ti cesarbr/knot-babeltower:dev

The first argument to -v must be the root of this repository, so if you are running from another folder, replace pwd with the corresponding path.

This will start the server with auto-reload.

Verify service health

curl http://<hostname>:<port>/healthcheck

Documentation

Server documentation is auto-generated by the swag tool (https://github.com/swaggo/swag) from annotations placed in the code and can be viewed on the browser: http://<address>:<port>/swagger/index.html.

If you want to generate the documentation just run the make http-docs command.