50 lines
840 B
Docker
50 lines
840 B
Docker
# Build stage
|
|
FROM golang:1.24-alpine AS builder
|
|
|
|
# Install build dependencies
|
|
RUN apk add --no-cache git
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Copy go mod files
|
|
COPY go.mod go.sum ./
|
|
|
|
# Download dependencies
|
|
RUN go mod download
|
|
|
|
# Copy source code
|
|
COPY . .
|
|
|
|
# Build the application
|
|
RUN CGO_ENABLED=0 GOOS=linux go build -o mcpbox ./cmd/mcpbox
|
|
|
|
# Final stage
|
|
FROM ubuntu:22.04
|
|
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
|
|
|
# Install runtime dependencies
|
|
RUN apt-get update && apt-get install -y ca-certificates tzdata docker.io bash wget curl
|
|
|
|
# Create non-root user
|
|
#RUN adduser -D -g '' appuser
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Copy binary from builder
|
|
COPY --from=builder /app/mcpbox .
|
|
|
|
# Use non-root user
|
|
#USER appuser
|
|
|
|
# Expose port
|
|
EXPOSE 8080
|
|
|
|
# Set entrypoint
|
|
ENTRYPOINT ["/app/mcpbox"]
|
|
|
|
# Default command
|
|
CMD ["-addr", ":8080"]
|