Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ LOGTYPE=console
WEBHOOKFILES=true

CONNECT_ON_STARTUP=true
TELEMETRY_ENABLED=true

OS_NAME=Evolution GO

Expand Down
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,18 @@ Evolution Go is a high-performance WhatsApp API built in Go, part of the [Evolut

### Docker (Recommended)

The easiest and fastest way to start the project with all its dependencies (PostgreSQL, RabbitMQ, MinIO) is by using our automated script:

```bash
git clone https://github.com/EvolutionAPI/evolution-go.git
cd evolution-go
make docker-build
make docker-run

# Runs the script that will prepare dependencies, variables, and start the containers
bash ./start.sh
```

> **Note:** The `start.sh` script will initialize submodules, create your `.env` based on `.env.example` (adjusting hosts for Docker), and run `docker compose up -d --build`.

### Local Development

```bash
Expand Down
27 changes: 14 additions & 13 deletions cmd/evolution-go/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,12 @@ import (

var devMode = flag.Bool("dev", false, "Enable development mode")

var version = "0.0.0"

func init() {
// ldflags -X main.version= sets this at compile time.
// If not set (or still default), try reading from VERSION file.
if version == "0.0.0" {
if v, err := os.ReadFile("VERSION"); err == nil {
if trimmed := strings.TrimSpace(string(v)); trimmed != "" {
version = trimmed
}
}
var version = func() string {
if v, err := os.ReadFile("VERSION"); err == nil {
return strings.TrimSpace(string(v))
}
}
return "dev"
}()

func setupRouter(db *gorm.DB, authDB *sql.DB, sqliteDB *sql.DB, config *config.Config, conn *amqp.Connection, exPath string, runtimeCtx *core.RuntimeContext) *gin.Engine {
killChannel := make(map[string](chan bool))
Expand Down Expand Up @@ -200,7 +193,7 @@ func setupRouter(db *gorm.DB, authDB *sql.DB, sqliteDB *sql.DB, config *config.C
// NOVO: PollHandler usando PollService já inicializado no whatsmeowService (evita dupla inicialização)
pollHandler := poll_handler.NewPollHandler(whatsmeowService.GetPollService(), loggerWrapper)

telemetry := telemetry.NewTelemetryService()
telemetry := telemetry.NewTelemetryService(config.TelemetryEnabled)

r := gin.Default()

Expand Down Expand Up @@ -245,6 +238,14 @@ func setupRouter(db *gorm.DB, authDB *sql.DB, sqliteDB *sql.DB, config *config.C
go whatsmeowService.ConnectOnStartup(config.ClientName)
}

// @Summary WebSocket Connection
// @Description Connect to the WebSocket
// @Tags WebSocket
// @Param token query string true "Global API Key"
// @Param instanceId query string true "Instance ID"
// @Success 101 {string} string "Switching Protocols"
// @Failure 401 {object} gin.H "Unauthorized"
// @Router /ws [get]
r.GET("/ws", func(c *gin.Context) {
token := c.Query("token")
instanceId := c.Query("instanceId")
Expand Down
86 changes: 86 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
version: '3.8'

services:
evolution-go:
build:
context: .
dockerfile: Dockerfile
container_name: evolution-go
restart: unless-stopped
ports:
- "8080:8080"
env_file:
- .env
volumes:
- evolution_data:/app/dbdata
- evolution_logs:/app/logs
networks:
- evolution_network
depends_on:
- postgres
- rabbitmq
- minio

postgres:
image: postgres:15-alpine
container_name: postgres
restart: unless-stopped
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: root
POSTGRES_DB: postgres
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
- ./docker/examples/init-db.sql:/docker-entrypoint-initdb.d/init-db.sql
networks:
- evolution_network

rabbitmq:
image: rabbitmq:3-management-alpine
container_name: rabbitmq
restart: unless-stopped
environment:
RABBITMQ_DEFAULT_USER: admin
RABBITMQ_DEFAULT_PASS: admin
RABBITMQ_DEFAULT_VHOST: default
ports:
- "5672:5672"
- "15672:15672"
volumes:
- rabbitmq_data:/var/lib/rabbitmq
networks:
- evolution_network

minio:
image: minio/minio:latest
container_name: minio
restart: unless-stopped
command: server /data --console-address ":9001"
environment:
MINIO_ROOT_USER: minioadmin
MINIO_ROOT_PASSWORD: minioadmin
ports:
- "9000:9000"
- "9001:9001"
volumes:
- minio_data:/data
networks:
- evolution_network

volumes:
evolution_data:
driver: local
evolution_logs:
driver: local
postgres_data:
driver: local
rabbitmq_data:
driver: local
minio_data:
driver: local

networks:
evolution_network:
driver: bridge
Loading