when hosting next js with aws ampify "Failed to set up process.env.secrets" [duplicate] - reactjs

This question already has answers here:
Error: Image Optimization using Next.js default loader is not compatible with `next export`
(5 answers)
Closed 4 months ago.
hi i am trying to host web/app with AWS Amplify. but it keeps don't working.
i start the code with yarn so i already removed package.lock.json
and input in the console this code: moment prop-types typescript
Here is the error code:
2022-10-01T05:02:39.118Z [INFO]: # Cloning repository: git#github.com:arty0928/SNS-Community-Instagram.git
2022-10-01T05:02:41.683Z [INFO]: Cloning into 'SNS-Community-Instagram'...
2022-10-01T05:02:41.683Z [INFO]: # Switching to commit: fcdeed8e4d4542a5fd5550c9d7f795f0b9c39e96
2022-10-01T05:02:41.691Z [INFO]: Note: switching to 'fcdeed8e4d4542a5fd5550c9d7f795f0b9c39e96'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:
git switch -c <new-branch-name>
Or undo this operation with:
git switch -
Turn off this advice by setting config variable advice.detachedHead to false
HEAD is now at fcdeed8 1001
2022-10-01T05:02:41.756Z [INFO]: Successfully cleaned up Git credentials
2022-10-01T05:02:41.756Z [INFO]: # Checking for Git submodules at: /codebuild/output/src195284664/src/SNS-Community-Instagram/.gitmodules
2022-10-01T05:02:41.782Z [INFO]: # Retrieving environment cache...
2022-10-01T05:02:42.530Z [INFO]: # Retrieved environment cache
2022-10-01T05:02:42.626Z [INFO]: ---- Setting Up SSM Secrets ----
2022-10-01T05:02:42.626Z [INFO]: SSM params {"Path":"/amplify/d2pnqm4mqnrup0/main/","WithDecryption":true}
2022-10-01T05:02:42.654Z [WARNING]: !Failed to set up process.env.secrets
2022-10-01T05:02:42.672Z [INFO]: No live updates for this build run
2022-10-01T05:02:42.676Z [INFO]: # Retrieving cache...
2022-10-01T05:02:42.720Z [INFO]: # Extracting cache...
2022-10-01T05:02:42.727Z [INFO]: # Extraction completed
2022-10-01T05:03:42.529Z [INFO]: ## Starting Backend Build
## Checking for associated backend environment...
## No backend environment association found, continuing...
## Completed Backend Build
2022-10-01T05:03:42.531Z [INFO]: {"backendDuration": 0}
## Starting Frontend Build
# Starting phase: preBuild
# Executing command: yarn install
2022-10-01T05:03:43.320Z [INFO]: yarn install v1.22.0
2022-10-01T05:03:43.407Z [INFO]: [1/4] Resolving packages...
2022-10-01T05:03:45.776Z [INFO]: [2/4] Fetching packages...
2022-10-01T05:04:04.328Z [INFO]: info #next/swc-win32-x64-msvc#12.3.0: The platform "linux" is incompatible with this module.
info "#next/swc-win32-x64-msvc#12.3.0" is an optional dependency and failed compatibility check. Excluding it from installation.
2022-10-01T05:04:04.329Z [INFO]: info #next/swc-android-arm64#12.3.0: The platform "linux" is incompatible with this module.
info "#next/swc-android-arm64#12.3.0" is an optional dependency and failed compatibility check. Excluding it from installation.
info #next/swc-android-arm64#12.3.0: The CPU architecture "x64" is incompatible with this module.
info #next/swc-freebsd-x64#12.3.0: The platform "linux" is incompatible with this module.
info "#next/swc-freebsd-x64#12.3.0" is an optional dependency and failed compatibility check. Excluding it from installation.
info #next/swc-android-arm-eabi#12.3.0: The platform "linux" is incompatible with this module.
info "#next/swc-android-arm-eabi#12.3.0" is an optional dependency and failed compatibility check. Excluding it from installation.
info #next/swc-android-arm-eabi#12.3.0: The CPU architecture "x64" is incompatible with this module.
info #next/swc-linux-arm64-musl#12.3.0: The CPU architecture "x64" is incompatible with this module.
info "#next/swc-linux-arm64-musl#12.3.0" is an optional dependency and failed compatibility check. Excluding it from installation.
info #next/swc-darwin-x64#12.3.0: The platform "linux" is incompatible with this module.
info "#next/swc-darwin-x64#12.3.0" is an optional dependency and failed compatibility check. Excluding it from installation.
info #next/swc-linux-arm64-gnu#12.3.0: The CPU architecture "x64" is incompatible with this module.
info "#next/swc-linux-arm64-gnu#12.3.0" is an optional dependency and failed compatibility check. Excluding it from installation.
info #next/swc-win32-arm64-msvc#12.3.0: The platform "linux" is incompatible with this module.
info "#next/swc-win32-arm64-msvc#12.3.0" is an optional dependency and failed compatibility check. Excluding it from installation.
info #next/swc-win32-arm64-msvc#12.3.0: The CPU architecture "x64" is incompatible with this module.
info #next/swc-win32-ia32-msvc#12.3.0: The platform "linux" is incompatible with this module.
info "#next/swc-win32-ia32-msvc#12.3.0" is an optional dependency and failed compatibility check. Excluding it from installation.
info #next/swc-win32-ia32-msvc#12.3.0: The CPU architecture "x64" is incompatible with this module.
info #next/swc-darwin-arm64#12.3.0: The platform "linux" is incompatible with this module.
info "#next/swc-darwin-arm64#12.3.0" is an optional dependency and failed compatibility check. Excluding it from installation.
info #next/swc-darwin-arm64#12.3.0: The CPU architecture "x64" is incompatible with this module.
info #next/swc-linux-arm-gnueabihf#12.3.0: The CPU architecture "x64" is incompatible with this module.
info "#next/swc-linux-arm-gnueabihf#12.3.0" is an optional dependency and failed compatibility check. Excluding it from installation.
2022-10-01T05:04:04.332Z [INFO]: info fsevents#2.3.2: The platform "linux" is incompatible with this module.
2022-10-01T05:04:04.332Z [INFO]: info "fsevents#2.3.2" is an optional dependency and failed compatibility check. Excluding it from installation.
2022-10-01T05:04:04.333Z [INFO]: [3/4] Linking dependencies...
2022-10-01T05:04:09.240Z [INFO]: [4/4] Building fresh packages...
2022-10-01T05:04:09.563Z [INFO]: success Saved lockfile.
2022-10-01T05:04:09.566Z [INFO]: Done in 26.25s.
2022-10-01T05:04:09.587Z [INFO]: # Completed phase: preBuild
# Starting phase: build
2022-10-01T05:04:09.588Z [INFO]: # Executing command: yarn run build
2022-10-01T05:04:09.706Z [INFO]: yarn run v1.22.0
2022-10-01T05:04:09.732Z [INFO]: $ next build && next export
2022-10-01T05:04:10.101Z [WARNING]: warn - Invalid next.config.js options detected:
2022-10-01T05:04:10.102Z [WARNING]: - The root value has an unexpected property, mode, which is not in the list of allowed properties (amp, analyticsId, assetPrefix, basePath, cleanDistDir, compiler, compress, crossOrigin, devIndicators, distDir, env, eslint, excludeDefaultMomentLocales, experimental, exportPathMap, future, generateBuildId, generateEtags, headers, httpAgentOptions, i18n, images, onDemandEntries, optimizeFonts, output, outputFileTracing, pageExtensions, poweredByHeader, productionBrowserSourceMaps, publicRuntimeConfig, reactStrictMode, redirects, rewrites, sassOptions, serverRuntimeConfig, staticPageGenerationTimeout, swcMinify, trailingSlash, typescript, useFileSystemPublicRoutes, webpack).
2022-10-01T05:04:10.102Z [WARNING]: - The root value has an unexpected property, theme, which is not in the list of allowed properties (amp, analyticsId, assetPrefix, basePath, cleanDistDir, compiler, compress, crossOrigin, devIndicators, distDir, env, eslint, excludeDefaultMomentLocales, experimental, exportPathMap, future, generateBuildId, generateEtags, headers, httpAgentOptions, i18n, images, onDemandEntries, optimizeFonts, output, outputFileTracing, pageExtensions, poweredByHeader, productionBrowserSourceMaps, publicRuntimeConfig, reactStrictMode, redirects, rewrites, sassOptions, serverRuntimeConfig, staticPageGenerationTimeout, swcMinify, trailingSlash, typescript, useFileSystemPublicRoutes, webpack).
- The root value has an unexpected property, variants, which is not in the list of allowed properties (amp, analyticsId, assetPrefix, basePath, cleanDistDir, compiler, compress, crossOrigin, devIndicators, distDir, env, eslint, excludeDefaultMomentLocales, experimental, exportPathMap, future, generateBuildId, generateEtags, headers, httpAgentOptions, i18n, images, onDemandEntries, optimizeFonts, output, outputFileTracing, pageExtensions, poweredByHeader, productionBrowserSourceMaps, publicRuntimeConfig, reactStrictMode, redirects, rewrites, sassOptions, serverRuntimeConfig, staticPageGenerationTimeout, swcMinify, trailingSlash, typescript, useFileSystemPublicRoutes, webpack).
- The root value has an unexpected property, plugins, which is not in the list of allowed properties (amp, analyticsId, assetPrefix, basePath, cleanDistDir, compiler, compress, crossOrigin, devIndicators, distDir, env, eslint, excludeDefaultMomentLocales, experimental, exportPathMap, future, generateBuildId, generateEtags, headers, httpAgentOptions, i18n, images, onDemandEntries, optimizeFonts, output, outputFileTracing, pageExtensions, poweredByHeader, productionBrowserSourceMaps, publicRuntimeConfig, reactStrictMode, redirects, rewrites, sassOptions, serverRuntimeConfig, staticPageGenerationTimeout, swcMinify, trailingSlash, typescript, useFileSystemPublicRoutes, webpack).
See more info here: https://nextjs.org/docs/messages/invalid-next-config
2022-10-01T05:04:10.105Z [INFO]: warn - No build cache found. Please configure build caching for faster rebuilds. Read more: https://nextjs.org/docs/messages/no-cache
2022-10-01T05:04:10.147Z [INFO]: Attention: Next.js now collects completely anonymous telemetry regarding usage.
2022-10-01T05:04:10.147Z [INFO]: This information is used to shape Next.js' roadmap and prioritize features.
You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
https://nextjs.org/telemetry
2022-10-01T05:04:10.236Z [INFO]: info - Linting and checking validity of types...
2022-10-01T05:04:12.264Z [INFO]: info - Creating an optimized production build...
2022-10-01T05:04:41.658Z [INFO]: info - Compiled successfully
2022-10-01T05:04:41.659Z [INFO]: info - Collecting page data...
2022-10-01T05:04:46.213Z [INFO]: info - Generating static pages (0/10)
2022-10-01T05:04:46.256Z [INFO]: info - Generating static pages (2/10)
2022-10-01T05:04:46.264Z [INFO]: info - Generating static pages (4/10)
2022-10-01T05:04:46.275Z [INFO]: info - Generating static pages (7/10)
2022-10-01T05:04:46.282Z [INFO]: info - Generating static pages (10/10)
2022-10-01T05:04:46.296Z [INFO]: info - Finalizing page optimization...
2022-10-01T05:04:46.301Z [INFO]:
2022-10-01T05:04:46.318Z [INFO]: Route (pages) Size First Load JS
┌ ○ / 212 B 1.22 MB
├ /_app 0 B 110 kB
├ ○ /404 194 B 110 kB
├ λ /api/auth/[...nextauth] 0 B 110 kB
├ λ /api/hello 0 B 110 kB
├ ○ /auth/Exercise 3.19 kB 1.22 MB
├ ○ /auth/Hobby 3.18 kB 1.22 MB
├ ○ /auth/Introduce 396 B 1.22 MB
├ ○ /auth/Invest 3.19 kB 1.22 MB
├ ○ /auth/News 3.18 kB 1.22 MB
├ ○ /auth/Reading 3.19 kB 1.22 MB
├ λ /auth/signin 664 B 1.22 MB
└ ○ /auth/Study 3.18 kB 1.22 MB
+ First Load JS shared by all 115 kB
├ chunks/framework-4556c45dd113b893.js 45.2 kB
├ chunks/main-153ca532c98eee0d.js 31.1 kB
├ chunks/pages/_app-c5a4783636926992.js 32.7 kB
├ chunks/webpack-cb7634a8b6194820.js 884 B
└ css/9331222e262f4b1a.css 5.25 kB
2022-10-01T05:04:46.319Z [INFO]: λ (Server) server-side renders at runtime (uses getInitialProps or getServerSideProps)
○ (Static) automatically rendered as static HTML (uses no initial props)
2022-10-01T05:04:46.776Z [WARNING]: warn - Invalid next.config.js options detected:
2022-10-01T05:04:46.778Z [WARNING]: - The root value has an unexpected property, mode, which is not in the list of allowed properties (amp, analyticsId, assetPrefix, basePath, cleanDistDir, compiler, compress, crossOrigin, devIndicators, distDir, env, eslint, excludeDefaultMomentLocales, experimental, exportPathMap, future, generateBuildId, generateEtags, headers, httpAgentOptions, i18n, images, onDemandEntries, optimizeFonts, output, outputFileTracing, pageExtensions, poweredByHeader, productionBrowserSourceMaps, publicRuntimeConfig, reactStrictMode, redirects, rewrites, sassOptions, serverRuntimeConfig, staticPageGenerationTimeout, swcMinify, trailingSlash, typescript, useFileSystemPublicRoutes, webpack).
2022-10-01T05:04:46.778Z [WARNING]: - The root value has an unexpected property, theme, which is not in the list of allowed properties (amp, analyticsId, assetPrefix, basePath, cleanDistDir, compiler, compress, crossOrigin, devIndicators, distDir, env, eslint, excludeDefaultMomentLocales, experimental, exportPathMap, future, generateBuildId, generateEtags, headers, httpAgentOptions, i18n, images, onDemandEntries, optimizeFonts, output, outputFileTracing, pageExtensions, poweredByHeader, productionBrowserSourceMaps, publicRuntimeConfig, reactStrictMode, redirects, rewrites, sassOptions, serverRuntimeConfig, staticPageGenerationTimeout, swcMinify, trailingSlash, typescript, useFileSystemPublicRoutes, webpack).
- The root value has an unexpected property, variants, which is not in the list of allowed properties (amp, analyticsId, assetPrefix, basePath, cleanDistDir, compiler, compress, crossOrigin, devIndicators, distDir, env, eslint, excludeDefaultMomentLocales, experimental, exportPathMap, future, generateBuildId, generateEtags, headers, httpAgentOptions, i18n, images, onDemandEntries, optimizeFonts, output, outputFileTracing, pageExtensions, poweredByHeader, productionBrowserSourceMaps, publicRuntimeConfig, reactStrictMode, redirects, rewrites, sassOptions, serverRuntimeConfig, staticPageGenerationTimeout, swcMinify, trailingSlash, typescript, useFileSystemPublicRoutes, webpack).
- The root value has an unexpected property, plugins, which is not in the list of allowed properties (amp, analyticsId, assetPrefix, basePath, cleanDistDir, compiler, compress, crossOrigin, devIndicators, distDir, env, eslint, excludeDefaultMomentLocales, experimental, exportPathMap, future, generateBuildId, generateEtags, headers, httpAgentOptions, i18n, images, onDemandEntries, optimizeFonts, output, outputFileTracing, pageExtensions, poweredByHeader, productionBrowserSourceMaps, publicRuntimeConfig, reactStrictMode, redirects, rewrites, sassOptions, serverRuntimeConfig, staticPageGenerationTimeout, swcMinify, trailingSlash, typescript, useFileSystemPublicRoutes, webpack).
See more info here: https://nextjs.org/docs/messages/invalid-next-config
2022-10-01T05:04:46.881Z [INFO]: info - using build directory: /codebuild/output/src195284664/src/SNS-Community-Instagram/.next
2022-10-01T05:04:46.884Z [INFO]: info - Copying "static build" directory
2022-10-01T05:04:46.887Z [INFO]: info - No "exportPathMap" found in "/codebuild/output/src195284664/src/SNS-Community-Instagram/next.config.js". Generating map from "./pages"
2022-10-01T05:04:46.889Z [WARNING]: Error: Image Optimization using Next.js' default loader is not compatible with `next export`.
Possible solutions:
- Use `next start` to run a server, which includes the Image Optimization API.
- Configure `images.unoptimized = true` in `next.config.js` to disable the Image Optimization API.
Read more: https://nextjs.org/docs/messages/export-image-api
at /codebuild/output/src195284664/src/SNS-Community-Instagram/node_modules/next/dist/export/index.js:149:23
at async Span.traceAsyncFn (/codebuild/output/src195284664/src/SNS-Community-Instagram/node_modules/next/dist/trace/trace.js:79:20)
2022-10-01T05:04:46.903Z [WARNING]: error Command failed with exit code 1.
2022-10-01T05:04:46.904Z [INFO]: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
2022-10-01T05:04:46.908Z [ERROR]: !!! Build failed
2022-10-01T05:04:46.908Z [ERROR]: !!! Non-Zero Exit Code detected
2022-10-01T05:04:46.908Z [INFO]: # Starting environment caching...
2022-10-01T05:04:46.909Z [INFO]: # Environment caching completed
Terminating logging...
This is package.json code:
{
"name": "my-project",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build && next export",
"start": "next start",
"lint": "next lint",
"netlify-deploy": "next build && next export"
},
"dependencies": {
"#faker-js/faker": "^7.5.0",
"#headlessui/react": "^1.7.2",
"#heroicons/react": "^1.0.6",
"#tailwindcss/forms": "^0.5.3",
"fake": "^0.2.2",
"faker": "^6.6.6",
"firebase": "^9.10.0",
"moment": "^2.29.4",
"next": "12.3.0",
"next-auth": "^4.10.3",
"prop-types": "^15.8.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-moment": "^1.1.2",
"react-router-dom": "^6.4.1",
"recoil": "^0.7.5",
"tailwind-scrollbar-hide": "^1.1.7",
"typescript": "^4.8.4"
},
"devDependencies": {
"autoprefixer": "^10.4.11",
"eslint": "8.23.1",
"eslint-config-next": "12.3.0",
"postcss": "^8.4.16",
"tailwind-scrollbar": "^2.0.1",
"tailwindcss": "^3.1.8"
}
}
how can i use these whole error? i am trying to host this for a week.. please help me out

