Cloudflare 배포

가입

CLI 설치

bun add -d wrangler@latest

개발모드 전용으로 설치한다.

Astro에 어댑터 설치

bun x astro add cloudflare --yes

bun add @astrojs/cloudflare@^13.3.0 wrangler@^4.87.0 설치해줌.
wrangler.jsonc 를 작성해줌
package.json 의 스크립트 영역을 수정해줌 "generate-types": "wrangler types" 추가됨
astro.config.mjs 수정해줌 adapter: cloudflare(), 추가됨
tsconfig.json 수정해줌. "./worker-configuration.d.ts" 참조함

CI/CD로 배포

  1. Workers Builds를 사용함.
  2. Cloudflare 대시보드에서 Compute > Workers & Pages 로 이동 후 Create application
  3. Connect GitHub 연결 후 Continue with GitHub
  4. Select a repository 에서 배포할 프로젝트를 선택한다
  5. Set up your application 에서 빌드 커맨드랑 배포 커맨드를 확인한다. bun 또는 npm
  6. 우상단 Visit 를 눌러 배포된 사이트를 확인한다.

env or 환경변수 설정