Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't Run Multiple Commands Under "Build command" Config? #241

Open
pihish opened this issue Mar 16, 2024 · 4 comments
Open

Can't Run Multiple Commands Under "Build command" Config? #241

pihish opened this issue Mar 16, 2024 · 4 comments

Comments

@pihish
Copy link

pihish commented Mar 16, 2024

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:

1

App Runner always gives an error and rolls back my change:

2

Does App Runner not support multiple build commands?

@Leonelmarianog
Copy link

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.

@pihish
Copy link
Author

pihish commented Mar 30, 2024

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).

@pihish
Copy link
Author

pihish commented Mar 30, 2024

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.

@pihish
Copy link
Author

pihish commented Mar 30, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants