Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce the cypress/factory image #812

Merged
merged 151 commits into from
Jan 17, 2023
Merged
Show file tree
Hide file tree
Changes from 143 commits
Commits
Show all changes
151 commits
Select commit Hold shift + click to select a range
f245471
in progress
mjhenkes Dec 8, 2022
75a9d07
latest updates
mjhenkes Dec 14, 2022
72ffc5b
latest changes
mjhenkes Dec 14, 2022
f2dd61d
Second attempt
mjhenkes Dec 16, 2022
a935881
Latest changes
mjhenkes Dec 19, 2022
b80eae2
Remove original docker factory
mjhenkes Dec 19, 2022
cfba5a8
Rename second factory iteration to factory
mjhenkes Dec 19, 2022
5690030
Merge branch 'master' into matth/docker-factory
mjhenkes Dec 20, 2022
399b5cf
Fixes for installing chrome and cypress standalone
mjhenkes Dec 20, 2022
a02de28
add test project
mjhenkes Dec 20, 2022
a02b113
more test cases
mjhenkes Dec 20, 2022
fcaa31f
readme updates mostly
mjhenkes Dec 20, 2022
540c272
readme update
mjhenkes Dec 20, 2022
f84dd8e
remove unused factory test.
mjhenkes Dec 20, 2022
b3e585d
naming docker images in docker compose
mjhenkes Dec 21, 2022
a9c90ce
Clean up some todos, add webkit install step
mjhenkes Dec 21, 2022
d310ffb
rename install scripts
mjhenkes Dec 21, 2022
d00b278
minor updates
mjhenkes Dec 21, 2022
22e1af5
use edge stable
mjhenkes Jan 3, 2023
c3b062b
docs and edge version update
mjhenkes Jan 3, 2023
da1dc2b
add tags
mjhenkes Jan 3, 2023
d7ed4c1
use ENV instead of yml anchors
mjhenkes Jan 3, 2023
40e99da
testing circle build
mjhenkes Jan 4, 2023
2d4e1cc
new image???
mjhenkes Jan 4, 2023
ef7d1e9
try again
mjhenkes Jan 4, 2023
1f785a3
check envs
mjhenkes Jan 4, 2023
635cb6a
experiment
mjhenkes Jan 4, 2023
74cabb4
just update bash_env
mjhenkes Jan 4, 2023
9329d19
more testing
mjhenkes Jan 4, 2023
3835a84
maybe this
mjhenkes Jan 4, 2023
7a1d876
i don't think this is going to work
mjhenkes Jan 4, 2023
c1f3a73
?
mjhenkes Jan 4, 2023
4305a7c
maybe we need to make it first?
mjhenkes Jan 4, 2023
f4d9e2e
?
mjhenkes Jan 4, 2023
b3f6213
:/
mjhenkes Jan 4, 2023
80fa14d
>:(
mjhenkes Jan 4, 2023
09d2afa
derp
mjhenkes Jan 4, 2023
f932b39
use current directory
mjhenkes Jan 4, 2023
06e3c14
buildx
mjhenkes Jan 4, 2023
7cad6b0
override platform
mjhenkes Jan 4, 2023
a65e2fe
load docker images
mjhenkes Jan 4, 2023
386c1c4
more experiments
mjhenkes Jan 4, 2023
5d66ff7
target isn't a key word
mjhenkes Jan 4, 2023
aba8e2a
grumpy
mjhenkes Jan 4, 2023
e16770c
actually load arm64 version
mjhenkes Jan 4, 2023
8688b6a
testing?
mjhenkes Jan 4, 2023
0b1ae04
circle syntax
mjhenkes Jan 4, 2023
0576601
once again
mjhenkes Jan 4, 2023
11bd2ed
try this
mjhenkes Jan 4, 2023
1413d99
try testing arm64??
mjhenkes Jan 4, 2023
4340255
random buildkit workaround???
mjhenkes Jan 4, 2023
24a0c7d
more robust env setting
mjhenkes Jan 4, 2023
6f7d842
can't inspect i guess
mjhenkes Jan 4, 2023
96b08f0
try it again without syntax errors
mjhenkes Jan 4, 2023
d9d5a44
try using buildx
mjhenkes Jan 5, 2023
21348fa
yml
mjhenkes Jan 5, 2023
bac9191
try docker driver because i don't want to run a local registry :sob:
mjhenkes Jan 5, 2023
7979e7c
make a new builder
mjhenkes Jan 5, 2023
f696030
try with a local registry???
mjhenkes Jan 5, 2023
4612876
testing
mjhenkes Jan 5, 2023
df8de33
Try pushing to a local repo
mjhenkes Jan 5, 2023
bdbb698
fiddle fiddle
mjhenkes Jan 5, 2023
cc914a4
wait longer i guess
mjhenkes Jan 5, 2023
8129fc1
Merge branch 'master' into matth/docker-factory
mjhenkes Jan 5, 2023
24c1a81
oops typo
mjhenkes Jan 5, 2023
b696e07
try it on an arm machine
mjhenkes Jan 5, 2023
8543b09
env
mjhenkes Jan 5, 2023
4bce39b
yay it failed like it should have!
mjhenkes Jan 5, 2023
1e06e57
lol, i bet this fails due to something dumb
mjhenkes Jan 5, 2023
46289f0
told you so
mjhenkes Jan 5, 2023
e8e6d16
typo
mjhenkes Jan 5, 2023
029bfbc
colon
mjhenkes Jan 5, 2023
735e738
schema violations, i'll be back
mjhenkes Jan 5, 2023
d611e0e
maybe this?
mjhenkes Jan 5, 2023
3890cc0
don't matrix resource class
mjhenkes Jan 5, 2023
dc070a6
no s
mjhenkes Jan 5, 2023
232f70a
fix syntax
mjhenkes Jan 5, 2023
fc2d2e6
lots of changes so low probability that this works right off.
mjhenkes Jan 5, 2023
9e044ef
fix some typos and rename some things.
mjhenkes Jan 5, 2023
5df97ab
run all commands on all included
mjhenkes Jan 5, 2023
4d26c69
i <3 yaml
mjhenkes Jan 5, 2023
14d4be7
combine again
mjhenkes Jan 5, 2023
384f65a
not a string
mjhenkes Jan 5, 2023
2beec11
combine into one workflow
mjhenkes Jan 5, 2023
3e3a9b7
conditional testing
mjhenkes Jan 5, 2023
da956b3
alias
mjhenkes Jan 5, 2023
f175c00
alias in the right place
mjhenkes Jan 5, 2023
e0637e3
changes around building images to get us ready for pushing.
mjhenkes Jan 6, 2023
44a7ffd
name syntax error?
mjhenkes Jan 6, 2023
f60bc19
maybe this?
mjhenkes Jan 6, 2023
00985c3
yml is great
mjhenkes Jan 6, 2023
7b9f07b
remove dead end
mjhenkes Jan 6, 2023
14e4e31
missed a colon
mjhenkes Jan 6, 2023
cecf647
omg
mjhenkes Jan 6, 2023
551e20a
use correct env
mjhenkes Jan 6, 2023
d1afe6b
fix browsers push job
mjhenkes Jan 6, 2023
aa0723f
update halt if exist
mjhenkes Jan 6, 2023
818344e
un-comment workflows
mjhenkes Jan 6, 2023
bb4473a
don't use undeclared parameters
mjhenkes Jan 6, 2023
52a5029
circle cleanup
mjhenkes Jan 6, 2023
cc02ba5
more cleanup
mjhenkes Jan 6, 2023
a92df3c
reduce more
mjhenkes Jan 6, 2023
714ce31
i had to mess something up
mjhenkes Jan 6, 2023
d88cd46
minor updates
mjhenkes Jan 6, 2023
1a83170
update comment
mjhenkes Jan 6, 2023
3063473
check versions
mjhenkes Jan 6, 2023
3b7e8b4
remove params
mjhenkes Jan 6, 2023
4ddbda5
try again
mjhenkes Jan 6, 2023
ae1a0f0
check against the right version
mjhenkes Jan 6, 2023
3abf60e
check cypress version
mjhenkes Jan 6, 2023
2f4d47e
new included image version string
mjhenkes Jan 6, 2023
602a629
clean up
mjhenkes Jan 9, 2023
0cf376f
updated notes on env file
mjhenkes Jan 9, 2023
f7b0d5d
Self review changes
mjhenkes Jan 9, 2023
416e9f5
more self review changes
mjhenkes Jan 9, 2023
497d1ec
remove test project and test folder
mjhenkes Jan 9, 2023
2f0a0e9
Updated readme
mjhenkes Jan 9, 2023
65cde5d
updating contributing guide
mjhenkes Jan 9, 2023
1ba948b
tweak
mjhenkes Jan 9, 2023
9ff0ffb
note
mjhenkes Jan 9, 2023
31e9c8c
Remove scripts
mjhenkes Jan 9, 2023
7a4b9ee
Apply suggestions from code review
mjhenkes Jan 10, 2023
6f9dc17
pr updates
mjhenkes Jan 10, 2023
88bc507
update
mjhenkes Jan 10, 2023
766bb13
Apply suggestions from code review
mjhenkes Jan 10, 2023
dbb5f53
Moved api up
mjhenkes Jan 10, 2023
d77705f
specify further in api
mjhenkes Jan 10, 2023
b920810
use inherit for logging
mjhenkes Jan 10, 2023
2b9e19d
adding example reducing the size of the docker container.
mjhenkes Jan 10, 2023
a2ebad4
update default version location
mjhenkes Jan 10, 2023
4e7a677
Update factory/README.md
mjhenkes Jan 10, 2023
733535a
changing command to docker compose from docker-compose
mjhenkes Jan 11, 2023
60088df
Adding instructions to build locally to the contributing document.
mjhenkes Jan 11, 2023
582fbcf
adding context to push jobs
mjhenkes Jan 11, 2023
c1cbef4
use newest cypress version
mjhenkes Jan 11, 2023
77d6d88
add no_output_timeout for included container.
mjhenkes Jan 11, 2023
1765001
move timeout
mjhenkes Jan 11, 2023
03b22d0
release latest tag for the factory
mjhenkes Jan 13, 2023
2e8fdb2
Apply suggestions from code review
mjhenkes Jan 13, 2023
2ff0ca4
Update factory/README.md
mjhenkes Jan 13, 2023
bb6cb49
Update factory/README.md
mjhenkes Jan 13, 2023
d95f3e6
Update factory/README.md
mjhenkes Jan 13, 2023
23426bf
Update factory/README.md
mjhenkes Jan 13, 2023
406430e
Update factory/README.md
mjhenkes Jan 13, 2023
e959404
Apply suggestions from code review
mjhenkes Jan 13, 2023
8409e5b
add brief one off release instructions.
mjhenkes Jan 13, 2023
c625820
try quotes
mjhenkes Jan 13, 2023
0c55c28
more quotes
mjhenkes Jan 13, 2023
d0beaee
fix versions test
mjhenkes Jan 13, 2023
67c00c7
try it again
mjhenkes Jan 13, 2023
bd64f04
PR Feedback
mjhenkes Jan 17, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 24 additions & 58 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,79 +12,47 @@ All contributors are expecting to abide by our [Code of Conduct](https://github.

⚠️ As a rule, unless there are extraordinary circumstances, we do NOT replace the existing Docker images. Replacing the images already used by people is dangerous, since it replaces the versions of tools without warning. We have such failed experience once, and do not want to repeat this mistake. Thus instead of replacing an existing image, in 99% of the cases we publish a new Docker image.

### Add new base image
### Building locally

To create a new base image follow these steps
We use docker compose to build the factory locally.

1. run `yarn add:base -- <new version>` script. For example `yarn add:base -- 13.6.0`

It will create a new folder `base/<new version>` and output versions of tools installed: Node, npm, yarn, etc. See [generate-base-image.js](scripts/generate-base-image.js) file for details.

2. open a pull request.

The new image will be built and tested on CI and pushed to Docker Hub once the PR is approved and merged to `master`.

**note:** we install Chinese fonts in the base image to allow correct testing of [cypress-documentation](https://github.com/cypress-io/cypress-documentation) site that includes several translations of the Cypress docs. Without Chinese fonts the pages have broken rendering.

### Add new browser image

To create a new image with the specific browser versions needed to run your cypress tests.

1. Run `yarn add:browser <base image tag> --chrome=<chrome version> --firefox=<firefox version> --edge`. For example `yarn add:browser 16.5.0 --chrome=94.0.4606.71 --firefox=93.0`.

This will create a new folder `browser/node<node version>-chrome<chrome version>-ff<firefox version>-edge` See [generate-browser-image.js](scripts/generate-browser-image.js) file for details.

2. Open a pull request.

**Important ⚠️** In order to properly generate a browser image, you must specify a version of Chrome, or a version of Firefox, or a version of Edge.

**note:** The Edge browser will always default to the latest stable release. There is currently no way to specify the downloaded version. For this reason, when generating an image with Edge support users should only pass `--edge`.

**note:** No major browsers are currently compatible with `arm64`, so browsers images will be missing those browsers on `linux/arm64` architecture. As time passes and these become available, we will introduce them to the `arm64` images as well: https://github.com/cypress-io/cypress-docker-images/issues/695.

### Add new included image

To create a new image with Cypress pre-installed globally

1. Run `yarn add:included -- <Cypress version> <base image tag>`. For example `yarn add:included -- 9.4.1 cypress/browsers:node16.13.2-chrome97-ff96`.
```bash
cd factory
docker compose build factory
```

**Important ⚠️** please use `cypress/browsers` Docker image with the latest Node version matching the major version of Node included with Cypress. For example, if Cypress is shipping 16.5.0 and the latest 16.x is 16.14.0, ship the included image with Node 16.14.0.
With the factory image built, you can now build the other included images

This will create a new folder `included/<Cypress version>` See [generate-included-image.js](scripts/generate-included-image.js) file for details.
```bash
# This builds the 'included' image specified in the docker-compose file.
docker compose build included

2. Open a pull request.
# This builds all images specified in the docker-compose file.
docker compose build
```

#### Handling included images with different node versions
Or you can then run tests in the test-project

If there is already a `cypress/included` image with a specific version, but you need a different Node version or browser version, just create a new included image per the instructions above and a folder with the name `<Cypress version>-<base image tag> will be created.`
```bash
cd test-project

**Important ⚠️** This only applies if there is an existing `cypress/included` image with the same version.
# set the environment variables from factory/.env in your terminal.
set -a && . ../.env && set +a

## Tagging the latest image
# run the test in an image built on top of the factory.
docker compose run test-factory-all-included
```

We build individual base images that match Node versions: `10.18.1`, `12.12.0`, `12.18.2`, etc. We also tag some of the images with major version: `base:10`, `base:12`. We also tag one image `base:latest`. In general, you should use the explicit version like `base:12.18.0` because it guarantees that the Docker image will never be suddenly updated.
### Updating images

To tag new image, like `base:12.18.2` need to do the following from a local machine
To produce new updated images, simply open a PR with the desired version(s) updated in the `factory/.env` file. Once the PR is merged into master the corresponding images will be pushed to dockerhub.

```text
# pull the image to tag
$ docker pull cypress/base:12.18.2
# tag that image with major version
$ docker tag cypress/base:12.18.2 cypress/base:12
# tag that image with "latest"
$ docker tag cypress/base:12.18.2 cypress/base:latest

# push the new images (which are the same)
$ docker push cypress/base:12
$ docker push cypress/base:latest
```
In general, `factory/.env` master should contain the latest versions we officially support. If you need to release an older version please modify `circle.yml` to push releases from a feature branch instead of setting the version in master to older versions.

## Minimize image sizes

By default, the current base image is `bullseye-slim`. This dramatically decreases the size of all images. Other optimizations have been made to the Dockerfiles per Docker's recommendations.

In order to allow for older images to be smaller, you can run the scripts above using existing node versions, Cypress versions, and browser versions. The scripts will recognize that a folder already exists, and append `-slim` to the folder. You can then update the folder name in your workflow, and use the images like you already were.

Node versions less than or equal to Node 14 will use the `buster-slim` base image if they are recreated. Older images may still rely on `buster`.

To see the final size of an image, you can use command [`docker images`](https://docs.docker.com/engine/reference/commandline/images/)
Expand Down Expand Up @@ -157,8 +125,6 @@ In CI, the images are built and tested in real `arm64` and `x64` architectures.
└─────────────────────────────────────────────┘
```

It would be nice to re-publish the Docker Hub images verbatim to ECR instead of building twice, but more work needs to be done in this area - see the `push-images` step in `circle.yml` for details.

A current limitation is that no `arm64` images have browser binaries - see https://github.com/cypress-io/cypress-docker-images/issues/695 for details. [`global-profile.sh`](./scripts/for-images/global-profile.sh) is placed in `/etc/bash.bashrc`, so Arm Docker users will see a warning about this limitation.

### Updating images to add `linux/arm64`
Expand Down
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

These images provide all of the required dependencies for running Cypress in Docker.

We build three main images, click on the image name to see the available tags and versions.
We build four images, click on the image name to see the available tags and versions.

| Image | Default | Description | Monthly pulls |
| ---------------------------- | --------------------------- | --------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| [cypress/base](base) | `cypress/base:16.13.0` | All operating system dependencies, no Cypress, and no browsers. | [![Docker Pulls](https://img.shields.io/docker/pulls/cypress/base.svg?maxAge=604800)](https://hub.docker.com/r/cypress/base/) |
| [cypress/browsers](browsers) | `cypress/browsers:chrome69` | All operating system dependencies and some browsers. | [![Docker Pulls](https://img.shields.io/docker/pulls/cypress/browsers.svg?maxAge=604800)](https://hub.docker.com/r/cypress/browsers/) |
| [cypress/included](included) | `cypress/included:9.4.1` | All operating system dependencies, Cypress, and some browsers installed globally. | [![Docker Pulls](https://img.shields.io/docker/pulls/cypress/included.svg?maxAge=604800)](https://hub.docker.com/r/cypress/included/) |
| Image | Default | Description | Monthly pulls |
| -------------------------------------------------------------- | --------------------------- | ---------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| [cypress/factory](https://hub.docker.com/r/cypress/factory/) | `cypress/factory:1.0.0` | A base image template which can be used with ARGs to create a custom docker image. | [![Docker Pulls](https://img.shields.io/docker/pulls/cypress/factory.svg?maxAge=604800)](https://hub.docker.com/r/cypress/factory/) |
| [cypress/base](https://hub.docker.com/r/cypress/base/) | `cypress/base:16.13.0` | All operating system dependencies, no Cypress, and no browsers. | [![Docker Pulls](https://img.shields.io/docker/pulls/cypress/base.svg?maxAge=604800)](https://hub.docker.com/r/cypress/base/) |
| [cypress/browsers](https://hub.docker.com/r/cypress/browsers/) | `cypress/browsers:chrome69` | All operating system dependencies, no Cypress, and some browsers. | [![Docker Pulls](https://img.shields.io/docker/pulls/cypress/browsers.svg?maxAge=604800)](https://hub.docker.com/r/cypress/browsers/) |
| [cypress/included](https://hub.docker.com/r/cypress/included/) | `cypress/included:9.4.1` | All operating system dependencies, Cypress, and some browsers installed globally. | [![Docker Pulls](https://img.shields.io/docker/pulls/cypress/included.svg?maxAge=604800)](https://hub.docker.com/r/cypress/included/) |

Of these images, we provide multiple tags for various operating systems and specific browser versions. These allow you to target specific combinations you need.

Expand All @@ -20,10 +21,15 @@ It is recommended to use a specific image tag, and not rely on the `default` tag

All of the images and tags are published to DockerHub under

- [https://hub.docker.com/r/cypress/factory](https://hub.docker.com/r/cypress/factory)
- [https://hub.docker.com/r/cypress/base](https://hub.docker.com/r/cypress/base)
- [https://hub.docker.com/r/cypress/browsers](https://hub.docker.com/r/cypress/browsers)
- [https://hub.docker.com/r/cypress/included](https://hub.docker.com/r/cypress/included)

## Cypress/Factory

Don't see the exact combination of cypress, node and browser versions you need for your test environment? Checkout our [cypress/factory](factory). You can use it to generate a custom image to fit your needs.

## Examples

These images have all dependencies necessary to install and run Cypress. Just install your NPM dependencies (including Cypress) and run the tests. We utilize many of these docker images in our own projects, with different CI providers.
Expand Down
Loading