By reading the following amplify console logs. It's seems that you have not disabled Image Optimization feature of the Nextjs.
Error: Image Optimization using Next.js' default loader is not
compatible with next export. Possible solutions:
Use next start to run a server, which includes the Image Optimization API.
Configure images.unoptimized = true in next.config.js to disable the Image Optimization API. Read more:
https://nextjs.org/docs/messages/export-image-api
As per the Amplify Docs
Image Optimization using Next.js' default loader is not compatible
with next export. To manually deploy the next-app example, you must
edit the index.js file to remove this feature following the steps
below.
Next, locate the similar <Image> Tag you have used in the Project
<Image src="/vercel.svg" alt="Vercel Logo" width={72} height={16} />
Edit the tag to use the HTML img tag as follows:
<img src="/vercel.svg" alt="Vercel Logo" width={72} height={16} />
You can read further about it here

In you next.config.js, define your loader as "akamai". If you're sourcing any images using URL and reactStrictMode is set to true, define the image URL in the domains object.
module.exports = {
reactStrictMode: true,
images:{
loader: 'akamai',
domains: [
"image URL",
]
}
Alternatively, leave your images unoptimised.
module.exports = {
reactStrictMode: true,
images:{
unoptimized: true,
}

Related

workspaces internal error when running "yarn dev"

I have a project I cloned from GitHub that was created in Vite+react+tailwind
When I run “yarn dev” I receive the following error
Internal Error: PROJECTNAME#workspace:.: This package doesn't seem to be present in your lockfile; run "yarn install" to update the lockfile
at AF.getCandidates (/Users/name/.yarn/releases/yarn-3.1.1.cjs:437:4421)
at pd.getCandidates (/Users/name/.yarn/releases/yarn-3.1.1.cjs:432:5275)
at /Users/name/.yarn/releases/yarn-3.1.1.cjs:441:7674
at du (/Users/name/.yarn/releases/yarn-3.1.1.cjs:382:4003)
at R (/Users/name/.yarn/releases/yarn-3.1.1.cjs:441:7654)
Then, when I run “yarn install” here is what I get
➤ YN0000: ┌ Resolution step
➤ YN0035: │ #noirgallery/restless#npm:^0.7.0: The remote server failed to provide the requested resource
➤ YN0035: │ Response Code: 404 (Not Found)
➤ YN0035: │ Request Method: GET
➤ YN0035: │ Request URL: https://registry.yarnpkg.com/#noirgallery%2frestless
➤ YN0000: └ Completed in 0s 670ms
➤ YN0000: Failed with errors in 0s 675ms
➤ YN0032: fsevents#npm:2.3.2: Implicit dependencies on node-gyp are discouraged
➤ YN0061: sane#npm:4.1.0 is deprecated: some dependency vulnerabilities fixed, support for node < 10 dropped, and newer ECMAScript syntax/features added
➤ YN0061: resolve-url#npm:0.2.1 is deprecated: https://github.com/lydell/resolve-url#deprecated
➤ YN0061: urix#npm:0.1.0 is deprecated: Please see https://github.com/lydell/urix#deprecated
➤ YN0061: core-js#npm:1.2.7 is deprecated: core-js#<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
And then if I run “yarn dev” again, this just repeats.

react-scripts build works local but fails in CodeBuild

I am using CodeBuild to deploy a react website to S3. When I run npm run build locally, it works perfectly. However, when it hits CodeBuild it fails with the following error:
[Container] 2021/01/26 00:29:23 Running command npm run build
> gci-web-app#0.1.0 build /codebuild/output/src705738256/src
> react-scripts build
/codebuild/output/src705738256/src/node_modules/fs-extra/lib/mkdirs/make-dir.js:85
} catch {
^
SyntaxError: Unexpected token {
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:616:28)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/codebuild/output/src705738256/src/node_modules/fs-extra/lib/mkdirs/index.js:3:44)
I have tried installing fs-extra in the package, but still hitting the same error. Really scratching my head on this, as this is an out of the box create-react-app application. Any help would be greatly appreciated!
In case its needed, this is what my CodeBuild looks like:
phases:
pre_build:
commands:
- echo Installing source NPM dependencies...
- npm install
build:
commands:
- echo Build started on `date`
- npm run build
post_build:
commands:
# copy the contents of /build to S3
- aws s3 cp --recursive --acl public-read ./build s3://${GciWebAppBucket}/
# set the cache-control headers for service-worker.js to prevent
# browser caching
- >
aws s3 cp --acl public-read
--cache-control="max-age=0, no-cache, no-store, must-revalidate"
./build/service-worker.js s3://${GciWebAppBucket}/
# set the cache-control headers for index.html to prevent
# browser caching
- >
aws s3 cp --acl public-read
--cache-control="max-age=0, no-cache, no-store, must-revalidate"
./build/index.html s3://${GciWebAppBucket}/
# invalidate the CloudFront cache for index.html and service-worker.js
# to force CloudFront to update its edge locations with the new versions
- >
aws cloudfront create-invalidation --distribution-id ${Distribution}
--paths /index.html /service-worker.js
artifacts:
files:
- '**/*'
base-directory: build
The issue was due to the version of Nodejs the docker was using. Changing the image to standard:5.0 and setting runtime-versions to nodejs 14 in the install phase did the job. The full CodeBuild cfn that worked is below.
CodeBuild:
Type: 'AWS::CodeBuild::Project'
Properties:
Name: !Sub ${AWS::StackName}-CodeBuild
ServiceRole: !GetAtt CodeBuildRole.Arn
Artifacts:
# The downloaded source code for the build will come from CodePipeline
Type: CODEPIPELINE
Name: GCIWebApp
Source:
Type: CODEPIPELINE
Environment:
# Linux container with node installed
ComputeType: BUILD_GENERAL1_SMALL
Type: LINUX_CONTAINER
Image: "aws/codebuild/standard:5.0"
Source:
Type: CODEPIPELINE
BuildSpec: !Sub |
version: 0.2
phases:
install:
runtime-versions:
nodejs: 14
commands:
- npm i npm#latest -g
- npm cache clean --force
- rm -rf node_modules package-lock.json
- npm install
build:
commands:
- echo Build started on `date`
- npm run build
post_build:
commands:
# copy the contents of /build to S3
- aws s3 cp --recursive --acl public-read ./build s3://${GciWebAppBucket}/
# set the cache-control headers for service-worker.js to prevent
# browser caching
- >
aws s3 cp --acl public-read
--cache-control="max-age=0, no-cache, no-store, must-revalidate"
./build/service-worker.js s3://${GciWebAppBucket}/
# set the cache-control headers for index.html to prevent
# browser caching
- >
aws s3 cp --acl public-read
--cache-control="max-age=0, no-cache, no-store, must-revalidate"
./build/index.html s3://${GciWebAppBucket}/
# invalidate the CloudFront cache for index.html and service-worker.js
# to force CloudFront to update its edge locations with the new versions
- >
aws cloudfront create-invalidation --distribution-id ${Distribution}
--paths /index.html /service-worker.js
artifacts:
files:
- '**/*'
base-directory: build

How do I resolve Composer dependency upgrading to CakePHP4?

I'm following the upgrade instructions for moving a CakePHP project to version 4. All went well until the final command:
php composer.phar require --update-with-dependencies "cakephp/cakephp:4.0.*"
This resulted in
Problem 1
cakephp/bake 1.11.2 requires cakephp/cakephp ^3.8.0 -> satisfiable by cakephp/cakephp[3.8.0, >>3.8.0-RC1, 3.8.0-RC2, 3.8.0-RC3, 3.8.0-beta1, 3.8.1, 3.8.10, 3.8.11, 3.8.2, 3.8.3, 3.8.4, >>3.8.5, 3.8.6, 3.8.7, 3.8.8, 3.8.9, 3.x-dev] but these conflict with your requirements or >.minimum-stability.
cakephp/bake 1.11.2 requires cakephp/cakephp ^3.8.0 -> satisfiable by cakephp/cakephp[3.8.0, 3.8.0-RC1, 3.8.0-RC2, 3.8.0-RC3, 3.8.0-beta1, 3.8.1, 3.8.10, 3.8.11, 3.8.2, 3.8.3, 3.8.4, 3.8.5, 3.8.6, 3.8.7, 3.8.8, 3.8.9, 3.x-dev] but these conflict with your requirements or minimum-stability.
cakephp/bake 1.11.2 requires cakephp/cakephp ^3.8.0 -> satisfiable by cakephp/cakephp[3.8.0, 3.8.0-RC1, 3.8.0-RC2, 3.8.0-RC3, 3.8.0-beta1, 3.8.1, 3.8.10, 3.8.11, 3.8.2, 3.8.3, 3.8.4, 3.8.5, 3.8.6, 3.8.7, 3.8.8, 3.8.9, 3.x-dev] but these conflict with your requirements or minimum-stability.
Installation request for cakephp/bake (locked at 1.11.2, required as ^1.9.0) -> satisfiable by cakephp/bake[1.11.2].
The VERSION.txt for the project shows CakePHP at 3.8.11.
In the composer.json file:
"require-dev": {
"cakephp/bake": "^1.9.0",
"cakephp/cakephp-codesniffer": "^3.0",
"cakephp/debug_kit": "^3.17.0",
"josegonzalez/dotenv": "3.*",
"psy/psysh": "#stable"
},
Without updating, change all requirements according to the latest 4.x application template's composer.json file, change the requirements for other CakePHP plugins that you might have installed to a 4.x compatible version too, and then update your dependencies.
composer require --no-update "cakephp/cakephp:^4.0" "cakephp/migrations:^3.0#beta"
composer require --no-update --dev "cakephp/bake:^2.0.3" "cakephp/cakephp-codesniffer:~4.1.0" "cakephp/debug_kit:^4.0" "phpunit/phpunit:^8.5"
composer update --with-dependencies

Gunicorn Command Line Error inGoogle App Engine Standard Environment

I'm getting an endless stream of the following errors after deploying a Flask/Python3/Postgres app to app engine standard environment. The warning about Psycopg2 package is of concern, but not what's causing the app to fail to run. Rather, it's the invalid command line arguments to gunicorn, which are supplied by GAE, not by me. Is anyone able to deploy a Python3 Flask that uses Postgres to the Standard environment successfully?
Here's the log file output:
2018-12-11 02:51:37 +0000] [3738] [INFO] Booting worker with pid: 3738
2018-12-11 02:51:37 default[20181210t140744] /env/lib/python3.7/site-packages/psycopg2/__init__.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>.
2018-12-11 02:51:37 default[20181210t140744] """)
2018-12-11 02:51:38 default[20181210t211942] usage: gunicorn [-h] [--debug] [--args]
2018-12-11 02:51:38 default[20181210t211942] gunicorn: error: unrecognized arguments: main:app --workers 1 -c /config/gunicorn.py
2018-12-11 02:51:38 default[20181210t211942] [2018-12-11 02:51:38 +0000] [882] [INFO] Worker exiting (pid: 882)
By default, if entrypoint is not defined in app.yaml, App Engine will look for an app called app in main.py. If you look at the official code sample in Github, it addresses it in the main.py file by declaring:
app = Flask(__name__)
Alternatively, this can be configured by adding an entrypoint to app.yaml pointing to another file. For example, if you declare app in a file called prod:
entrypoint: gunicorn -b :$PORT prod.app
You'll find additional details about the entrypoint configuration here.
From the comment and answer above, It looked like the problem had to be in my app. I confirmed that by running gunicorn locally on a bare-bones app without difficulty, but failing when running the real app.
One culprit turned out to be the use of argparse, which I was using so I could add a "debug" argument to the command line when working locally. Moving that code to the if __name__ == '__main__': section made the app run fine when using gunicorn locally.
But it still fails when deployed to GAE:
2018-12-12 20:09:16 default[20181212t094625] [2018-12-12 20:09:16 +0000] [8145] [INFO] Booting worker with pid: 8145
2018-12-12 20:09:16 default[20181212t094625] /env/lib/python3.7/site-packages/psycopg2/__init__.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>.
2018-12-12 20:09:16 default[20181212t094625] """)
2018-12-12 20:09:16 default[20181212t094625] [2018-12-12 20:09:16 +0000] [8286] [INFO] Booting worker with pid: 8286
2018-12-12 20:09:16 default[20181212t094625] /env/lib/python3.7/site-packages/psycopg2/__init__.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>.
2018-12-12 20:09:16 default[20181212t094625] """)
2018-12-12 20:09:19 default[20181212t094625] usage: gunicorn [-h] [--debug] [--args]
2018-12-12 20:09:19 default[20181212t094625] gunicorn: error: unrecognized arguments: -b :8081 main:app
2018-12-12 20:09:19 default[20181212t094625] [2018-12-12 20:09:19 +0000] [8145] [INFO] Worker exiting (pid: 8145)
Here’s app.yaml (minus the environment variable for SendGrid):
runtime: python37
env: standard
#threadsafe: true
entrypoint: gunicorn --workers 2 --bind :5000 main:app
#runtime_config:
# python_version: 3
# This beta setting is necessary for the db hostname parameter to be able to handle a URI in the
# form “/cloudsql/...” where ... is the instance given here:
beta_settings:
cloud_sql_instances: provost-access-148820:us-east1:cuny-courses

Heroku - Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch using Webpack

been using the http://jumbo-react.g-axon.com/ framework for a client. This framework is based on react and uses webpack to build. It works on my local machine, but when uploading to Heroku I get this error:
react-material#2.0.0 start /app
2018-08-24T10:05:46.551774+00:00 app[web.1]: > webpack-dev-server --hot --open
2018-08-24T10:05:46.551775+00:00 app[web.1]:
2018-08-24T10:05:47.905809+00:00 app[web.1]: Project is running at http://localhost:24282/
2018-08-24T10:05:47.906248+00:00 app[web.1]: webpack output is served from /assets/
2018-08-24T10:05:47.906347+00:00 app[web.1]: Content not from webpack is served from ./public/, ./src/
2018-08-24T10:05:47.906399+00:00 app[web.1]: 404s will fallback to /index.html
2018-08-24T10:05:47.939064+00:00 app[web.1]: Unable to open browser. If you are running in a headless environment, please do not use the open flag.
2018-08-24T10:06:37.917006+00:00 app[web.1]: Hash: 7feed7b626257881787d
2018-08-24T10:06:37.917049+00:00 app[web.1]: Version: webpack 3.12.0
2018-08-24T10:06:37.917052+00:00 app[web.1]: Time: 49556ms
2018-08-24T10:06:37.917058+00:00 app[web.1]: Asset Size Chunks
2018-08-24T10:06:37.917128+00:00 app[web.1]:
Cut the middle to make it easier to read
2018-08-24T10:06:37.917146+00:00 app[web.1]: [../node_modules/webpack/hot/log.js] (webpack)/hot/log.js 1.04 kB {30} [built]
2018-08-24T10:06:37.917124+00:00 app[web.1]: [../node_modules/react-hot-loader/patch.js] ./node_modules/react-hot-loader/patch.js 40 bytes {30} [built]
2018-08-24T10:06:37.917147+00:00 app[web.1]: [../node_modules/webpack/hot/only-dev-server.js] (webpack)/hot/only-dev-server.js 2.37 kB {30} [built]
2018-08-24T10:06:37.917143+00:00 app[web.1]: [../node_modules/webpack/hot/emitter.js] (webpack)/hot/emitter.js 77 bytes {30} [built]
2018-08-24T10:06:37.917151+00:00 app[web.1]: + 1784 hidden modules
2018-08-24T10:06:37.917126+00:00 app[web.1]: [../node_modules/webpack-dev-server/client/index.js?http://localhost:24282] (webpack)-dev-server/client?http://localhost:24282 7.93 kB {30} [built]
2018-08-24T10:06:37.917152+00:00 app[web.1]: webpack: Compiled successfully.
2018-08-24T10:06:37.917142+00:00 app[web.1]: [../node_modules/webpack/hot/dev-server.js] (webpack)/hot/dev-server.js 1.61 kB {30} [built]
2018-08-24T10:06:37.917150+00:00 app[web.1]: [./index.js] ./src/index.js 848 bytes {30} [built]
2018-08-24T10:06:44.847917+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2018-08-24T10:06:44.847917+00:00 heroku[web.1]: Stopping process with SIGKILL
2018-08-24T10:06:44.963250+00:00 heroku[web.1]: Process exited with status 137
2018-08-24T10:06:44.977771+00:00 heroku[web.1]: State changed from starting to crashed
When initially searching for an answer, the most common response was: because I was hard setting the port instead of using process.env.PORT, but I've now changed that in the webpack settings:
return {
context: this.srcPathAbsolute,
devtool: 'eval',
devServer: {
contentBase: ['./public/', './src/'],
publicPath: '/assets/',
historyApiFallback: true,
hot: true,
inline: true,
port: process.env.PORT || 3000
But Heroku still shows this crash report. Every time it does show, however, the app is now using a different port- meaning it's now being set by Heroku.
The build time of webpack is 50s and I was wondering if that was the problem. Is it building too slow and then afterwards not having enough time to bind to a port before the 60s Heroku limit is up?
Honestly not really sure where to go from here, before hacking through files and changing the structure of the app for efficiency (although not a bad thing to do) I wanted to know if I was on the right trail. Would hate to change things in the app and accidentally create more problems when not solving the initial problem that was the most pressing.
If you have any suggestions, really would like to hear.
Thanks for your time.
Node: v8.11.3
Yarn: 1.6.0
Webpack: ^3.5.6
It looks like you're trying to run heroku in a development environment. You'll want to make sure that your environment is set to production and that you get web pack to compile all your assets.
The first line of the heroku output says webpack-dev-server --hot --open which suggests you're trying to use the web packer dev server in production which, as the name suggests, probably won't work.
This might help? https://www.thegreatcodeadventure.com/deploying-react-redux-to-heroku/

Resources