Skip to content
ekedonald edited this page Jul 19, 2024 · 12 revisions

Environment Setup for HNG Boilerplate Golang Web

Overview

This document outlines the environment setup required to run the HNG Boilerplate Golang Web application in both development (test) and production environments. It covers the necessary software, hardware, and configuration settings, including setting up Nginx as a reverse proxy.

Required Software

Go Programming Language

  • Version: 1.19 or later
  • Installation: Follow the official Go installation guide for your operating system.

PostgreSQL

  • Version: 14 or later
  • Installation: You can install PostgreSQL using the package manager of your choice:
    • Homebrew (MacOS):
      brew install postgresql
    • APT (Ubuntu):
      sudo apt-get update
      sudo apt-get install postgresql postgresql-contrib
    • YUM (CentOS):
      sudo yum install postgresql-server postgresql-contrib

Docker (Optional)

  • Purpose: To run PostgreSQL instances in containers, simplifying setup and teardown.
  • Installation: Follow the official Docker installation guide.

Git

Nginx

  • Version: Latest stable version.
  • Installation: You can install Nginx using the package manager of your choice:
    • APT (Ubuntu):
      sudo apt-get update
      sudo apt-get install nginx
    • YUM (CentOS):
      sudo yum install nginx

PM2 (Process Manager)

  • Purpose: To manage and monitor the Go application processes.
  • Installation: Follow the official PM2 installation guide:
    npm install pm2@latest -g

Setting Up the Environment

PostgreSQL Instances

You need two PostgreSQL instances: one for regular development and one for running tests. You can set them up locally or use Docker for convenience.

Using Docker

To set up PostgreSQL instances using Docker, run the following commands:

docker run --name main_db -e POSTGRES_PASSWORD=password -d postgres
docker run --name test_db -e POSTGRES_PASSWORD=password -d postgres