diff --git a/Dockerfile.tests b/Dockerfile.tests new file mode 100644 index 0000000000..d288e269fd --- /dev/null +++ b/Dockerfile.tests @@ -0,0 +1,2 @@ +FROM node:lts +RUN apt-get update && apt-get install -y --no-install-recommends gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget diff --git a/curriculum/test/test-challenges.js b/curriculum/test/test-challenges.js index 7ea6d28125..76b0410a83 100644 --- a/curriculum/test/test-challenges.js +++ b/curriculum/test/test-challenges.js @@ -108,8 +108,15 @@ async function runTests() { logLevel: 0 }); browser = await puppeteer.launch({ - args: ['--no-sandbox'] - // dumpio: true + args: [ + // Required for Docker version of Puppeteer + '--no-sandbox', + '--disable-setuid-sandbox', + // This will write shared memory files into /tmp instead of /dev/shm, + // because Docker’s default for /dev/shm is 64MB + '--disable-dev-shm-usage' + // dumpio: true + ] }); global.Worker = createPseudoWorker(await newPageContext(browser)); page = await newPageContext(browser); diff --git a/docker-compose.tests.yml b/docker-compose.tests.yml new file mode 100644 index 0000000000..7c552ac67e --- /dev/null +++ b/docker-compose.tests.yml @@ -0,0 +1,25 @@ +# Docker Compose file for FreeCodeCamp +# +# Before run tests, bootstrap project with commands from a docker-compose.yml +# +# Note, first run takes a long time. +# +# Run with: +# npm run docker:test -- -c "npm run test" +# or +# npm run docker:test -- -c "npm run test:curriculum" +# npm run docker:test -- -c "npm run test:client" +# npm run docker:test -- -c "npm run test:server" +# +# If need to test one challenge: +# npm run docker:test -- -c "cd curriculum && npm run test -f 'Title of Challenge'" +# +version: '3' +services: + tests: + build: + context: . + dockerfile: Dockerfile.tests + volumes: + - .:/app + working_dir: /app diff --git a/package.json b/package.json index 2d4c836aa0..c2d94947ea 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "docker:install": "npm run docker:bash -- -c \"npm install\"", "docker:install2": "docker-compose run --rm -u root freecodecamp bash -c \"npm install -g npm@5.7.1 && su node -c 'npm install'\"", "docker:seed": "npm run docker:bash -- -c \"npm run seed\"", - "docker:test": "npm run docker:bash -- -c \"npm run test\"", + "docker:test": "docker-compose -f docker-compose.tests.yml run --rm tests bash", "ensure-env": "cross-env DEBUG=fcc:* node ./tools/scripts/ensure-env.js", "format": "npm run lint -- --fix", "hooks:install": "node node_modules/husky/husky.js install",