Skip to content

Instantly share code, notes, and snippets.

@karthiks
Created April 18, 2026 08:28
Show Gist options
  • Select an option

  • Save karthiks/1c3a8fd8b584cdee8b84878e88408e82 to your computer and use it in GitHub Desktop.

Select an option

Save karthiks/1c3a8fd8b584cdee8b84878e88408e82 to your computer and use it in GitHub Desktop.
Reference Implementation - Melchizedek as Persistent Memory
# Stage 1: "Borrow" the binaries from official images
FROM maven:3.9.6-eclipse-temurin-21-jammy AS maven_source
FROM eclipse-temurin:21-jdk-jammy AS java_source
# Stage 2: Final Development Image
FROM node:20-slim
# 1. Install critical system dependencies (optimized)
RUN apt-get update && apt-get install -y --no-install-recommends \
bash curl git vim jq ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# 2. Setup user and Workspace
RUN useradd -m developer
WORKDIR /workspace
# 3. Copy Java and Maven from the sources above
ENV JAVA_HOME=/opt/java/openjdk
ENV MAVEN_HOME=/usr/share/maven
COPY --from=java_source $JAVA_HOME $JAVA_HOME
COPY --from=maven_source $MAVEN_HOME $MAVEN_HOME
# 4. Add binaries to PATH (Java, Maven, and Claude)
ENV PATH="${JAVA_HOME}/bin:${MAVEN_HOME}/bin:/home/developer/.local/bin:${PATH}"
# 5. Setup User space securely (Local-First Strategy)
# Install Claude and Melchizedek as the developer user
USER developer
WORKDIR /home/developer
# Create a dedicated directory for MCP tools to avoid cluttering home
RUN mkdir -p /home/developer/mcp-tools && \
mkdir -p /home/developer/.local/bin
# Install melchizedek LOCALLY (No -g flag)
WORKDIR /home/developer/mcp-tools
RUN npm init -y && npm install melchizedek
# Install Claude CLI
RUN curl -fsSL https://claude.ai/install.sh | bash
# 6. MCP Registration using the DIRECT PATH
# This tells Claude exactly which node binary and script to use,
# bypassing shell PATH resolution issues.
RUN /home/developer/.local/bin/claude mcp add --scope user melchizedek -- \
node /home/developer/mcp-tools/node_modules/.bin/melchizedek-server
# 8. Optimized Git and Shell Config
# Note: Re-using the same layer for git config to keep image lean
RUN git config --global --add safe.directory /workspace && \
git config --global core.fileMode false && \
git config --global core.autocrlf true && \
echo 'alias cld="claude"' >> ~/.bashrc && \
echo 'alias cldw="claude -w"' >> ~/.bashrc
# 9. Environment Configuration
ENV TERM=xterm-256color \
COLORTERM=truecolor \
CONTAINER=docker
ENTRYPOINT ["bash"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment