# 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:
- Go installed
- Docker installed
- Docker Compose installed
Installation
-
Clone the repository:
git clone https://github.com/yourusername/go-auth-service.git cd go-auth-service
-
Install dependencies:
go mod download
-
Rename file
.env.example
to.env
:mv .env.sample .env
-
Generate JWT secret
-
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.
-
Apply migrations:
goose -dir ./sql/migrations postgres "user=db_username password=db_password dbname=db_name sslmode=disable" up
Local usage
For Linux:
-
Build the application:
go build -o main cmd/main.go
-
Run the application:
./main
For Windows
- Build the application:
go build -o main.exe cmd/main.go
- Run the application:
./main.exe
Docker
The project includes a Dockerfile and docker-compose.yml for containerizing the application.
- Build the Docker image:
docker-compose build
- Run the Docker container:
docker-compose up