diff --git a/aio/aio-builds-setup/dockerbuild/Dockerfile b/aio/aio-builds-setup/dockerbuild/Dockerfile index d77d210a5e..78432dfe50 100644 --- a/aio/aio-builds-setup/dockerbuild/Dockerfile +++ b/aio/aio-builds-setup/dockerbuild/Dockerfile @@ -1,5 +1,5 @@ # Image metadata and config -FROM debian:jessie +FROM debian:stretch LABEL name="angular.io PR preview" \ description="This image implements the PR preview functionality for angular.io." \ @@ -76,21 +76,20 @@ RUN apt-get update -y && apt-get install -y curl RUN curl --silent --show-error --location https://deb.nodesource.com/setup_10.x | bash - RUN curl --silent --show-error https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list -RUN echo "deb http://ftp.debian.org/debian jessie-backports main" | tee /etc/apt/sources.list.d/backports.list +RUN echo "deb http://ftp.debian.org/debian stretch-backports main" | tee /etc/apt/sources.list.d/backports.list # Install packages RUN apt-get update -y && apt-get install -y \ - chkconfig \ cron \ dnsmasq \ nano \ + nginx \ nodejs \ openssl \ rsyslog \ yarn -RUN apt-get install -t jessie-backports -y nginx -RUN yarn global add pm2@2 +RUN yarn global add pm2@3 # Set up log rotation @@ -151,8 +150,7 @@ RUN sed -i "s|{{\$AIO_PREVIEW_SERVER_PORT}}|$TEST_AIO_PREVIEW_SERVER_PORT|g" /et # Set up pm2 -RUN pm2 startup systemv -u root > /dev/null -RUN chkconfig pm2-root on +RUN pm2 startup --user root > /dev/null # Set up the shell scripts diff --git a/aio/aio-builds-setup/dockerbuild/scripts-js/lib/verify-setup/helper.ts b/aio/aio-builds-setup/dockerbuild/scripts-js/lib/verify-setup/helper.ts index f267e608dd..d5c65241ef 100644 --- a/aio/aio-builds-setup/dockerbuild/scripts-js/lib/verify-setup/helper.ts +++ b/aio/aio-builds-setup/dockerbuild/scripts-js/lib/verify-setup/helper.ts @@ -1,7 +1,6 @@ // Imports import * as cp from 'child_process'; import * as fs from 'fs'; -import * as http from 'http'; import * as path from 'path'; import * as shell from 'shelljs'; import {AIO_DOWNLOADS_DIR, HIDDEN_DIR_PREFIX} from '../common/constants'; @@ -105,18 +104,7 @@ class Helper { Object.keys(this.portPerScheme).forEach(scheme => suiteFactory(scheme, this.portPerScheme[scheme])); } - public verifyResponse(status: number | [number, string], regex: string | RegExp = /^/): VerifyCmdResultFn { - let statusCode: number; - let statusText: string; - - if (Array.isArray(status)) { - statusCode = status[0]; - statusText = status[1]; - } else { - statusCode = status; - statusText = http.STATUS_CODES[statusCode] || 'UNKNOWN_STATUS_CODE'; - } - + public verifyResponse(status: number, regex: string | RegExp = /^/): VerifyCmdResultFn { return (result: CmdResult) => { const [headers, body] = result.stdout. split(/(?:\r?\n){2,}/). @@ -131,7 +119,7 @@ class Helper { } expect(result.success).toBe(true); - expect(headers).toContain(`${statusCode} ${statusText}`); + expect(headers).toMatch(new RegExp(`HTTP/(?:1\\.1|2) ${status} `)); expect(body).toMatch(regex); }; } diff --git a/aio/aio-builds-setup/dockerbuild/scripts-js/lib/verify-setup/nginx.e2e.ts b/aio/aio-builds-setup/dockerbuild/scripts-js/lib/verify-setup/nginx.e2e.ts index 656973b205..4a58bad9f2 100644 --- a/aio/aio-builds-setup/dockerbuild/scripts-js/lib/verify-setup/nginx.e2e.ts +++ b/aio/aio-builds-setup/dockerbuild/scripts-js/lib/verify-setup/nginx.e2e.ts @@ -259,10 +259,10 @@ describe(`nginx`, () => { it('should disallow non-GET requests', async () => { await Promise.all([ - h.runCmd(`curl -iLX POST ${baseUrl}/42`).then(h.verifyResponse([405, 'Not Allowed'])), - h.runCmd(`curl -iLX PUT ${baseUrl}/42`).then(h.verifyResponse([405, 'Not Allowed'])), - h.runCmd(`curl -iLX PATCH ${baseUrl}/42`).then(h.verifyResponse([405, 'Not Allowed'])), - h.runCmd(`curl -iLX DELETE ${baseUrl}/42`).then(h.verifyResponse([405, 'Not Allowed'])), + h.runCmd(`curl -iLX POST ${baseUrl}/42`).then(h.verifyResponse(405)), + h.runCmd(`curl -iLX PUT ${baseUrl}/42`).then(h.verifyResponse(405)), + h.runCmd(`curl -iLX PATCH ${baseUrl}/42`).then(h.verifyResponse(405)), + h.runCmd(`curl -iLX DELETE ${baseUrl}/42`).then(h.verifyResponse(405)), ]); }); @@ -295,10 +295,10 @@ describe(`nginx`, () => { const url = `${scheme}://${host}/circle-build`; Promise.all([ - h.runCmd(`curl -iLX GET ${url}`).then(h.verifyResponse([405, 'Not Allowed'])), - h.runCmd(`curl -iLX PUT ${url}`).then(h.verifyResponse([405, 'Not Allowed'])), - h.runCmd(`curl -iLX PATCH ${url}`).then(h.verifyResponse([405, 'Not Allowed'])), - h.runCmd(`curl -iLX DELETE ${url}`).then(h.verifyResponse([405, 'Not Allowed'])), + h.runCmd(`curl -iLX GET ${url}`).then(h.verifyResponse(405)), + h.runCmd(`curl -iLX PUT ${url}`).then(h.verifyResponse(405)), + h.runCmd(`curl -iLX PATCH ${url}`).then(h.verifyResponse(405)), + h.runCmd(`curl -iLX DELETE ${url}`).then(h.verifyResponse(405)), ]).then(done); }); @@ -334,10 +334,10 @@ describe(`nginx`, () => { it('should disallow non-POST requests', done => { Promise.all([ - h.runCmd(`curl -iLX GET ${url}`).then(h.verifyResponse([405, 'Not Allowed'])), - h.runCmd(`curl -iLX PUT ${url}`).then(h.verifyResponse([405, 'Not Allowed'])), - h.runCmd(`curl -iLX PATCH ${url}`).then(h.verifyResponse([405, 'Not Allowed'])), - h.runCmd(`curl -iLX DELETE ${url}`).then(h.verifyResponse([405, 'Not Allowed'])), + h.runCmd(`curl -iLX GET ${url}`).then(h.verifyResponse(405)), + h.runCmd(`curl -iLX PUT ${url}`).then(h.verifyResponse(405)), + h.runCmd(`curl -iLX PATCH ${url}`).then(h.verifyResponse(405)), + h.runCmd(`curl -iLX DELETE ${url}`).then(h.verifyResponse(405)), ]).then(done); });