If you like this repo or found it helpful, please give it a star. Thanks!
- Gin as web framework
- JWT for authentication and authorization
- Redis for caching
- Elasticsearch for logging database
- Beat for log shipping
- Kibana as log viewer
- Postgresql as main database engine
- PgAdmin as database management tool
- Prometheus for metric database
- Grafana for metric dashboards
- Validator for endpoint input Validation
- Viper for configurations
- Zap for logging
- Zerolog for logging
- Gorm as ORM
- Swagger for documentation
- Docker compose to run project with all dependencies in docker
docker compose -f "docker/docker-compose.yml" up -d --build
Run local manually http://localhost:5005
Run in docker http://localhost:9001
Token Url: http://localhost:5005/api/v1/users/login-by-username
Username: admin
Password: 12345678
Username: elastic
Password: @aA123456
Username: admin
Password: foobar
Username: h.naimaei@gmail.com
Password: 123456
Postgres Server info:
Host: postgres_container
Port: 5432
Username: postgres
Password: admin
docker compose --file 'docker/docker-compose.yml' --project-name 'docker' down
- build Project and copy configuration
/src > go build -o ../prod/server ./cmd/main.go
/src > mkdir ../prod/config/ && cp config/config-production.yml ../prod/config/config-production.yml
- Create systemd unit
sudo vi /lib/systemd/system/go-api.service
- Service config
[Unit]
Description=go-api
[Service]
Type=simple
Restart=always
RestartSec=20s
ExecStart=/home/hamed/github/golang-clean-web-api/prod/server
Environment="APP_ENV=production"
WorkingDirectory=/home/hamed/github/golang-clean-web-api/prod
[Install]
WantedBy=multi-user.target
- Start service
sudo systemctl start go-api
- Stop service
sudo systemctl stop go-api
- Show service logs
sudo journalctl -u go-api -e