|
| 1 | +# Multi-stage build for ARM64 (AWS Bedrock requirement) |
| 2 | +# MUST build from astack root directory: |
| 3 | +# cd /Users/archer/a-github/astack && docker build --platform linux/arm64 -f examples/agent-in-aws-bedrock-agent-core/Dockerfile -t IMAGE_NAME . |
| 4 | + |
| 5 | +FROM node:18-alpine AS builder |
| 6 | + |
| 7 | +WORKDIR /app |
| 8 | + |
| 9 | +# Copy workspace files from root |
| 10 | +COPY package.json pnpm-lock.yaml pnpm-workspace.yaml turbo.json tsconfig.json ./ |
| 11 | +COPY packages ./packages |
| 12 | +COPY examples/agent-in-aws-bedrock-agent-core ./examples/agent-in-aws-bedrock-agent-core |
| 13 | + |
| 14 | +# Install pnpm and dependencies |
| 15 | +RUN corepack enable pnpm && \ |
| 16 | + pnpm install --frozen-lockfile --registry=https://registry.npmmirror.com |
| 17 | + |
| 18 | +# Build all packages then the example |
| 19 | +RUN pnpm build && \ |
| 20 | + cd examples/agent-in-aws-bedrock-agent-core && \ |
| 21 | + pnpm build |
| 22 | + |
| 23 | +# Production stage |
| 24 | +FROM node:18-alpine |
| 25 | + |
| 26 | +WORKDIR /app |
| 27 | + |
| 28 | +# Copy workspace structure to maintain proper module resolution |
| 29 | +COPY --from=builder /app/package.json /app/pnpm-lock.yaml /app/pnpm-workspace.yaml ./ |
| 30 | +COPY --from=builder /app/node_modules ./node_modules |
| 31 | +COPY --from=builder /app/packages ./packages |
| 32 | +COPY --from=builder /app/examples/agent-in-aws-bedrock-agent-core ./examples/agent-in-aws-bedrock-agent-core |
| 33 | + |
| 34 | +# Set working directory to the example |
| 35 | +WORKDIR /app/examples/agent-in-aws-bedrock-agent-core |
| 36 | + |
| 37 | +# Expose port 8080 |
| 38 | +EXPOSE 8080 |
| 39 | + |
| 40 | +# Environment variables |
| 41 | +ENV NODE_ENV=production |
| 42 | +ENV PORT=8080 |
| 43 | +ENV HOST=0.0.0.0 |
| 44 | + |
| 45 | +# Health check |
| 46 | +HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ |
| 47 | + CMD node -e "require('http').get('http://localhost:8080/health', (r) => process.exit(r.statusCode === 200 ? 0 : 1))" |
| 48 | + |
| 49 | +# Run server |
| 50 | +CMD ["node", "dist/server.js"] |
0 commit comments