Reputation: 1976
I've got the following deployment configuration that continues to fail when running sudo npm run production --silent at step 02_build_frontend. The step fails every time when using the EB CLI and "eb deploy" however if I SSH into the t3.small instance, and run the command, it compiles just fine. Here is my config and the associated errors.
01_deploy_application.config
option_settings:
- namespace: aws:elasticbeanstalk:application:environment
option_name: COMPOSER_HOME
value: /root
- namespace: aws:elasticbeanstalk:container:php:phpini
option_name: document_root
value: /public
- namespace: aws:elasticbeanstalk:container:php:phpini
option_name: memory_limit
value: 256M
container_commands:
00_copy_env_file:
command: "mv /tmp/.env /var/app/staging/.env"
01_install_js_dependencies:
command: "sudo npm install"
cwd: "/var/app/staging"
02_build_frontend:
command: "sudo npm run production --silent"
cwd: "/var/app/staging"
03_migrate_central_database:
command: "php artisan migrate --force"
cwd: "/var/app/staging"
leader_only: true
04_migrate_tenant_databases:
command: "php artisan tenants:migrate --force"
cwd: "/var/app/staging"
leader_only: true
cfn-init.log
2020-11-14 09:35:13,102 [INFO] -----------------------Starting build-----------------------
2020-11-14 09:35:13,108 [INFO] Running configSets: Infra-EmbeddedPostBuild
2020-11-14 09:35:13,111 [INFO] Running configSet Infra-EmbeddedPostBuild
2020-11-14 09:35:13,114 [INFO] Running config postbuild_0_first_access_data_network
2020-11-14 09:35:13,130 [INFO] Command 00_copy_env_file succeeded
2020-11-14 09:35:51,434 [INFO] Command 01_install_js_dependencies succeeded
2020-11-14 09:36:49,148 [ERROR] Command 02_build_frontend (sudo npm run production --silent) failed
2020-11-14 09:36:49,149 [ERROR] Error encountered during build of postbuild_0_first_access_data_network: Command 02_build_frontend failed
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 542, in run_config
CloudFormationCarpenter(config, self._auth_config).build(worklog)
File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 260, in build
changes['commands'] = CommandTool().apply(self._config.commands)
File "/usr/lib/python2.7/site-packages/cfnbootstrap/command_tool.py", line 117, in apply
raise ToolError(u"Command %s failed" % name)
ToolError: Command 02_build_frontend failed
2020-11-14 09:36:49,156 [ERROR] -----------------------BUILD FAILED!------------------------
cfn-init-cmd.log
2020-11-14 09:35:51,446 P30042 [INFO] ============================================================
2020-11-14 09:35:51,446 P30042 [INFO] Command 02_build_frontend
2020-11-14 09:36:49,141 P30042 [INFO] -----------------------Command Output-----------------------
2020-11-14 09:36:49,147 P30042 [INFO] events.js:292
2020-11-14 09:36:49,147 P30042 [INFO] throw er; // Unhandled 'error' event
2020-11-14 09:36:49,147 P30042 [INFO] ^
2020-11-14 09:36:49,147 P30042 [INFO]
2020-11-14 09:36:49,147 P30042 [INFO] Error: write EPIPE
2020-11-14 09:36:49,147 P30042 [INFO] at ChildProcess.target._send (internal/child_process.js:832:20)
2020-11-14 09:36:49,147 P30042 [INFO] at ChildProcess.target.send (internal/child_process.js:703:19)
2020-11-14 09:36:49,147 P30042 [INFO] at ChildProcessWorker.send (/var/app/staging/node_modules/laravel-mix/node_modules/jest-worker/build/workers/ChildProcessWorker.js:291:17)
2020-11-14 09:36:49,147 P30042 [INFO] at WorkerPool.send (/var/app/staging/node_modules/laravel-mix/node_modules/jest-worker/build/WorkerPool.js:32:34)
2020-11-14 09:36:49,147 P30042 [INFO] at Farm._process (/var/app/staging/node_modules/laravel-mix/node_modules/jest-worker/build/Farm.js:129:10)
2020-11-14 09:36:49,147 P30042 [INFO] at Farm._enqueue (/var/app/staging/node_modules/laravel-mix/node_modules/jest-worker/build/Farm.js:152:10)
2020-11-14 09:36:49,147 P30042 [INFO] at Farm._push (/var/app/staging/node_modules/laravel-mix/node_modules/jest-worker/build/Farm.js:159:12)
2020-11-14 09:36:49,147 P30042 [INFO] at /var/app/staging/node_modules/laravel-mix/node_modules/jest-worker/build/Farm.js:90:14
2020-11-14 09:36:49,148 P30042 [INFO] at new Promise (<anonymous>)
2020-11-14 09:36:49,148 P30042 [INFO] at Farm.doWork (/var/app/staging/node_modules/laravel-mix/node_modules/jest-worker/build/Farm.js:56:12)
2020-11-14 09:36:49,148 P30042 [INFO] at JestWorker._callFunctionWithArgs (/var/app/staging/node_modules/laravel-mix/node_modules/jest-worker/build/index.js:143:23)
2020-11-14 09:36:49,148 P30042 [INFO] at TaskRunner.runTask (/var/app/staging/node_modules/laravel-mix/node_modules/terser-webpack-plugin/dist/TaskRunner.js:41:26)
2020-11-14 09:36:49,148 P30042 [INFO] at enqueue (/var/app/staging/node_modules/laravel-mix/node_modules/terser-webpack-plugin/dist/TaskRunner.js:89:35)
2020-11-14 09:36:49,148 P30042 [INFO] at /var/app/staging/node_modules/laravel-mix/node_modules/terser-webpack-plugin/dist/TaskRunner.js:113:86
2020-11-14 09:36:49,148 P30042 [INFO] Emitted 'error' event on ChildProcess instance at:
2020-11-14 09:36:49,148 P30042 [INFO] at internal/child_process.js:836:39
2020-11-14 09:36:49,148 P30042 [INFO] at processTicksAndRejections (internal/process/task_queues.js:75:11) {
2020-11-14 09:36:49,148 P30042 [INFO] errno: -32,
2020-11-14 09:36:49,148 P30042 [INFO] code: 'EPIPE',
2020-11-14 09:36:49,148 P30042 [INFO] syscall: 'write'
2020-11-14 09:36:49,148 P30042 [INFO] }
2020-11-14 09:36:49,148 P30042 [INFO] ------------------------------------------------------------
2020-11-14 09:36:49,148 P30042 [ERROR] Exited with error code 1
/root/.npm/_logs/2020-11-14T06_49_39_693Z-debug.log
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/bin/npm', 'run', 'production' ]
2 info using npm@6.14.8
3 info using node@v14.15.0
4 verbose run-script [ 'preproduction', 'production', 'postproduction' ]
5 info lifecycle @~preproduction: @
6 info lifecycle @~production: @
7 verbose lifecycle @~production: unsafe-perm in lifecycle true
8 verbose lifecycle @~production: PATH: /usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/var/app/staging/node_modules/.bin:/sbin:/bin:/usr/sbin:/usr/bin
9 verbose lifecycle @~production: CWD: /var/app/staging
10 silly lifecycle @~production: Args: [
10 silly lifecycle '-c',
10 silly lifecycle 'node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel$
10 silly lifecycle ]
11 silly lifecycle @~production: Returned: code: 1 signal: null
12 info lifecycle @~production: Failed to exec production script
13 verbose stack Error: @ production: `node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=nod$
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:315:20)
13 verbose stack at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:315:20)
13 verbose stack at maybeClose (internal/child_process.js:1048:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
14 verbose pkgid @
15 verbose cwd /var/app/staging
16 verbose Linux 4.14.200-155.322.amzn2.x86_64
17 verbose argv "/usr/bin/node" "/bin/npm" "run" "production"
18 verbose node v14.15.0
19 verbose npm v6.14.8
20 error code ELIFECYCLE
21 error errno 1
22 error @ production: `node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/larav$
22 error Exit status 1
23 error Failed at the @ production script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
Upvotes: 1
Views: 1239
Reputation: 1976
Turns out NPM was running out of physical memory from the size of the dependencies. A t3.small instance has 2GB of memory. This was fixed by creating swap memory with the following deployment config:
commands:
00_setup_swap_memory:
test: test ! -e /var/swapfile
command: |
/bin/dd if=/dev/zero of=/var/swapfile bs=1M count=4096
/bin/chmod 600 /var/swapfile
/sbin/mkswap /var/swapfile
/sbin/swapon /var/swapfile
Upvotes: 1