Categorygithub.com/xclamation/go-auth-service
module
0.0.0-20241223123653-12a01b9e1d9d
Repository: https://github.com/xclamation/go-auth-service.git
Documentation: pkg.go.dev

# README

Go Auth Service

This project is a Go-based authentication service that uses PostgreSQL for database management and Goose for database migrations. The application is containerized using Docker.

Features

  • Authentication service
  • PostgreSQL database
  • Database migrations using Goose
  • Dockerized for easy deployment

Prerequisites

Before you begin, ensure you have met the following requirements:

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/go-auth-service.git
    cd go-auth-service
    
    
  2. Install dependencies:

    go mod download
    
    
  3. Rename file .env.example to .env:

    mv .env.sample .env
    
    
  4. Generate JWT secret

  5. Open .env and fill it with your values:

    DB_URL = "postgres://$DBUSER:$DBPASSWORD@$DBHOST/$DBNAME?sslmode=$DBSSL"
    JWT_SECRET = "your_jwt_token"
    DBHOST=host.docker.internal
    DBUSER=your_db_username
    DBPASSWORD=your_db_password
    DBNAME=your_db_name
    DBSSL=disable
    

Database Migrations

This project uses Goose for database migrations. Migrations are stored in the sql/migrations directory.

  1. Apply migrations:

    goose -dir ./sql/migrations postgres "user=db_username password=db_password dbname=db_name sslmode=disable" up
    

Local usage

For Linux:

  1. Build the application:

    go build -o main cmd/main.go
    
    
  2. Run the application:

    ./main
    

For Windows

  1. Build the application:
    go build -o main.exe cmd/main.go
    
  2. Run the application:
    ./main.exe
    

Docker

The project includes a Dockerfile and docker-compose.yml for containerizing the application.

  1. Build the Docker image:
    docker-compose build
    
  2. Run the Docker container:
    docker-compose up
    

# Packages

No description provided by the author
No description provided by the author