-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproduction.sh
37 lines (34 loc) · 1.71 KB
/
production.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
echo 'The following "npm" command builds your Node.js/React application for'
echo 'production in the local "build" directory (i.e. within the appropriate'
echo 'subdirectory of "/var/jenkins_home/workspace/"), correctly bundles React'
echo 'in production mode and optimizes the build for the best performance.'
set -x
npm run build
set +x
echo 'The following "npm" command downloads and installs the npm serve module'
echo '(for serving static sites in production environments) to the local'
echo '"node_modules" directory (i.e. within the appropriate subdirectory of'
echo '"/var/jenkins_home/workspace/"), which means that this module should not'
echo 'need to be downloaded after this Pipeline''s initial run for a given'
echo 'branch.'
set -x
npm install serve
set +x
echo 'The following "serve" command runs the npm serve module (downloaded'
echo 'above) deploys your Node.js/React application (built above in production'
echo 'mode) for production and makes the application available for web browsing.'
echo 'The "serve" command has a trailing ampersand so that the command runs'
echo 'as a background process (i.e. asynchronously). Otherwise, this command'
echo 'can pause running builds of CI/CD applications indefinitely. "serve"'
echo 'is followed by another command that retrieves the process ID (PID) value'
echo 'of the previously run process (i.e. "serve") and writes this value to'
echo 'the file ".pidfile".'
set -x
./node_modules/serve/bin/serve.js -c 0 -s build &
sleep 1
echo $! > .pidfile
set +x
echo 'Now...'
echo 'Visit http://localhost:5000 to see your Node.js/React application in action.'
echo '(This is why you specified the "args ''-p 5000:5000''" parameter when you'
echo 'created your initial Pipeline as a Jenkinsfile.)'