Skip to content

Latest commit

 

History

History
106 lines (85 loc) · 4.27 KB

kinsta.mdx

File metadata and controls

106 lines (85 loc) · 4.27 KB
title description type i18nReady
AstroサイトをKinstaのアプリケーションホスティングにデプロイする
KinstaのアプリケーションホスティングにAstroサイトをデプロイする方法。
deploy
true

import { Steps } from '@astrojs/starlight/components';

Kinstaのアプリケーションホスティングを利用して、クラウドホスティング上でAstroサイトをホストできます。

Astroプロジェクトの設定

静的ホスティング

:::tip[例をお探しですか?] Astroのための公式Kinstaアプリケーションホスティングスタータープロジェクトをチェックしてみてください! :::

Kinstaのアプリケーションホスティングであなたのプロジェクトをホストするには、次のことが必要です。

  • package.jsonnameフィールドを含めます。(これは何でもよく、デプロイには影響しません。)
  • package.jsonbuildスクリプトを含めます。(あなたのAstroプロジェクトは既にこれを含んでいるはずです。)
  • serveパッケージをインストールし、startスクリプトをserve dist/に設定します。

以下は、package.jsonファイルに必要な行です。

{
  "name": "anything", // これは必須ですが、値はなんでも良いです。
  "scripts": {
    "dev": "astro dev",
    "start": "serve dist/",
    "build": "astro build",
    "preview": "astro preview",
    "astro": "astro"
  },
  "dependencies": {
    "astro": "^2.2.0",
    "serve": "^14.0.1"
  },
}

SSR

:::tip[例をお探しですか?] Astro SSRのための公式Kinstaアプリケーションホスティングスタータープロジェクトをチェックしてみてください! :::

Kinstaのアプリケーションホスティングであなたのプロジェクトをホストするには、次のことが必要です。

  • package.jsonnameフィールドを含めます。(これは何でもよく、デプロイには影響しません。)
  • package.jsonbuildスクリプトを含めます。(あなたのAstroプロジェクトは既にこれを含んでいるはずです。)
  • astrojs/nodeパッケージをインストールし、startスクリプトをnode ./dist/server/entry.mjsに設定します。
  • astro.config.mjs@astrojs/nodeを使用し、host: trueを使用するように設定します。

以下は、package.jsonファイルに必要な行です。

{
  "name": "anything", // これは必須ですが、値はなんでも良いです。
  "scripts": {
    "dev": "astro dev",
    "start": "node ./dist/server/entry.mjs",
    "build": "astro build",
    "preview": "astro preview",
    "astro": "astro"
  },
  "dependencies": {
    "astro": "^2.2.0",
    "@astrojs/node": "^5.1.1"
  },
}

以下は、astro.config.mjsファイルに必要な行です。

  import { defineConfig } from 'astro/config';
  import node from "@astrojs/node";

  export default defineConfig({
    output: 'server',
    adapter: node({
      mode: "standalone"
    }),
    server: {
      host: true
    }
  });

デプロイ方法

プロジェクトのGitHubリポジトリが接続されると、MyKinsta管理パネルでKinstaのアプリケーションホスティングへの手動デプロイをトリガーできます。また、管理パネルで自動デプロイを設定できます。

新しいKinstaアプリケーションの設定

1. [MyKinsta](https://my.kinsta.com/)管理パネルにアクセスします。
  1. アプリケーションタブに移動します。

  2. GitHubリポジトリを接続します。

  3. アプリケーション > アプリケーションを追加ボタンを押します。

  4. ウィザードの手順に従ってください。

  5. アプリケーションがデプロイされます。