31 lines
670 B
Docker
31 lines
670 B
Docker
# STAGE 1: Build
|
|
FROM golang:1.25-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"] |