Environment
Source:
src/Railway/ProjectEnvironment.ts
A Railway.Environment is an extra deploy environment under a Project (staging, preview, …). The production environment is created with the Project — do not recreate it as an Environment resource.
Create an extra environment
Section titled “Create an extra environment”Alchemy generates a unique name unless you pass one. Production is
already on the Project as environmentId.
const site = yield* Railway.Project("Site");const staging = yield* Railway.Environment("Staging", { project: site,});A stable name
Section titled “A stable name”Pass name when you need a stable environment name (staging).
Changing it later updates the environment in place.
const staging = yield* Railway.Environment("Staging", { project: site, name: "staging",});Fork from production
Section titled “Fork from production”sourceEnvironmentId copies services, volumes, configuration, and
variables from another environment. Create-only.
const staging = yield* Railway.Environment("Staging", { project: site, sourceEnvironmentId: site.environmentId,});Module-scope declarations
Section titled “Module-scope declarations”Declare the Project once. Pass it into every child. Resource-valued props accept the resource or an Effect producing it.
import * as Railway from "alchemy/Railway";
export const Site = Railway.Project("Site");export const Staging = Railway.Environment("Staging", { project: Site,});