Skip to content
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
00b0ad6
Initial impl
cprecioso Sep 19, 2025
717acb5
Format
cprecioso Sep 22, 2025
7a84c2a
Simpler logic
cprecioso Sep 22, 2025
f5c05cf
Correct docs
cprecioso Sep 22, 2025
45862be
Add changelog
cprecioso Sep 22, 2025
c276d57
Revert "Simpler logic"
cprecioso Sep 22, 2025
dee1cbc
Custom database logic
cprecioso Sep 22, 2025
984c58a
Fixes
cprecioso Sep 23, 2025
0d82d87
Change changelog
cprecioso Sep 26, 2025
3c76921
Merge branch 'main' into image-arg-for-deploy-railway
cprecioso Sep 26, 2025
7798922
Update web/docs/deployment/deployment-methods/wasp-deploy/railway.md
cprecioso Sep 26, 2025
8c9c0dd
Update web/docs/deployment/deployment-methods/wasp-deploy/railway.md
cprecioso Sep 26, 2025
4217d57
Update web/docs/deployment/deployment-methods/wasp-deploy/railway.md
cprecioso Sep 26, 2025
97ad6e9
Update web/docs/deployment/deployment-methods/wasp-deploy/railway.md
cprecioso Sep 26, 2025
5f66ed4
Update web/docs/deployment/deployment-methods/wasp-deploy/railway.md
cprecioso Sep 26, 2025
91b92db
Consistent description
cprecioso Sep 26, 2025
3d67589
Comment
cprecioso Sep 26, 2025
12a0177
Update waspc/packages/deploy/src/providers/railway/commands/setup/set…
cprecioso Sep 26, 2025
09b1f8e
Fix
cprecioso Sep 26, 2025
7d91499
Docs
cprecioso Sep 26, 2025
143d365
Make DB docs consistent between providers
cprecioso Sep 29, 2025
f23dfab
Consistent DB arg
cprecioso Sep 29, 2025
aeca0f1
More readable array
cprecioso Oct 8, 2025
c130a77
Use helper
cprecioso Oct 8, 2025
f38591d
Extract partial
cprecioso Oct 8, 2025
c682352
Merge branch 'main' into image-arg-for-deploy-railway
cprecioso Oct 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions waspc/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### 🎉 New Features

