FROM node:22-alpine

WORKDIR /app

# Install build dependencies
RUN apk add --no-cache git

# Clone repository into current directory
RUN git clone https://github.com/brave/brave-search-mcp-server.git /tmp/brave-mcp && \
    cp -r /tmp/brave-mcp/* . && \
    rm -rf /tmp/brave-mcp

# Install dependencies and build
RUN npm ci && npm run build

# Remove git since we don't need it in runtime
RUN apk del git

# Remove dev dependencies and build artifacts we don't need
RUN npm prune --production

# Expose the MCP server port
EXPOSE 3000

# Start the MCP server
CMD ["npm", "start"]
