Вход на сайт

Просмотр новости

Найдите то, что Вас интересует

Multi-Service Docker Compose Build in Travis CI with Cross-Container Caching and Service Health Checks

Дата публикации: 03-06-2025 18:13:00

While Docker Compose supports healthcheck, Travis won’t inherently wait for these checks to pass unless you tell it to. You can create a scripts/wait-for-health.sh script that loops over your critical services (such as postgres, redis, and minio) and checks their health status using docker inspect. This ensures your build doesn’t proceed until all containers are reported as healthy.
Here’s what that script should do: for each service, it checks if docker inspect -f '{{.State.Health.Status}}' returns healthy, and if not, it waits and tries again every few seconds. Once all services pass, the script completes and the test phase can safely begin. Don’t forget to mark this script as executable with chmod +x scripts/wait-for-health.sh, and then invoke it during your before_install phase in .travis.yml right after docker-compose up -d.
For Docker layer caching, the common mistake is assuming that simply caching $HOME/.docker will persist image layers — but this rarely works reliably across Travis CI builds. Instead, you should explicitly save your Docker image as a tarball using docker save before the cache phase, and then load it again in a future build using docker load. For example, you could use docker save my-app:latest > my-app.tar in the before_cache section, and restore it in before_install with docker load < my-app.tar. This approach makes Docker image reuse deterministic and avoids layer rebuilds on every build.
In summary, you’ll need to create a bash script to wait for health checks, explicitly manage Docker caching with docker save/load, and stick to container names for intra-service communication. These fixes combined will make your Travis + Docker Compose setup faster, more stable, and easier to debug. Let me know if you want a sample repo to demonstrate it all.

Схожие новости

#Наименование новостиТональностьИнформативностьДата публикации
1Continuous Integration, Deployment, and Build Failures for a Restaurant Menu Website Using Travis CI0709-02-2026
2Travis CI Pipeline Reliability Issues While Building, Testing, and Deploying My Real-Time Morse Code Website0720-06-2026
3Travis CI build failing after dependency updates for my website project0706-11-2025
4Complex Multi-Job Matrix with Conditional Deploys Fails on Secret Merging – Need Advanced Debugging Help0503-06-2025
5TRAVIS_COMMIT and TRAVIS_PULL_REQUEST_SHA commit SHA's getting masked in web log output0604-12-2025
6.NET 10 support0529-06-2026
7How to get travis-ci support?-8602-06-2026
8Failing after success stage5714-10-2025
9Travis Displays intermittent "We couldn't display the repository"0519-01-2026
10Build dist is bionic even though jammy is specified in config0521-10-2025

Классификация: . Схожих патентов: 0. Схожих новостей: 10. Тональность: 0. Информативность: 7. Источник: travis-ci.community.