Dockerized
This commit is contained in:
4
.dockerignore
Normal file
4
.dockerignore
Normal file
@@ -0,0 +1,4 @@
|
||||
.git
|
||||
bot.db
|
||||
vendor
|
||||
.env
|
||||
1
.env.example
Normal file
1
.env.example
Normal file
@@ -0,0 +1 @@
|
||||
DISCORD_TOKEN="Ein Discord Token"
|
||||
31
Dockerfile
Normal file
31
Dockerfile
Normal file
@@ -0,0 +1,31 @@
|
||||
# STAGE 1: Build
|
||||
FROM golang:1.24-bookworm AS builder
|
||||
|
||||
# Arbeitsverzeichnis im Container
|
||||
WORKDIR /app
|
||||
|
||||
# Erst Abhängigkeiten kopieren (für besseres Caching)
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
|
||||
# Restlichen Code kopieren
|
||||
COPY . .
|
||||
|
||||
# Statisch kompilieren (wichtig für alpine)
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build -o bot main.go
|
||||
|
||||
# STAGE 2: Run
|
||||
FROM alpine:latest
|
||||
|
||||
# Zertifikate für Discord (HTTPS) installieren
|
||||
RUN apk --no-cache add ca-certificates
|
||||
|
||||
WORKDIR /root/
|
||||
|
||||
# Nur die Binary vom Builder kopieren
|
||||
COPY --from=builder /app/bot .
|
||||
# Falls du eine .env lokal nutzt (auf dem Server meist via Environment im Stack)
|
||||
# COPY .env .
|
||||
|
||||
# Startbefehl
|
||||
CMD ["./bot"]
|
||||
26
docker-compose.yaml
Normal file
26
docker-compose.yaml
Normal file
@@ -0,0 +1,26 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
app:
|
||||
image: alpine:latest # Oder ein spezielles "slim" / "alpine" Image deiner Wahl
|
||||
container_name: mein_sparsames_projekt
|
||||
restart: unless-stopped
|
||||
# Ressourcen-Limits verhindern, dass ein Memory Leak den Host killt
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: '0.50'
|
||||
memory: 256M
|
||||
reservations:
|
||||
memory: 64M
|
||||
logging:
|
||||
driver: "json-file"
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "3"
|
||||
networks:
|
||||
- discord_backend_net
|
||||
|
||||
networks:
|
||||
discord_backend_net:
|
||||
driver: bridge
|
||||
Reference in New Issue
Block a user