- make
- PostgreSQL
- PostgreSQL Docker Image
- Create a Docker Network to Connect Golang Server Container and PostgreSQL Container with Each other
A Standard GNU Make File is Provided to Help with Running and Building Locally.
help ๐ฌ This Help Message
lint ๐ Lint & Format, will not Fix but Sets Exit Code on Error
lint-fix ๐ Lint & Format, will Try to Fix Errors and Modify Code
build ๐จ Build Binary File
run ๐ Run the Web Server Locally at PORT 9010
init ๐ฅ Download Dependencies From go.mod File
clean ๐งน Clean up Project
postgres ๐ Pull PostgreSQL Docker Image from Docker Hub Registry
docker-network ๐ชก Create Docker Network
image ๐ฆ Build Docker Container Image from Dockerfile
push ๐ค Push Container Image to Registry
compose-up ๐งท Create and Start Containers
compose-down ๐งผ Stop and Remove Containers, Networks
Makefile Variables
Makefile Variable | Default |
---|---|
SRC_DIR | ./src/ |
DEFAULT_GOAL | help |
BINARY_NAME | main |
BINARY_DIR | ./bin/ |
IMAGE_REPO | soelz/golang-book-management-system-sql-crud-api |
IMAGE_TAG | 0.1 |
DATABASE_URL | postgres://gorm:1234@db:5432/bank |
PostgreSQL_IMAGE | postgres:alpine3.18 |
PostgreSQL ORM Configurations (GORM) Available in ./src/pkg/config/app.go.
RUN Server in a Container
docker run --name db --network backend -e POSTGRES_USER=gorm -e POSTGRES_PASSWORD=1234 -e POSTGRES_DB=bank -p 5432:5432 postgres:alpine3.18
docker run --network backend -e DATABASE_URL=postgres://gorm:1234@db:5432/bank -p 9010:9010 soelz/golang-book-management-system-sql-crud-api:0.1
OR
Just Execute this Command ~>
make compose-up