How to fix SSH Webpack build timeout on CI/CD (Git

2019-07-26 17:00发布

I've created a CI/CD integration with Gitlab and keep stalling out on the final compilation of webpack and assets when running through the CI/CD.

This is for a Linux 16.04 t2.small AWS instance and I'm curious if it is a memory / processor issue, though it seems to compile fine if I SSH into the server and run the cmd directly.

deploy.sh

#!/bin/bash
set -e

echo "Deploying to $DEPLOY_SERVER"

# Once inside the server, run updateAndRestart.sh
ssh -tt -o "StrictHostKeyChecking no" ubuntu@$DEPLOY_SERVER 'bash' < ./config/updateAndRestart.sh

updateAndRestart.sh

#!/bin/bash
set -e

# Delete the old repo
rm -rf /home/ubuntu/deploy/application/client

# clone the repo fresh
git clone git@gitlab.com:repo/repo.git /home/ubuntu/deploy/application/client

# enter the new repo
cd /home/ubuntu/deploy/application/client

# install npm packages
echo "Running npm install"
npm install

# let resources recover
sleep 10s

echo "Running npm run build"
# build the new package
node --max_old_space_size=4096 ./node_modules/webpack/bin/webpack.js --env=production

I added the sleep method thinking there might be some issue with npm install hoarding resources and moving too quickly, though it did not resolve the problem. It gets to this final step just fine, then times out:

ubuntu@host:~/deploy/application/client$ node --max_old_spa
<-157:~/deploy/application/client$ node --max_old_spac                         e_size=4096 ./node_module

<ient$ node --max_old_space_size=4096 ./node_modules                         /webpack/bin/webpack.js -

<_size=4096 ./node_modules/webpack/bin/webpack.js --                         env=productionPulling docker image gitlab/gitlab-runner-helper:x86_64-10efa505 ...
ERROR: Job failed: execution took longer than 10m0s seconds

Not entirely sure about the gitlab-runner-helper starting again, but this is what happens right when things time out.

Generally when running the build cmd, node --max_old_space_size=4096 ./node_modules/webpack/bin/webpack.js --env=production, it prompts with more details such as

Building in:  production
clean-webpack-plugin: /home/ubuntu/deploy/application/client/public/*.js has been removed.
ℹ 「atl」: Using typescript@2.9.2 from typescript
ℹ 「atl」: Using tsconfig.json from /home/ubuntu/deploy/application/client/tsconfig.json
ℹ 「atl」: Checking started in a separate process...
ℹ 「atl」: Time: 1319ms

which I never see when running from the SSH deploy. Is there anything I can do besides upgrading my ec2 size? Why would this work directly via SSH just fine, but have issues when doing so from the CI/CD of Gitlab?

0条回答
登录 后发表回答