| # Stage 1: Build the application | |
| FROM golang:1.22 AS builder | |
| WORKDIR /app | |
| # Copy go.mod and go.sum and download dependencies | |
| COPY go.mod go.sum ./ | |
| RUN go mod download | |
| # Copy application code | |
| COPY . . | |
| # Build the application binary | |
| RUN go build -o go_jackett main.go | |
| # Stage 2: Create a minimal runtime container | |
| FROM debian:bullseye-slim | |
| WORKDIR /app | |
| # Install necessary runtime dependencies | |
| RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/* | |
| # Copy the built binary from the builder stage | |
| COPY --from=builder /app/go_jackett /app/ | |
| # Copy the .env file for configuration (if needed) | |
| COPY .env /app/.env | |
| # Expose the application port | |
| EXPOSE 3000 | |
| # Default command to run the application | |
| CMD ["./go_jackett"] | |