|
| 1 | +FROM node:20-slim AS builder |
| 2 | + |
| 3 | +WORKDIR /hyperlane-monorepo |
| 4 | + |
| 5 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 6 | + git g++ make python3 python3-pip jq bash curl ca-certificates unzip \ |
| 7 | + && rm -rf /var/lib/apt/lists/* |
| 8 | + |
| 9 | +# Install Foundry (Linux binaries) - pinned version for reproducibility |
| 10 | +ARG FOUNDRY_VERSION |
| 11 | +ARG TARGETARCH |
| 12 | +SHELL ["/bin/bash", "-c"] |
| 13 | +RUN set -o pipefail && \ |
| 14 | + ARCH=$([ "$TARGETARCH" = "arm64" ] && echo "arm64" || echo "amd64") && \ |
| 15 | + curl --fail -L "https://github.com/foundry-rs/foundry/releases/download/${FOUNDRY_VERSION}/foundry_${FOUNDRY_VERSION}_linux_${ARCH}.tar.gz" | tar -xzC /usr/local/bin forge cast |
| 16 | +SHELL ["/bin/sh", "-c"] |
| 17 | + |
| 18 | +# Copy package.json first for corepack to read packageManager field |
| 19 | +COPY package.json ./ |
| 20 | +RUN corepack enable && corepack install |
| 21 | + |
| 22 | +# Copy pnpm config files |
| 23 | +COPY pnpm-lock.yaml pnpm-workspace.yaml ./ |
| 24 | + |
| 25 | +# Copy patches directory (required for pnpm install) |
| 26 | +COPY patches ./patches |
| 27 | + |
| 28 | +# Copy only the packages needed for ccip-server |
| 29 | +COPY typescript/ccip-server/package.json ./typescript/ccip-server/ |
| 30 | +COPY typescript/deploy-sdk/package.json ./typescript/deploy-sdk/ |
| 31 | +COPY typescript/sdk/package.json ./typescript/sdk/ |
| 32 | +COPY typescript/provider-sdk/package.json ./typescript/provider-sdk/ |
| 33 | +COPY typescript/utils/package.json ./typescript/utils/ |
| 34 | +COPY typescript/cosmos-sdk/package.json ./typescript/cosmos-sdk/ |
| 35 | +COPY typescript/cosmos-types/package.json ./typescript/cosmos-types/ |
| 36 | +COPY typescript/radix-sdk/package.json ./typescript/radix-sdk/ |
| 37 | +COPY typescript/tsconfig/package.json ./typescript/tsconfig/ |
| 38 | +COPY typescript/eslint-config/package.json ./typescript/eslint-config/ |
| 39 | +COPY solidity/package.json ./solidity/ |
| 40 | +COPY solhint-plugin/package.json ./solhint-plugin/ |
| 41 | +COPY starknet/package.json ./starknet/ |
| 42 | + |
| 43 | +# Copy prisma schema before install (needed for postinstall prisma generate) |
| 44 | +COPY typescript/ccip-server/prisma ./typescript/ccip-server/prisma |
| 45 | + |
| 46 | +# Set dummy DATABASE_URL for prisma generate during install (actual URL provided at runtime) |
| 47 | +ENV DATABASE_URL="postgresql://placeholder:placeholder@localhost:5432/placeholder" |
| 48 | + |
| 49 | +RUN pnpm install --frozen-lockfile |
| 50 | + |
| 51 | +# Run prisma generate after install (needed to generate Prisma client) |
| 52 | +RUN pnpm --filter @hyperlane-xyz/ccip-server prisma generate |
| 53 | + |
| 54 | +# Copy source files |
| 55 | +COPY turbo.json ./ |
| 56 | +COPY typescript/ccip-server ./typescript/ccip-server |
| 57 | +COPY typescript/deploy-sdk ./typescript/deploy-sdk |
| 58 | +COPY typescript/sdk ./typescript/sdk |
| 59 | +COPY typescript/provider-sdk ./typescript/provider-sdk |
| 60 | +COPY typescript/utils ./typescript/utils |
| 61 | +COPY typescript/cosmos-sdk ./typescript/cosmos-sdk |
| 62 | +COPY typescript/cosmos-types ./typescript/cosmos-types |
| 63 | +COPY typescript/radix-sdk ./typescript/radix-sdk |
| 64 | +COPY typescript/tsconfig ./typescript/tsconfig |
| 65 | +COPY typescript/eslint-config ./typescript/eslint-config |
| 66 | +COPY solidity ./solidity |
| 67 | +COPY solhint-plugin ./solhint-plugin |
| 68 | +COPY starknet ./starknet |
| 69 | + |
| 70 | +# Build the ccip-server |
| 71 | +RUN pnpm turbo run build --filter=@hyperlane-xyz/ccip-server |
| 72 | + |
| 73 | +# Create standalone deployment with resolved dependencies (no symlinks) |
| 74 | +# --legacy flag required for pnpm v10+ without inject-workspace-packages |
| 75 | +RUN pnpm --filter @hyperlane-xyz/ccip-server deploy --legacy --prod /app |
| 76 | + |
| 77 | +# Copy generated Prisma client to dist (TypeScript doesn't copy non-TS files) |
| 78 | +# Note: Prisma outputs to src/generated/prisma/ (custom path), not node_modules/.prisma |
| 79 | +RUN cp -r /app/src/generated /app/dist/generated |
| 80 | + |
| 81 | +# Production stage - Debian slim for Prisma native binary compatibility |
| 82 | +FROM node:20-slim AS runner |
| 83 | + |
| 84 | +WORKDIR /app |
| 85 | + |
| 86 | +RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates \ |
| 87 | + && rm -rf /var/lib/apt/lists/* |
| 88 | + |
| 89 | +# Copy the deployed standalone package |
| 90 | +COPY --from=builder /app ./ |
| 91 | + |
| 92 | +# Copy prisma schema for migrations |
| 93 | +COPY --from=builder /hyperlane-monorepo/typescript/ccip-server/prisma ./prisma |
| 94 | + |
| 95 | +# Environment variables |
| 96 | +ENV NODE_ENV=production |
| 97 | +ENV LOG_LEVEL=info |
| 98 | +ENV SERVER_PORT=3000 |
| 99 | + |
| 100 | +# Expose ports |
| 101 | +EXPOSE 3000 |
| 102 | +EXPOSE 9090 |
| 103 | + |
| 104 | +# Run the ccip-server |
| 105 | +CMD ["node", "dist/server.js"] |
0 commit comments