Skip to content

Commit 9efd989

Browse files
committed
feat: Add Docker commands and update README with Makefile command descriptions
1 parent 567437b commit 9efd989

File tree

2 files changed

+63
-10
lines changed

2 files changed

+63
-10
lines changed

Makefile

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,24 @@ lint:
4545
build-prod:
4646
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o bin/api ./cmd/api
4747

48+
# Docker commands
49+
50+
# Run development environment with Docker
4851
docker-dev:
4952
./dev.sh
5053

54+
# Run production environment with Docker
55+
docker-compose-build:
56+
docker-compose build
57+
58+
# Stop and remove containers, networks, images, and volumes
59+
docker-compose-down:
60+
docker-compose down
61+
62+
# Start Docker containers in detached mode with build
63+
docker-compose-up:
64+
docker-compose up -d --build
65+
5166
# Docker build
5267
docker-build:
5368
docker build -t auth-api .
@@ -56,16 +71,27 @@ docker-build:
5671
docker-run:
5772
docker run -p 8080:8080 --env-file .env auth-api
5873

74+
# Generate documentation using Swagger
75+
swag-init:
76+
swag init -g cmd/api/main.go -o docs
77+
5978
# Show help
6079
help:
6180
@echo "Available commands:"
62-
@echo " build - Build the application"
63-
@echo " run - Run the application"
64-
@echo " dev - Run with hot reload (Air)"
65-
@echo " test - Run tests"
66-
@echo " clean - Clean build artifacts"
67-
@echo " setup - Setup development environment"
68-
@echo " fmt - Format code"
69-
@echo " lint - Run linter"
70-
@echo " build-prod - Build for production"
71-
@echo " docker-* - Docker commands"
81+
@echo " build - Build the application"
82+
@echo " run - Run the application"
83+
@echo " dev - Run with hot reload (Air)"
84+
@echo " test - Run tests"
85+
@echo " clean - Clean build artifacts"
86+
@echo " install-air - Install Air for hot reloading"
87+
@echo " setup - Setup development environment"
88+
@echo " fmt - Format code"
89+
@echo " lint - Run linter"
90+
@echo " build-prod - Build for production"
91+
@echo " docker-dev - Run development environment with Docker"
92+
@echo " docker-compose-build - Build Docker images using docker-compose"
93+
@echo " docker-compose-down - Stop and remove Docker containers, networks, images, volumes"
94+
@echo " docker-compose-up - Start Docker containers in detached mode with build"
95+
@echo " docker-build - Build Docker image (auth-api)"
96+
@echo " docker-run - Run Docker container with environment from .env"
97+
@echo " swag-init - Generate Swagger documentation (docs/)"

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,33 @@ swag init -g cmd/api/main.go -o docs
5454
3. Install [Air](https://github.com/air-verse/air) for hot reload: `go install github.com/air-verse/air@latest`
5555
4. Run: `air` or `go run cmd/api/main.go`
5656

57+
## 🛠️ Makefile Commands
58+
59+
The following `make` commands are available for development, testing, building, and Docker operations:
60+
61+
| Command | Description |
62+
|------------------------|------------------------------------------------------------------|
63+
| `make build` | Build the application binary (`bin/api.exe`). |
64+
| `make run` | Run the application without hot reload. |
65+
| `make dev` | Run with hot reload using [Air](https://github.com/air-verse/air).|
66+
| `make test` | Run all Go tests with verbose output. |
67+
| `make clean` | Remove build artifacts and temporary files. |
68+
| `make install-air` | Install Air for hot reloading. |
69+
| `make setup` | Setup development environment (installs Air, tidy/download deps). |
70+
| `make fmt` | Format code using `go fmt`. |
71+
| `make lint` | Run linter (`golangci-lint`). |
72+
| `make build-prod` | Build for production (Linux, static binary). |
73+
| `make docker-dev` | Run development environment with Docker (`./dev.sh`). |
74+
| `make docker-compose-build` | Build Docker images using docker-compose. |
75+
| `make docker-compose-down` | Stop and remove Docker containers, networks, images, volumes.|
76+
| `make docker-compose-up` | Start Docker containers in detached mode with build. |
77+
| `make docker-build` | Build Docker image (`auth-api`). |
78+
| `make docker-run` | Run Docker container with environment from `.env`. |
79+
| `make swag-init` | Generate Swagger documentation (`docs/`). |
80+
| `make help` | Show all available make commands. |
81+
82+
> **Tip:** You can also run `make help` to see this list in your terminal.
83+
5784
## 🔑 API Endpoints (Summary)
5885
- `POST /register` — Register
5986
- `POST /login` — Login

0 commit comments

Comments
 (0)