diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..d0e5d86584 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +FROM node:lts-buster-slim +RUN mkdir /usr/src/app +WORKDIR /usr/src/app +ENV PATH /usr/src/app/node_modules/.bin:$PATH +COPY package.json /usr/src/app/package.json +RUN npm install +RUN npm install react-scripts -g +CMD ["npm", "start"] \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000000..0aba0301d5 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,28 @@ +pipeline { + agent { + docker { + image 'node:lts-buster-slim' + args '-p 3000:3000' + } + } + environment { + CI = 'true' + } + stages { + stage('Install') { + steps { + sh 'npm install' + } + } + stage('Build') { + steps { + sh 'npm run build' + } + } + stage('Deploy') { + steps { + sh 'npm start' + } + } + } +} diff --git a/jenkins/Jenkinsfile b/jenkins/Jenkinsfile index 5b2e173ad9..fd5e7a5b37 100644 --- a/jenkins/Jenkinsfile +++ b/jenkins/Jenkinsfile @@ -22,8 +22,6 @@ pipeline { stage('Deliver') { steps { sh './jenkins/scripts/deliver.sh' - input message: 'Finished using the web site? (Click "Proceed" to continue)' - sh './jenkins/scripts/kill.sh' } } } diff --git a/jenkins/scripts/deliver.sh b/jenkins/scripts/deliver.sh index 21ddafd83f..910c2b9b35 100755 --- a/jenkins/scripts/deliver.sh +++ b/jenkins/scripts/deliver.sh @@ -1,29 +1,4 @@ #!/usr/bin/env sh -echo 'The following "npm" command builds your Node.js/React application for' -echo 'production in the local "build" directory (i.e. within the' -echo '"/var/jenkins_home/workspace/simple-node-js-react-app" directory),' -echo 'correctly bundles React in production mode and optimizes the build for' -echo 'the best performance.' -set -x npm run build -set +x - -echo 'The following "npm" command runs your Node.js/React application in' -echo 'development mode and makes the application available for web browsing.' -echo 'The "npm start" 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. "npm start"' -echo 'is followed by another command that retrieves the process ID (PID) value' -echo 'of the previously run process (i.e. "npm start") and writes this value to' -echo 'the file ".pidfile".' -set -x -npm start & -sleep 1 -echo $! > .pidfile -set +x - -echo 'Now...' -echo 'Visit http://localhost:3000 to see your Node.js/React application in action.' -echo '(This is why you specified the "args ''-p 3000:3000''" parameter when you' -echo 'created your initial Pipeline as a Jenkinsfile.)' +npm start \ No newline at end of file diff --git a/public/index.html b/public/index.html index 7bee027101..66f149cc69 100644 --- a/public/index.html +++ b/public/index.html @@ -19,7 +19,7 @@ work correctly both with client-side routing and a non-root public URL. Learn how to configure a non-root public URL by running `npm run build`. --> -