teracyhq / docker-files

Teracy docker-files project to build common Docker images
https://hub.docker.com/r/teracy/
MIT License
92 stars 55 forks source link

Can't run tests from Ubuntu server #63

Closed sddev-dotnet closed 4 years ago

sddev-dotnet commented 5 years ago

I have a brand new Ubuntu 18.04 server with Docker CE installed on it. I am trying to build my angular 7 cli project and have been getting an error and am unable to run my test.

Here is my Dockerfile

FROM teracy/angular-cli:7.3 as build

WORKDIR /app
COPY /Rubbl.Web.Website/package*.json ./
RUN npm i

COPY ./Rubbl.Web.Website .

# Run unit tests
RUN npm run test-headless

# Copy unit test results to /test
WORKDIR /app/src/test-results
RUN mkdir /test
RUN cp *.xml /test

WORKDIR /app
RUN mkdir /test/coverage
RUN cp -r coverage/* /test/coverage
RUN ng build --prod

WORKDIR /publish
RUN cp -r /app/dist/* ./

FROM nginx AS publish

RUN apt-get update
RUN apt-get install gettext -y

WORKDIR /test-results
COPY --from=build /test .

WORKDIR /app
COPY --from=build /publish/rubbl-web-website /usr/share/nginx/html
RUN rm /etc/nginx/conf.d/default.conf
COPY default.conf /etc/nginx/conf.d/
COPY ./startup.sh .

RUN chmod +x ./startup.sh

ENTRYPOINT ["/bin/bash", "-c", "./startup.sh"]

My Karma config:

// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
process.env.CHROME_BIN = require('puppeteer').executablePath();

module.exports = function (config) {
  config.set({
    basePath: '',
    frameworks: ['jasmine', '@angular-devkit/build-angular'],
    plugins: [
      require('karma-jasmine'),
      require('karma-chrome-launcher'),
      require('karma-jasmine-html-reporter'),
      require('karma-coverage-istanbul-reporter'),
      require('@angular-devkit/build-angular/plugins/karma'),
      require('karma-junit-reporter')
    ],
    client: {
      clearContext: false // leave Jasmine Spec Runner output visible in browser
    },
    captureTimeout: 60000,
    browserDisconnectTimeout: 10000,
    browserDisconnectTolerance: 1,
    browserNoActivityTimeout: 60000,
    coverageIstanbulReporter: {
      dir: require('path').join(__dirname, '../coverage/rubbl-web-website'),
      reports: ['html', 'lcovonly', 'text-summary', 'cobertura'],
      fixWebpackSourcePaths: true
    },
    reporters: ['progress', 'kjhtml', 'junit'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['Chrome', 'ChromeHeadless'],
    customLaunchers: {
      ChromeHeadlessCI: {
        base: 'ChromeHeadless',
        flags: ['--no-sandbox', '--disable-translate', '--disable-extensions']
      }
    },
    singleRun: false,
    files: [
      "./assets/environment/environment.js",
    ],
    junitReporter: {
      outputDir: 'test-results', // results will be saved as $outputDir/$browserName.xml
      outputFile: undefined, // if included, results will be saved as $outputDir/$browserName/$outputFile
      suite: '', // suite will become the package name attribute in xml testsuite element
      useBrowserName: true, // add browser name to report and classes names
      nameFormatter: undefined, // function (browser, result) to customize the name attribute in xml testcase element
      classNameFormatter: undefined, // function (browser, result) to customize the classname attribute in xml testcase element
      properties: {}, // key value pair of properties to add to the <properties> section of the report
      xmlVersion: null // use '1' if reporting to be per SonarQube 6.2 XML format
    }
  });
};

And here is the error I am getting: image

hoatle commented 5 years ago

assigned to @datphan for help.

sddev-dotnet commented 5 years ago

I was able to get it working by updating my custom launcher to look like this:

customLaunchers: {
      ChromeHeadlessCI: {
        base: 'ChromeHeadless',
        flags: ['--no-sandbox', '--disable-translate', '--disable-extensions', '--disable-gpu', '--disable-features=VizDisplayCompositor']
      }
    },

apparently this is an issue that keeps getting fixed and then reoccurs with chrome.