使用 Railway 部署你的 Astro 网站
Railway 是一个部署平台,旨在通过统一的开发者体验,简化你的基础架构堆栈(从服务器到可观测性)。
¥Railway is a deployment platform built to simplify your infrastructure stack from servers to observability with a unified developer experience.
本指南介绍如何使用 Web 界面或 Railway CLI 工具将 Astro 静态站点部署到 Railway。
¥This guide is for deploying an Astro static site to Railway using either the web interface or Railway CLI tool.
¥Project Configuration
Railway 的默认构建系统 Railpack 会自动将你的 Astro 项目构建为静态网站。
¥Railway’s default build system, Railpack, automatically builds your Astro project as a static site.
通过 Railway 模板部署
Section titled “通过 Railway 模板部署”¥Deploy via a Railway template
如果你还没有 Astro 项目,并且是从头开始:
¥If you do not already have an Astro project, and are starting from scratch:
-
Go to the Astro template on Railway: railway.com/deploy/astro-starter.
-
Click “Deploy Now” and sign in with your GitHub account to authorize Railway. This will deploy the Astro template into your new Railway account.
-
Eject the service code into your own Github repository by following this guide. This will allow you to keep the repo deployed but customize it with your own code.
通过 Web 界面部署
Section titled “通过 Web 界面部署”¥Deploy via the web interface
如果你有一个想要部署的现有 Astro 项目,但还没有 Railway 账户:
¥If you have an existing Astro project you would like to deploy but not a Railway account yet:
-
Create a Railway account and sign in.
-
From the Railway dashboard, create a new project.
-
Select the option to deploy from a GitHub repository, and select your Astro project.
-
Generate or add a custom domain from your project’s network settings.
通过 Railway CLI 部署
Section titled “通过 Railway CLI 部署”¥Deploy via Railway CLI
如果你有一个想要部署的现有 Astro 项目和一个现有的 Railway 账户:
¥If you have an existing Astro project you would like to deploy and an existing Railway account:
-
Install the Railway CLI tool.
-
Login with the command
railway login. -
From within your Astro project, run
railway initand choose a workspace and project name. -
Run
railway upto deploy your project on Railway. -
Run
railway domainto generate a Railway provided service domain.
¥Official Resources
¥Community Resources
¥How to host an Astro site on Railway