apprunner-roadmap
apprunner-roadmap copied to clipboard
Can't Run Multiple Commands Under "Build command" Config?
I have the following in my package.json
file:
"scripts": {
"migrate": "knex migrate:latest"
},
Running npm run migrate
works fine on my local machine. When I try to add this command onto my existing build command:
App Runner always gives an error and rolls back my change:
Does App Runner not support multiple build commands?
I had the same problem when defining the start command.
Example:
start command -> npm ci && npm run build
✅
build command -> npm run migration:run && npm run start
❌
I remember the error being related to the &&
. What I did as a workaround is creating a new script that encapsulated everything I wanted to do:
start command -> npm ci && npm run build
✅
build command -> npm run start:cd
✅ (cd as in Continuous Deployment)
With npm run start:cd
being:
"scripts": {
"start:cd": "npm run migration:run && npm run start:prod",
},
If that still doesn't do it, I would check the service logs to see what is causing the rollback to happen.
I had the same problem when defining the start command.
Example:
start command ->
npm ci && npm run build
✅ build command ->npm run migration:run && npm run start
❌I remember the error being related to the
&&
. What I did as a workaround is creating a new script that encapsulated everything I wanted to do:start command ->
npm ci && npm run build
✅ build command ->npm run start:cd
✅ (cd as in Continuous Deployment)With
npm run start:cd
being:"scripts": { "start:cd": "npm run migration:run && npm run start:prod", },
If that still doesn't do it, I would check the service logs to see what is causing the rollback to happen.
So you're running your custom start:cd
command as the build command - even though the second command it calls starts the server? Or did you mean to put that under the start command input on the App Runner config page?
What I think you're trying to say:
With the App Runner "build command", you're running npm ci && npm run build
. Then with the App Runner "start command", you're running your custom npm run start:cd
command (which runs your DB migrations and starts the Express / React server).
Another data point here - I tried running npm run migrate
by itself under the App Runner "build command" and got the same rollback error. That's probably because without npm install
, the knex library isn't available. I tried npm install; npm run migrate
and got the rollback error too.
The crux of the problem here is that App Runner doesn't provide actual logs that tell you what went wrong. I saw this brought up as a complaint from way back in 2021 and it doesn't seem like it has ever been addressed.
The really weird thing is that I can't seem to run any command in the App Runner "build command" input other than npm install
. I tried npm install -g
and even that got rolled back automatically.
Would be nice if someone from the App Runner team could actually chime in and provide some insight as to why setting up basic configs do not work.