diff options
| author | Bobby <[email protected]> | 2025-04-13 18:55:56 +0530 |
|---|---|---|
| committer | Bobby <[email protected]> | 2025-04-13 18:55:56 +0530 |
| commit | 3f24195e763622f8dcf6c0eb22dd48b25052f68a (patch) | |
| tree | e9a981b497f1a33c382b568fceee90184f6890b2 | |
| parent | 6b486844a18fe8bf9b4ca4bdd3c44f45094e03e5 (diff) | |
| download | ai-3f24195e763622f8dcf6c0eb22dd48b25052f68a.tar.xz ai-3f24195e763622f8dcf6c0eb22dd48b25052f68a.zip | |
added dockerfile
| -rw-r--r-- | Dockerfile | 47 | ||||
| -rw-r--r-- | go.mod | 2 |
2 files changed, 48 insertions, 1 deletions
diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..38f59bd --- /dev/null +++ b/Dockerfile @@ -0,0 +1,47 @@ +# Build stage +FROM golang:1.24-alpine AS builder + +# Install git and build tools +RUN apk add --no-cache git gcc musl-dev + +# Set working directory +WORKDIR /app + +# Copy go.mod and go.sum first for better caching +COPY go.mod go.sum ./ +RUN go mod download + +# Copy the rest of the source code +COPY . . + +# Build the application +RUN CGO_ENABLED=1 GOOS=linux go build -a -o ai/ai ai/main.go + +# Runtime stage +FROM alpine:3.21 + +# Set working directory +WORKDIR /app + +# Install runtime dependencies +RUN apk add --no-cache ffmpeg python3 py3-pip opus libopus-dev ca-certificates && \ + pip3 install --no-cache-dir yt-dlp && \ + mkdir -p /app/temp + +# Copy the binary from the builder stage +COPY --from=builder /app/ai/ai . + +# Copy environment variables file +# Note: You can also use CapRover environment variables instead +COPY .env.example .env + +# Expose port 80 for CapRover health checks +# The application doesn't need to use this port, it's just for health checks +EXPOSE 80 + +# Create a simple health check endpoint +RUN echo '#!/bin/sh\nwhile true; do echo -e "HTTP/1.1 200 OK\n\nOK" | nc -l -p 80; done' > /app/healthcheck.sh && \ + chmod +x /app/healthcheck.sh + +# Start both the health check service and the application +CMD /app/healthcheck.sh & ./ai
\ No newline at end of file @@ -5,11 +5,11 @@ go 1.24.1 require ( github.com/bwmarrin/discordgo v0.28.1 github.com/joho/godotenv v1.5.1 + layeh.com/gopus v0.0.0-20210501142526-1ee02d434e32 ) require ( github.com/gorilla/websocket v1.4.2 // indirect golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b // indirect golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 // indirect - layeh.com/gopus v0.0.0-20210501142526-1ee02d434e32 // indirect ) |
