7 months ago
Love the new pre-deploy command feature!
Question, is it possible to configure this from the railway config file, rather than through the UI?
0 Replies
7 months ago
yep! its part of the json schema already
@Brody Can I specify multiple commands? The schema seems to indicate that it's an array, but with a max of 1?
7 months ago
you can - command 1 && command 2
I don't have a startCommand in my railway.toml
because I use a Dockerfile. Can I still use a pre-deploy command?
oh, I see it in the schema file. preDeployCommand
always forget I can just see the entire schema directly
I just tested this. Multiple commands in preDeployCommand
don't seem to work:
startCommand = "./server"
preDeployCommand = "bun db:migrate && bun db:seed"
Only the first command runs.
Logs:
Starting Container
$ bun config/scripts/migrate.ts
Using database: libsql://...
Schema version: 6
[Migrate] Running up [6->all] migrations...
[Migrate] Done.
Stopping Container
Starting Container
Using database: libsql://...
Server is running on http://localhost:8080/graphql
When running bun db:migrate && bun db:seed
locally, this is how the logs look like:
$ bun config/scripts/migrate.ts
Using database: file:/...
Schema version: 6
[Migrate] Running up [6->all] migrations...
[Migrate] Done.
$ bun config/seeds.ts
Using database: file:/...
Schema version: 6
[Seeds] Seeding users...
[Seeds] Done.
I tried moving the commands to a shell script (the file has +x permission):
preDeployCommand = "./config/migrate.sh"
But it failed with:
Starting Container
exec container process `/app/backend/api/./config/migrate.sh`: Exec format error
Stopping Container
7 months ago
you are using a dockerfile, you need to wrap the pre-deploy command in a shell
7 months ago
/bin/sh -c "bun db:migrate && bun db:seed"
since &&
is shell specific syntax
this will probably fail, right?
preDeployCommand = "/bin/sh -c "bun db:migrate && bun db:seed""
7 months ago
pog
7 months ago
backslashes escape quotes btw
7 months ago
!s
Status changed to Solved brody • 7 months ago