45 lines
963 B
Docker
45 lines
963 B
Docker
FROM golang:1.22-alpine AS builder
|
|
|
|
# Install build dependencies
|
|
RUN apk add --no-cache git
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Copy go mod and sum files
|
|
COPY go.mod go.sum ./
|
|
|
|
# Download dependencies
|
|
RUN go mod download
|
|
|
|
# Copy source code
|
|
COPY *.go ./
|
|
|
|
# Build the application
|
|
RUN CGO_ENABLED=0 GOOS=linux go build -o discord-europa-fm
|
|
|
|
# Use a smaller base image for the final stage
|
|
FROM alpine:latest
|
|
|
|
# Install ffmpeg
|
|
RUN apk add --no-cache ffmpeg ca-certificates
|
|
|
|
# Copy the built executable
|
|
WORKDIR /app
|
|
COPY --from=builder /app/discord-europa-fm .
|
|
|
|
# Environment variables
|
|
ENV DISCORD_TOKEN="" \
|
|
DEBUG="" \
|
|
GUILD_ID=""
|
|
|
|
# Run the bot
|
|
CMD if [ -n "$DEBUG" ] && [ -n "$GUILD_ID" ]; then \
|
|
./discord-europa-fm -debug -guild "$GUILD_ID"; \
|
|
elif [ -n "$DEBUG" ]; then \
|
|
./discord-europa-fm -debug; \
|
|
elif [ -n "$GUILD_ID" ]; then \
|
|
./discord-europa-fm -guild "$GUILD_ID"; \
|
|
else \
|
|
./discord-europa-fm; \
|
|
fi
|