33 lines
615 B
Docker
33 lines
615 B
Docker
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"] |