├── .github └── workflows │ └── build.yml ├── Dockerfile ├── LICENSE └── README.md /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: 'build images' 2 | 3 | on: 4 | workflow_dispatch: 5 | schedule: 6 | - cron: '7 5 * * *' 7 | push: 8 | 9 | jobs: 10 | docker: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - name: Checkout 14 | uses: actions/checkout@v3 15 | 16 | - name: Prepare 17 | id: prep 18 | run: | 19 | DOCKER_IMAGE=trion/ng-cli-e2e 20 | VERSION=latest 21 | SHORTREF=${GITHUB_SHA::8} 22 | 23 | #use branch as version 24 | if [[ $GITHUB_REF == refs/heads/* ]]; then 25 | VERSION=${GITHUB_REF#refs/heads/} 26 | [ $VERSION == "master" ] && VERSION=latest 27 | fi 28 | 29 | #use tag as version 30 | if [[ $GITHUB_REF == refs/tags/* ]]; then 31 | VERSION=${GITHUB_REF#refs/tags/} 32 | fi 33 | 34 | #use version as image tag 35 | TAGS="${DOCKER_IMAGE}:${VERSION}" 36 | 37 | # If version is a number also tag it 'latest'. 38 | if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then 39 | TAGS="$TAGS,${DOCKER_IMAGE}:latest" 40 | fi 41 | 42 | echo ::set-output name=tags::${TAGS} 43 | echo ::set-output name=docker_image::${DOCKER_IMAGE} 44 | 45 | - name: Set up QEMU 46 | uses: docker/setup-qemu-action@master 47 | with: 48 | platforms: all 49 | 50 | - name: Set up Docker Buildx 51 | id: buildx 52 | uses: docker/setup-buildx-action@master 53 | 54 | - name: Cache Docker layers 55 | uses: actions/cache@v3 56 | with: 57 | path: /tmp/.buildx-cache 58 | key: ${{ runner.os }}-buildx-${{ github.sha }} 59 | restore-keys: | 60 | ${{ runner.os }}-buildx- 61 | 62 | - name: Login to DockerHub 63 | if: github.event_name != 'pull_request' 64 | uses: docker/login-action@v2 65 | with: 66 | username: ${{ secrets.DOCKER_USERNAME }} 67 | password: ${{ secrets.DOCKER_PASSWORD }} 68 | 69 | - name: Build 70 | uses: docker/build-push-action@v3 71 | with: 72 | builder: ${{ steps.buildx.outputs.name }} 73 | context: . 74 | file: ./Dockerfile 75 | #platforms: linux/amd64,linux/arm64,linux/arm/v7 76 | platforms: linux/amd64,linux/arm64 77 | push: true 78 | tags: ${{ steps.prep.outputs.tags }} 79 | cache-from: type=local,src=/tmp/.buildx-cache 80 | cache-to: type=local,dest=/tmp/.buildx-cache-new 81 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM trion/ng-cli-karma:latest 2 | 3 | LABEL ng-cli-karma='20.0.1' 4 | 5 | ARG USER_ID=1000 6 | USER root 7 | 8 | RUN apt-get update && apt-get install -y --no-install-recommends \ 9 | bzip2 \ 10 | unzip \ 11 | xz-utils \ 12 | apt-transport-https \ 13 | ffmpeg \ 14 | openjdk-17-jre \ 15 | ca-certificates p11-kit \ 16 | && rm -rf /var/lib/apt/lists/* 17 | 18 | 19 | USER $USER_ID 20 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Docker Angular CLI e2e 2 | Run Angular end-to-end tests with Protractor / Webdriver inside docker container using Google Chrome / chromium. 3 | Works great on CI servers. 4 | 5 | Example usage 6 | ``` 7 | docker run -u $(id -u) --rm -v "$PWD":/app trion/ng-cli-e2e ng e2e 8 | ``` 9 | 10 | ## Locking the ChromeDriver version 11 | Angular CLI uses webdriver for protractor tests. The npm package to install/update webdriver checks every hour if a new version is available and updates to the latest version. This might break your build if webdriver requires a later version of the Chrome browser. (See https://github.com/angular/webdriver-manager/blob/HEAD/docs/versions.md ) 12 | The solution is to run an update to a fixed version just before the actual build happens. This will prevent installation of a later version. 13 | 14 | For example: 15 | 16 | ``` 17 | docker ... trion/ng-cli-e2e:11.0.0 \ 18 | ./node_modules/protractor/bin/webdriver-manager update --versions.chrome 86.0.4240.198 && \ 19 | ng e2e --webdriver-update=false 20 | ``` 21 | --------------------------------------------------------------------------------