aws-amplify / aws-amplify/amplify-hosting
Allow Frontend build phases no need to write in order
- Dominant language
- Dockerfile
- Stars
- 481
- Forks
- 123
- PR merge metrics
- No merged PRs in 30d
Description
### Before opening, please confirm:
- [X] I have checked to see if my question is addressed in the [FAQ](https://github.com/aws-amplify/amplify-hosting/blob/master/FAQ.md).
- [X] I have [searched for duplicate or closed issues](https://github.com/aws-amplify/amplify-hosting/issues?q=is%3Aissue+).
- [X] I have read the guide for [submitting questions](https://github.com/aws-amplify/amplify-hosting/blob/master/CONTRIBUTING.md).
- [X] I have removed any sensitive information from my code snippets and submission.
### App Id
arn:aws:amplify:us-east-1:209057985304:apps/d3dzvvrrpoxcz8
### AWS Region
us-east-1
### Amplify Hosting feature
Build settings, Frontend builds
### Is your feature request related to a problem? Please describe:
I'm currently using CDK Java amplify-alpha service to deploy my next.js frontend. I noticed that after `cdk deploy`, the build process error occurred as
```
# Starting phase: build
2023-12-05T09:42:57.747Z [INFO]: # Executing command: npm run build
2023-12-05T09:43:11.049Z [INFO]: > frontend@0.1.0 build
> next build
endeg. 1. 0 but: apm run build
2023-12-05T09:43:11.055Z [WARNING]: sh: line 1: next: command not found
...
```
Because the amplify.yml defined by java.util.Map does not maintain the order of phases as `preBuild` then `build`, it might generate something as:
```
frontend:
phases:
build:
commands:
- npm run build
preBuild:
commands:
- npm ci
...
```
From my personal understanding, the container will try to run build first, and next has not been installed yet by preBuild command, thus caused the error. I always need to manually adjust the `amplify.yml` afterwards.
### Describe how you'd like this feature to work
So I hope that it's possible to always execute `preBuild`, then `build`, and then `postBuild`, regardless of the order in which they are written under `phases` in amplify.yml.
Contributor guide
Research direction
Start by reproducing the reported failure with the phases in amplify.yml ordered as build before preBuild, using the CDK Java Amplify setup and Next.js commands described in the issue. Trace how preBuild, build, and postBuild are read and executed; done means those phases run in that order regardless of their written order.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, java, next.js
- Domain
- build-system, ci-cd, cloud
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100