1*cc02d7e2SAndroid Build Coastguard Worker# Docker images used for gRPC testing 2*cc02d7e2SAndroid Build Coastguard Worker 3*cc02d7e2SAndroid Build Coastguard WorkerMost of our linux tests on the CI run under a docker container, since that makes it easier 4*cc02d7e2SAndroid Build Coastguard Workerto maintain the test environment and the dependencies. Having an easily reproducible test 5*cc02d7e2SAndroid Build Coastguard Workerenvironment also make it easier to reproduce issues we see on CI locally. 6*cc02d7e2SAndroid Build Coastguard Worker 7*cc02d7e2SAndroid Build Coastguard WorkerThe docker image definitions we use live under `tools/dockerfile` directory (with the 8*cc02d7e2SAndroid Build Coastguard Workerexception of `third_party/rake-compiler-dock` docker images). 9*cc02d7e2SAndroid Build Coastguard Worker 10*cc02d7e2SAndroid Build Coastguard Worker## Version management 11*cc02d7e2SAndroid Build Coastguard Worker 12*cc02d7e2SAndroid Build Coastguard WorkerThe docker images we use for testing evolve over time (and newer/older versions of it 13*cc02d7e2SAndroid Build Coastguard Workermight not work with newer/older revisions of our code). 14*cc02d7e2SAndroid Build Coastguard Worker 15*cc02d7e2SAndroid Build Coastguard WorkerFor each dockerfile (which is identified by the directory in which is it located), 16*cc02d7e2SAndroid Build Coastguard Workerthe "current version" that's being used by testing is determined by the 17*cc02d7e2SAndroid Build Coastguard Workercorresponding `.current_version` file, which contains the full docker image name, 18*cc02d7e2SAndroid Build Coastguard Workerincluding artifact registry location, docker image name, the current tag and the 19*cc02d7e2SAndroid Build Coastguard WorkerSHA256 image digest. 20*cc02d7e2SAndroid Build Coastguard Worker 21*cc02d7e2SAndroid Build Coastguard WorkerExample: 22*cc02d7e2SAndroid Build Coastguard WorkerFor `tools/dockerfile/test/cxx_debian11_x64/Dockerfile`, there is a 23*cc02d7e2SAndroid Build Coastguard Worker`tools/dockerfile/test/cxx_debian11_x64.current_version` file which contains info 24*cc02d7e2SAndroid Build Coastguard Workeras follows: 25*cc02d7e2SAndroid Build Coastguard Worker``` 26*cc02d7e2SAndroid Build Coastguard Workerus-docker.pkg.dev/grpc-testing/testing-images-public/cxx_debian11_x64:[CURRENT_CHECKSUM]@sha256:[CURRENT_SHA256_DIGEST] 27*cc02d7e2SAndroid Build Coastguard Worker``` 28*cc02d7e2SAndroid Build Coastguard WorkerThis info can be passed directly to `docker run` command to get an environment 29*cc02d7e2SAndroid Build Coastguard Workerthat's identical what what we use when testing on CI. 30*cc02d7e2SAndroid Build Coastguard Worker 31*cc02d7e2SAndroid Build Coastguard Worker## Updating the images 32*cc02d7e2SAndroid Build Coastguard Worker 33*cc02d7e2SAndroid Build Coastguard WorkerThe authoritative version of docker images we use for testing is stored in artifact registry, 34*cc02d7e2SAndroid Build Coastguard Workerunder the repository `us-docker.pkg.dev/grpc-testing/testing-images-public`. 35*cc02d7e2SAndroid Build Coastguard Worker 36*cc02d7e2SAndroid Build Coastguard WorkerIf you've made modifications to a dockerfile, you can upload the new version of the artifact 37*cc02d7e2SAndroid Build Coastguard Workerregistry as follows: 38*cc02d7e2SAndroid Build Coastguard Worker 39*cc02d7e2SAndroid Build Coastguard WorkerIf you haven't configured authentication in Docker for us-docker.pkg.dev previously, run: 40*cc02d7e2SAndroid Build Coastguard Worker``` 41*cc02d7e2SAndroid Build Coastguard Workergcloud auth configure-docker us-docker.pkg.dev 42*cc02d7e2SAndroid Build Coastguard Workergcloud auth login 43*cc02d7e2SAndroid Build Coastguard Worker``` 44*cc02d7e2SAndroid Build Coastguard Worker 45*cc02d7e2SAndroid Build Coastguard WorkerRebuild the docker images that have been modified locally and upload the docker images to 46*cc02d7e2SAndroid Build Coastguard Workerartifact registry (note that this won't overwrite the "old" versions of the docker image 47*cc02d7e2SAndroid Build Coastguard Workerthat are already in artifact registry) 48*cc02d7e2SAndroid Build Coastguard Worker``` 49*cc02d7e2SAndroid Build Coastguard Worker# Install qemu, binformat, and configure binfmt interpreters 50*cc02d7e2SAndroid Build Coastguard Workersudo apt-get install binfmt-support qemu-user-static 51*cc02d7e2SAndroid Build Coastguard Worker 52*cc02d7e2SAndroid Build Coastguard Worker# Enable different multi-architecture containers by QEMU with Docker 53*cc02d7e2SAndroid Build Coastguard Workerdocker run --rm --privileged multiarch/qemu-user-static --reset -p yes 54*cc02d7e2SAndroid Build Coastguard Worker 55*cc02d7e2SAndroid Build Coastguard Workertools/dockerfile/push_testing_images.sh 56*cc02d7e2SAndroid Build Coastguard Worker``` 57*cc02d7e2SAndroid Build Coastguard Worker 58*cc02d7e2SAndroid Build Coastguard WorkerBuild modified docker images locally and don't push to artifact registry. This option is 59*cc02d7e2SAndroid Build Coastguard Workervery useful for quick local experiments. The script is much faster if it doesn't have to 60*cc02d7e2SAndroid Build Coastguard Workerinteract with artifact registry: 61*cc02d7e2SAndroid Build Coastguard Worker``` 62*cc02d7e2SAndroid Build Coastguard Worker# very useful for local experiments 63*cc02d7e2SAndroid Build Coastguard WorkerLOCAL_ONLY_MODE=true tools/dockerfile/push_testing_images.sh 64*cc02d7e2SAndroid Build Coastguard Worker``` 65*cc02d7e2SAndroid Build Coastguard Worker 66*cc02d7e2SAndroid Build Coastguard Worker## Migrating from dockerhub 67*cc02d7e2SAndroid Build Coastguard Worker 68*cc02d7e2SAndroid Build Coastguard WorkerIn the past, our testing docker images were [hosted on dockerhub](https://hub.docker.com/u/grpctesting), 69*cc02d7e2SAndroid Build Coastguard Workerbut we are in the process of migrating them artifact registry now. 70*cc02d7e2SAndroid Build Coastguard Worker 71*cc02d7e2SAndroid Build Coastguard WorkerThis temporary feature might simplify the migration: 72*cc02d7e2SAndroid Build Coastguard Worker``` 73*cc02d7e2SAndroid Build Coastguard Worker# try pull existing images from dockerhub instead of building the from scratch locally. 74*cc02d7e2SAndroid Build Coastguard WorkerTRANSFER_FROM_DOCKERHUB=true tools/dockerfile/push_testing_images.sh 75*cc02d7e2SAndroid Build Coastguard Worker``` 76