Netlify에 Mastra 배포
사용@mastra/deployer-netlifyNetlify에 Mastra 서버를 배포합니다. 배포자는 코드를 번들로 묶고.netlifyNetlify를 준수하는 디렉토리프레임워크 API, 배포 준비가 완료되었습니다. 서버리스 기능(기본값) 또는 다음과 같이 배포할 수 있습니다.가장자리 기능더 낮은 대기 시간과 더 긴 실행 시간을 위해.
이 가이드에서는Mastra server. If you're using a server adapter or web framework, 해당 프레임워크에서 평소 사용하는 방식으로 배포하세요.
시작하기 전에시작하기 전에에 대한 직접 링크
당신은Mastra application and a Netlify account.
Netlify Functions는 임시 파일 시스템을 사용하므로 구성하는 모든 스토리지(관측성 스토리지 포함)는 외부에서 호스팅되어야 합니다. 당신이 사용하는 경우LibSQLStore 를 파일 URL과 함께 사용하고 있다면 원격으로 호스팅되는 데이터베이스로 전환하세요.
설치설치에 대한 직접 링크
추가@mastra/deployer-netlify package to your project:
- npm
- pnpm
- Yarn
- Bun
npm install @mastra/deployer-netlify@latest
pnpm add @mastra/deployer-netlify@latest
yarn add @mastra/deployer-netlify@latest
bun add @mastra/deployer-netlify@latest
수입NetlifyDeployer 를 설치하고 Mastra 구성에서 deployer로 설정하세요:
import { Mastra } from '@mastra/core'
import { NetlifyDeployer } from '@mastra/deployer-netlify'
export const mastra = new Mastra({
deployer: new NetlifyDeployer(),
})
대신 에지 기능으로 배포하려면 다음을 전달하세요.{ target: 'edge' }:
import { Mastra } from '@mastra/core'
import { NetlifyDeployer } from '@mastra/deployer-netlify'
export const mastra = new Mastra({
deployer: new NetlifyDeployer({
target: 'edge',
}),
})
Edge 기능은 사용자에게 가장 가까운 Edge의 Deno에서 실행됩니다. 하드 실행 시간 제한이 없으므로(CPU 시간 제한만 있음) 장기 실행 AI Workflow에 더 적합합니다. 참조constructor options for details.
만들기netlify.toml 파일을 프로젝트 루트에 다음 내용으로 생성하세요:
[build]
command = "mastra build"
배포배포에 대한 직접 링크
프로젝트를 설정한 후 선택한 원격 Git 공급자(예: GitHub)에 푸시하세요.
저장소를 Netlify에 연결하세요. 설정 과정에서 Netlify는 귀하의
netlify.tomlfile and set the build command tomastra build.노트애플리케이션을 실행하는 데 필요한 환경 변수(예:model provider API key).
준비가 되었으면Deploy 버튼을 클릭하고 첫 번째 배포가 완료될 때까지 기다립니다. 함수 하나가 배포되었다는 메시지가 표시됩니다.
배포를 확인하세요.
https://<random-slug>.netlify.app/api/agents, Agent의 JSON 목록이 반환되어야 합니다.이후Mastra server prefixes every API endpoint with
/api, 요청할 때 URL에 이를 추가해야 합니다.정보Netlify 기능은 일반적으로 다음 위치에 배포됩니다.
https://<random-slug>.netlify.app/.netlify/functions/api. TheNetlifyDeployerredirects any request from/*to/.netlify/functions/api/:splat, so you don't need to include the.netlify/functionsprefix in your URLs.이제 HTTP를 통해 Mastra 엔드포인트를 호출할 수 있습니다.
경고설정authentication before exposing your endpoints publicly.