feat: add Docker support and bot configuration

- Introduced Dockerfile for building the bot application using Go.
- Added .dockerignore to exclude unnecessary files from the Docker context.
- Updated docker-compose.yml to define the bot service and its dependencies, including environment variables for database and Lavalink configuration.
- Modified internal configuration to streamline environment variable handling.
This commit is contained in:
2026-03-18 13:39:31 +00:00
parent 1b47bd13a3
commit 461f8435c0
4 changed files with 50 additions and 26 deletions
+7
View File
@@ -0,0 +1,7 @@
.git
.gitignore
.env
*.md
Dockerfile
docker-compose*.yml
.dockerignore
+21
View File
@@ -0,0 +1,21 @@
# Build stage
FROM golang:1.22-alpine AS builder
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -o /velox-bot .
# Run stage
FROM alpine:3.19
RUN apk add --no-cache ca-certificates tzdata
WORKDIR /app
COPY --from=builder /velox-bot .
ENTRYPOINT ["./velox-bot"]
+16 -17
View File
@@ -1,23 +1,22 @@
version: "3.9" version: "3.9"
services: services:
db: bot:
image: postgres:16 build: .
container_name: velox-postgres container_name: velox-bot
restart: unless-stopped restart: unless-stopped
env_file: .env
environment: environment:
POSTGRES_USER: velox DB_HOST: postgres://velox:velox_pwd@db:5432/velox?sslmode=disable
POSTGRES_PASSWORD: velox_pwd LAVALINK_HOST: ${LAVALINK_HOST:-ws://lavalink:2333}
POSTGRES_DB: velox LAVALINK_PASSWORD: ${LAVALINK_PASSWORD:-youshallnotpass}
ports: depends_on:
- "5432:5432" db:
volumes: condition: service_healthy
- velox_pgdata:/var/lib/postgresql/data networks:
healthcheck: - default
test: ["CMD-SHELL", "pg_isready -U velox -d velox"] - lavalink
interval: 10s
timeout: 5s
retries: 5
volumes: networks:
velox_pgdata: lavalink:
external: true
-3
View File
@@ -33,9 +33,6 @@ func LoadConfig() (*Config, error) {
} }
guildID := os.Getenv("GUILD_ID") guildID := os.Getenv("GUILD_ID")
if guildID == "" {
return nil, fmt.Errorf("GUILD_ID is not set")
}
dbHost := os.Getenv("DB_HOST") dbHost := os.Getenv("DB_HOST")
if dbHost == "" { if dbHost == "" {