Group
Source:
src/Railway/Group.ts
A Railway.Group organizes services, databases, volumes, and buckets on
the project canvas. IaC parity with group("Backend", [api, worker, db]).
Groups have no dedicated create/delete mutation. Alchemy writes
EnvironmentConfig.groups (and services[id].groupId) via
environmentPatchCommit, matching Railway’s own IaC compiler. Volume
membership is observed from environment.canvasGroupRefs. When Railway
does not persist a first-class Group id, the resource still records
member service/volume/bucket ids. canvasViewMerge /
canvasViewMergePreview copy canvas layout between environments.
Create a Group
Section titled “Create a Group”Pass a Project and the members to group. Alchemy generates a unique name unless you pass one.
const site = yield* Railway.Project("Site");const api = yield* Railway.Service("Api", { project: site, image: "hashicorp/http-echo",});const worker = yield* Railway.Service("Worker", { project: site, image: "hashicorp/http-echo",});const backend = yield* Railway.Group("Backend", { project: site, resources: [api, worker],});Environment
Section titled “Environment”Defaults to the Project’s primary environment. Pass a
Railway.Environment (or { environmentId }) to target another one.
const staging = yield* Railway.Environment("Staging", { project: site });const backend = yield* Railway.Group("Backend", { project: site, environment: staging, resources: [api],});Databases, volumes, and buckets
Section titled “Databases, volumes, and buckets”Postgres/Redis/MySQL/Mongo group as services (serviceId). Volumes and
buckets are accepted as members (volumeId / bucketId).
const db = yield* Railway.Postgres("Db", { project: site });const backend = yield* Railway.Group("Backend", { project: site, resources: [api, db],});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 Api = Railway.Service("Api", { project: Site, image: "hashicorp/http-echo",});export const Backend = Railway.Group("Backend", { project: Site, resources: [Api],});