Has anyone tried to deploy Strapi app using AWS amplify console “deliver” feature? I have no issues while hosting a normal react app but when I try hosting strapi app, the build files are not accessible (404) … Something went wrong with the path. Please find my build settings below. Any help is much appreciated.
Code seems ok, it is similar to React’s example. index.html file should be accessible even without the backend, but the js files which are included from /admin/{name}.js are not accessible directly. In that case you will get 404 for these files.
You should also launch the backend, with npm run start command:
backend:
phases:
postBuild:
commands:
- npm run start
@sunnyson Thanks for the quick response. I tried the postBuild command but the deployment got stuck in build phase in amplify console. Please find the build logs below.
2020-12-14T17:13:33.939Z [INFO]: # Completed phase: preBuild
# Starting phase: build
# Executing command: npm run build
2020-12-14T17:13:34.110Z [INFO]: > event-marketing-strapi-app@0.1.0 build /codebuild/output/src058873696/src/ema-serverless-app
> strapi build
2020-12-14T17:13:34.977Z [INFO]: Building your admin UI with development configuration ...
2020-12-14T17:13:37.302Z [INFO]: [info] [webpackbar] Compiling Webpack
2020-12-14T17:14:29.497Z [INFO]: [success] [webpackbar] Webpack: Compiled successfully in 52.19s
2020-12-14T17:14:29.517Z [INFO]: # Completed phase: build
# Starting phase: postBuild
2020-12-14T17:14:29.518Z [INFO]: # Executing command: npm run start
2020-12-14T17:14:29.677Z [INFO]: > event-marketing-strapi-app@0.1.0 start /codebuild/output/src058873696/src/ema-serverless-app
> strapi start
2020-12-14T17:14:32.124Z [WARNING]: /bin/sh: hostname: command not found
2020-12-14T17:14:32.750Z [INFO]:
But on a side point I do recommend you use the environment system, and assuming you have some kind of proxy application (Nginx, HAProxy AWS ELB, ect) configure the url in that file.
It could be related to how we generate our telemetry and the missing command from whatever container service amplify is using. We did have a bug report about that here:
@DMehaffy Thanks. The issue raised in amplify was done by one of my teammates. We will follow that thread for answers … Meanwhile, it looks like a non-shell command issue too. Do we have a workaround for this until Strapi fix this bug?
@Prabhu_Raj Currently I need to patch the node_modules/strapi/lib/services/metrics/sender.js on the Dockerfile after npm install is done, something like this
// ./patches/strapi/lib/services/metrics/sender.js
...
// machineIdSync() will not work on none-shell host
// We should disable it when opt-out telemetry
// https://strapi.io/documentation/v3.x/getting-started/usage-information.html#commitment-to-our-users-data-collection
if (uuid){
deviceId = machineIdSync();
}
Then in the Dockerfile
...
RUN yarn install
# Patches
COPY ./patches ./node_modules
...
@hxhieu and @Prabhu_Raj I’ve raised the issue directly with our backend engineers. We are currently in the middle of a feature development sprint (among a few other things ) but I’ll see if they can find a patch soon.
However @hxhieu if you are willing to submit a pull request, please do. It’s been a busy month for us and on a limited team of devs, especially with the holidays.
I was able to see the logs in AWS Amplify logs. I think issue is happening somewhere else too. Do we have to add some other change? Let me know if i miss something.
@Santhosh222 Unfortunately you need to opt-out the telemetry i.e. remove the uuid from the package.json, then the machineIdSync() method will not fire.
There is no other way to enable telemetry until the dependency on machineIdSync() is removed or update with one that does not rely on shell script.
I removed the uuid from package json. This resolved the issue /bin/sh: hostname: command not found. But the deploy is still getting stuck after the command npm start. There are also no errors after this command.
hello! Is there any solution? i have delete uuid from package json and the /bin/sh: hostname: command not found it continues to appear in the amplify deploy…
is there any other way? thanks!!
Hey everyone need some serious help! I am at the last of the project which I have to deliver.
at the start I build my next js frontend and deploy it on aws amplify successfully.
after that I start working on strapi, setup the project and now I want to deploy it on aws amplify.
getting same issues described abve.
this is the log message.