- You can now specify which PostgreSQL image to use in `wasp start db` with the `--db-image` argument. ([#3182](https://github.com/wasp-lang/wasp/pull/3182))
- You can now specify which PostgreSQL image to use in `wasp deploy railway` with the `--db-image` argument. ([#3184](https://github.com/wasp-lang/wasp/pull/3184))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, I'd list this as a feature :)

Btw, please bump the version in waspc.cabal to 0.18.1.
I haven't yet delieverd the post mortem and made my case for this, so just trust me bro :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will wait until we decided on the postmortem

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we decided we want to bump right away, does this make this comment actionable now?

Copy link
Member Author

@cprecioso cprecioso Oct 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did it on here since I don't want to mix concerns in the same PR, we can merge that one first
#3236


### 📖 Documentation

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import { CommonCmdOptions } from "../../DeploymentInstructions.js";
export interface DeployCmdOptions extends CommonCmdOptions {
skipClient?: boolean;
skipServer?: boolean;
existingProjectId: RailwayProjectId | null;
existingProjectId?: RailwayProjectId;
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ async function ensureRailwayProjectForDirectory({
railwayExe: RailwayCliExe;
projectName: RailwayProjectName;
waspProjectDir: WaspProjectDir;
existingProjectId: RailwayProjectId | null;
existingProjectId?: RailwayProjectId;
}): Promise<RailwayProject> {
const { status, project } = await getRailwayProjectStatus({
projectName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
} from "../../DeploymentInstructions.js";

export interface SetupCmdOptions extends CommonCmdOptions, SecretsOptions {
existingProjectId: RailwayProjectId | null;
workspace: string | null;
existingProjectId?: RailwayProjectId;
workspace?: string;
dbImage?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ async function setupRailwayProjectForDirectory({
railwayExe: RailwayCliExe;
projectName: RailwayProjectName;
waspProjectDir: WaspProjectDir;
existingProjectId: RailwayProjectId | null;
workspace: string | null;
existingProjectId?: RailwayProjectId;
workspace?: string;
}): Promise<RailwayProject> {
const { status, project } = await getRailwayProjectStatus({
projectName,
Expand Down Expand Up @@ -122,14 +122,42 @@ async function setupRailwayProjectForDirectory({

async function setupDb({
cmdOptions: options,
dbServiceName,
}: DeploymentInstructions<SetupCmdOptions>): Promise<void> {
waspSays("Setting up database");

const railwayCli = createCommandWithCwd(
options.railwayExe,
options.waspProjectDir,
);
await railwayCli(["add", "-d", "postgres"]);

if (options.dbImage) {
waspSays(`Using custom database image: ${options.dbImage}`);
// When using a custom database image, Railway doesn't automatically set the default
// Postgres-related environment variables, so we need to set them ourselves.
await railwayCli([
"add",
"--service",
dbServiceName,
"--image",
options.dbImage,
"--variables",
"POSTGRES_DB=railway",
"--variables",
"POSTGRES_USER=postgres",
"--variables",
"POSTGRES_PASSWORD=${{secret()}}",
"--variables",
"PORT=5432",
"--variables",
"PGDATA=/var/lib/postgresql/data/pgdata",
"--variables",
"DATABASE_URL=postgresql://${{POSTGRES_USER}}:${{POSTGRES_PASSWORD}}@${{RAILWAY_PRIVATE_DOMAIN}}:${{PORT}}/${{POSTGRES_DB}}",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd reuse the getRailwayEnvVarValueReference helper for these Railway env var references 😄

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I did it, but tbh I don't think we're winning much by using it, on the contrary making it more difficult to read the variable. Check it out and tell me what you think.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel it's more readable now because it's quite explicit about what's going on. Either way, I'd keep it consistent now with the other place where we use env var references - at least when we decide to refactor it, there won't be two different ways of doing things.

]);
} else {
// Use the default Railway Postgres template.
await railwayCli(["add", "-d", "postgres"]);
}
}

async function setupServer({
Expand Down
8 changes: 8 additions & 0 deletions waspc/packages/deploy/src/providers/railway/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ function makeRailwaySetupCommand(): Command {
"--workspace [workspace]",
"the Railway workspace to use if a new project needs to be created (if not provided, will ask interactively)",
)
.option(
"--db-image <dbImage>",
"custom Docker image for the PostgreSQL database",
)
.action(setupFn);
}

Expand Down Expand Up @@ -140,5 +144,9 @@ function makeRailwayLaunchCommand(): Command {
"--workspace [workspace]",
"the Railway workspace to use if a new project needs to be created (if not provided, will ask interactively)",
)
.option(
"--db-image <dbImage>",
"custom Docker image for the PostgreSQL database",
)
.action(launchFn);
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export async function initRailwayProject({
projectName: RailwayProjectName;
railwayExe: RailwayCliExe;
waspProjectDir: WaspProjectDir;
workspace: string | null;
workspace?: string;
}): Promise<RailwayProject> {
const railwayCli = createCommandWithCwd(railwayExe, waspProjectDir);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export async function getRailwayProjectStatus({
existingProjectId,
}: {
projectName: RailwayProjectName;
existingProjectId: RailwayProjectId | null;
existingProjectId?: RailwayProjectId;
waspProjectDir: WaspProjectDir;
railwayExe: RailwayCliExe;
}): Promise<
Expand Down
42 changes: 41 additions & 1 deletion web/docs/deployment/deployment-methods/wasp-deploy/railway.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ The project name is used as a base for your server and client service names on R
- `my-wasp-app-client`
- `my-wasp-app-server`

Railway doesn't allow setting the database service name using the Railway CLI. It will always be named `Postgres`.
Railway doesn't allow setting the database service name using the Railway CLI. It will always be named `Postgres`. This also applies when using the `--db-image` flag.

<LaunchCommandEnvVars />

Expand Down Expand Up @@ -94,6 +94,26 @@ wasp deploy railway setup <project-name>
wasp deploy railway deploy <project-name>
```

#### Using a custom PostgreSQL instance

By default, Wasp uses the standard PostgreSQL image provided by Railway when creating a new database for your app. However, if your application requires specific PostgreSQL extensions (e.g., PostGIS), you can specify a Docker image with a custom PostgreSQL installation, with the `--db-image <docker-image>` flag.

:::tip
You only need to specify the Docker image once, when first creating the app.
:::

```shell
# Use PostGIS:
wasp deploy railway launch my-wasp-app --db-image postgis/postgis
```

```shell
# Use pgvector:
wasp deploy railway launch my-wasp-app --db-image pgvector/pgvector:pg16
```

The service name will always be `Postgres`, regardless of the image used.

#### Explicitly providing the Railway project ID

By default, Wasp CLI tries to create a new Railway project named `<project-name>`. If you want to use an existing Railway project, pass its ID with `--existing-project-id` option:
Expand Down Expand Up @@ -192,6 +212,26 @@ The project name is used as a base for your server and client service names on R

Railway also creates a PostgreSQL database service named `Postgres`.

#### Using a custom PostgreSQL database

By default, Wasp uses the standard PostgreSQL image provided by Railway when creating a new database for your app. However, if your application requires specific PostgreSQL extensions (e.g., PostGIS), you can specify a Docker image with a custom PostgreSQL installation, with the `--db-image <docker-image>` flag.

:::tip
You only need to specify the Docker image once, when first creating the app.
:::

```shell
# Use PostGIS:
wasp deploy railway launch my-wasp-app --db-image postgis/postgis
```

```shell
# Use pgvector:
wasp deploy railway launch my-wasp-app --db-image pgvector/pgvector:pg16
```

The service name will always be `Postgres`, regardless of the image used.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If these texts are repeated verbatim - let's extract them into a partial and include in both places.


#### Explicitly providing the Railway project ID

By default, Wasp CLI tries to create a new Railway project named `<project-name>`. If you want to use an existing Railway project, pass its ID with `--existing-project-id` option:
Expand Down
Loading