Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
.git
55 changes: 55 additions & 0 deletions .github/workflows/deploy-server-og-evm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Deploy to AWS

on:
workflow_dispatch:

jobs:
build-and-deploy:
name: Build and Deploy
runs-on: ubuntu-latest
environment: production

env:
ECS_CLUSTER: MemChat
ECS_SERVICE: memchat-facilitator-x402-og-evm
ECR_REPOSITORY: memchat/facilitator-x402-og-evm
IMAGE_TAG: latest
AWS_REGION: us-east-2

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2

- name: Build, tag, and push image to Amazon ECR
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "Docker image successfully pushed to ECR!"

- name: Force new deployment on Amazon ECS
run: |
aws ecs update-service --cluster $ECS_CLUSTER --service $ECS_SERVICE --force-new-deployment > /dev/null
echo "New ECS deployment started!"

- name: AWS LINKS TO VIEW DEPLOYMENT
run: |
echo "View deployment progress here - https://us-east-2.console.aws.amazon.com/ecs/v2/clusters/MemChat/services/facilitator-x402-og-evm/tasks?region=us-east-2"

- name: Wait for ECS service to stabilize
run: |
echo "Waiting for ECS service to stabilize..."
aws ecs wait services-stable --cluster $ECS_CLUSTER --services $ECS_SERVICE
echo "✅ ECS service is now stable and deployment is complete!"
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,8 @@ vite.config.ts.timestamp-*
.vite/

# walrus config
walrus_config
walrus_config

.DS_Store

*.turbo/
60 changes: 36 additions & 24 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,49 +1,61 @@
# Build stage
FROM node:20-alpine AS builder

ARG PNPM_VERSION=10.7.0


RUN npm install -g pnpm@${PNPM_VERSION} && \
apk add --no-cache python3 make g++

WORKDIR /app

ARG NODE_OPTIONS=--max-old-space-size=3048
ARG NODE_ENV=production
# Copy root workspace files
COPY pnpm-lock.yaml pnpm-workspace.yaml package.json ./

COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
# Copy all package.json files to optimize layer caching for pnpm install
COPY typescript/package.json ./typescript/
COPY typescript/packages/x402/package.json ./typescript/packages/x402/

COPY typescript/packages/core/package.json ./typescript/packages/core/
COPY typescript/packages/extensions/package.json ./typescript/packages/extensions/
COPY typescript/packages/mcp/package.json ./typescript/packages/mcp/
COPY typescript/packages/mechanisms/evm/package.json ./typescript/packages/mechanisms/evm/
COPY typescript/packages/mechanisms/svm/package.json ./typescript/packages/mechanisms/svm/
COPY typescript/packages/http/next/package.json ./typescript/packages/http/next/
COPY typescript/packages/http/express/package.json ./typescript/packages/http/express/
COPY typescript/packages/http/fetch/package.json ./typescript/packages/http/fetch/
COPY typescript/packages/http/hono/package.json ./typescript/packages/http/hono/
COPY typescript/packages/http/axios/package.json ./typescript/packages/http/axios/
COPY typescript/packages/http/paywall/package.json ./typescript/packages/http/paywall/

# Install dependencies
RUN pnpm install --frozen-lockfile

# Copy source code
COPY . .

WORKDIR /app/typescript/packages/x402
RUN pnpm build

WORKDIR /app
RUN pnpm build

FROM node:20-alpine
# Build all packages
# We assume 'pnpm build' at root builds all workspace packages
RUN pnpm --filter @x402/core build && \
pnpm --filter @x402/evm build && \
pnpm --filter @x402/svm build && \
pnpm --filter @x402/extensions build && \
pnpm build

ARG PNPM_VERSION=10.7.0
# Remove development dependencies
RUN pnpm prune --prod

RUN npm install -g pnpm@${PNPM_VERSION}
# Production stage
FROM node:20-alpine AS runner

WORKDIR /app

ENV NODE_ENV=production

COPY --from=builder /app/package.json /app/pnpm-lock.yaml /app/pnpm-workspace.yaml ./
COPY --from=builder /app/typescript/package.json ./typescript/
COPY --from=builder /app/typescript/packages/x402/package.json ./typescript/packages/x402/

RUN pnpm install --prod --frozen-lockfile

# Copy built files and necessary node_modules
COPY --from=builder /app/package.json ./package.json
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/typescript/packages/x402/dist ./typescript/packages/x402/dist
# Include workspace packages if needed at runtime
COPY --from=builder /app/typescript/packages ./typescript/packages

EXPOSE 3002

CMD ["pnpm", "start"]
CMD ["node", "dist/all_networks.js"]

Loading