This commit is contained in:
2026-03-02 00:38:38 -03:00
4 changed files with 79 additions and 0 deletions

4
.dockerignore Normal file
View File

@@ -0,0 +1,4 @@
.vscode
.git
data/
bot.db

33
Dockerfile Normal file
View File

@@ -0,0 +1,33 @@
FROM golang:1.25-alpine AS builder
# Ensure CGO is off for a static binary
ENV CGO_ENABLED=0
# Ensure Go modules are strictly enforced
ENV GO111MODULE=on
WORKDIR /app
# Copy only the dependency files first
COPY go.mod go.sum ./
RUN go mod download
# Copy the entire project structure
COPY . .
# Build from the current directory (.) so it finds the module root
RUN go build -o /app/bot .
FROM alpine:latest
RUN apk --no-cache add ca-certificates
RUN mkdir /data
WORKDIR /root/
COPY --from=builder /app/bot .
COPY --from=builder /app/templates ./templates
COPY .env .
ENV DB_PATH=/data/bot.db
CMD ["./bot"]

View File

@@ -1,2 +1,40 @@
# whatsapp-bot
## 🐳 Docker Deployment (Server)
Build and run the central inventory server:
```bash
# Build the image
docker build -t go-bot:latest .
# Run the container (Map port 9090 and persist the database/cache)
docker run -d \
--name whatsapp-bot \
-p 9090:9090 \
-e OPENROUTER_API_KEY=your_key \
-e WHATSAPP_PHONE_ID=your_id \
-e WHATSAPP_TOKEN=your_token \
-v $(pwd)/whatsapp-bot/data:/root/data:Z \
--restart unless-stopped \
go-bot:latest
```
Or use this stack:
```yml
services:
bot:
image: go-bot:latest
container_name: whatsapp-bot
restart: unless-stopped
environment:
- OPENROUTER_API_KEY=your_api_key_here
- WHATSAPP_PHONE_ID=your_phone_id_here
- WHATSAPP_TOKEN=your_token_here
volumes:
# Map host data folder to the app's data path
# The :Z is required for SELinux (Fedora/RHEL)
- YOUR_PATH/whatsapp-bot/data:/root/data:Z
ports:
- "8080:9090"
```

View File

@@ -11,7 +11,11 @@ var Conn *sql.DB
func Init() {
var err error
<<<<<<< HEAD
Conn, err = sql.Open("sqlite", "./saas_bot.db")
=======
Conn, err = sql.Open("sqlite", "./data/bot.db")
>>>>>>> 63654c4c1b55ddcfeb4a5adf43d0a1778236c58d
if err != nil {
panic(err)
}