|
| 1 | +FROM amazonlinux:2023 |
| 2 | + |
| 3 | +RUN yum update -y \ |
| 4 | + && yum install -y \ |
| 5 | + curl-minimal clang tar zip unzip python3 git xz \ |
| 6 | + make wget gcc gcc-c++ \ |
| 7 | + && yum clean all |
| 8 | + |
| 9 | +# Install Node.js and npm |
| 10 | +RUN curl -fsSL https://rpm.nodesource.com/setup_18.x | bash - \ |
| 11 | + && yum install -y nodejs \ |
| 12 | + && node -v && npm -v |
| 13 | + |
| 14 | +# Setup Rust toolchain |
| 15 | +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > /tmp/rustup.sh \ |
| 16 | + && chmod +x /tmp/rustup.sh \ |
| 17 | + && /tmp/rustup.sh -y \ |
| 18 | + && . ~/.profile; rustup component add llvm-tools-preview rust-src |
| 19 | + |
| 20 | +# Install cargo-fuzz |
| 21 | +RUN . ~/.profile; cargo install cargo-fuzz |
| 22 | + |
| 23 | +# Install Lean |
| 24 | +RUN wget https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh && sh elan-init.sh -y --default-toolchain none |
| 25 | + |
| 26 | +# Install protoc |
| 27 | +RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v29.0/protoc-29.0-linux-x86_64.zip && unzip protoc-29.0-linux-x86_64.zip && rm protoc-29.0-linux-x86_64.zip |
| 28 | + |
| 29 | +ENV PATH="/root/.cargo/bin:${PATH}" |
| 30 | + |
| 31 | +ENV CEDAR_SPEC_ROOT=/opt/src/cedar-deps |
| 32 | + |
| 33 | +# Clone `cedar` repositories |
| 34 | +WORKDIR $CEDAR_SPEC_ROOT |
| 35 | +RUN git clone --depth 1 https://github.com/cedar-policy/cedar-spec |
| 36 | + |
| 37 | +# Build CLI and Lean library |
| 38 | +WORKDIR $CEDAR_SPEC_ROOT/cedar-spec/ |
| 39 | +RUN source /root/.profile \ |
| 40 | + && cd cedar-lean-ffi \ |
| 41 | + && source ./set_env_vars.sh \ |
| 42 | + && ./build_lean_lib.sh \ |
| 43 | + && cd ../cedar-lean-cli \ |
| 44 | + && cargo build \ |
| 45 | + && cargo install --path . |
| 46 | + |
| 47 | +# Create a setup script that will be sourced in .bashrc |
| 48 | +RUN echo '#!/bin/bash' > /root/setup_env.sh \ |
| 49 | + && echo 'source /root/.profile' >> /root/setup_env.sh \ |
| 50 | + && echo "cd $CEDAR_SPEC_ROOT/cedar-spec/cedar-lean-ffi" >> /root/setup_env.sh \ |
| 51 | + && echo 'source ./set_env_vars.sh' >> /root/setup_env.sh \ |
| 52 | + && chmod +x /root/setup_env.sh |
| 53 | + |
| 54 | +# Add the setup script to .bashrc so it runs automatically |
| 55 | +RUN echo 'source /root/setup_env.sh' >> /root/.bashrc |
| 56 | + |
| 57 | +# Download cvc5 based on architecture |
| 58 | +RUN arch=$(uname -m) && \ |
| 59 | + if [ "$arch" = "aarch64" ] || [ "$arch" = "arm64" ]; then \ |
| 60 | + curl -LO https://github.com/cvc5/cvc5/releases/download/cvc5-1.2.1/cvc5-Linux-arm64-static.zip && \ |
| 61 | + unzip cvc5-Linux-arm64-static.zip && \ |
| 62 | + export CVC5_DIR="cvc5-Linux-arm64-static"; \ |
| 63 | + else \ |
| 64 | + curl -LO https://github.com/cvc5/cvc5/releases/download/cvc5-1.2.1/cvc5-Linux-x86_64-static.zip && \ |
| 65 | + unzip cvc5-Linux-x86_64-static.zip && \ |
| 66 | + export CVC5_DIR="cvc5-Linux-x86_64-static"; \ |
| 67 | + fi && \ |
| 68 | + echo "export CVC5=$CEDAR_SPEC_ROOT/cedar-spec/$CVC5_DIR/bin/cvc5" >> /root/setup_env.sh |
| 69 | + |
| 70 | +ENV MCP_ROOT=/opt/src/mcp |
| 71 | +COPY mcp/. $MCP_ROOT |
| 72 | + |
| 73 | +WORKDIR $MCP_ROOT |
| 74 | +RUN npm install && npm run build |
| 75 | + |
| 76 | +# Set the working directory to mcp |
| 77 | +WORKDIR $MCP_ROOT |
| 78 | + |
| 79 | +# Use a simple entrypoint that keeps the container running |
| 80 | +ENV NODE_ENV=production |
| 81 | +ENTRYPOINT ["/bin/bash", "-c", "source /root/setup_env.sh && exec node /opt/src/mcp/dist/server.js"] |
0 commit comments