github action services: mysql, redis and elasticsearch
sugiarto
Posted on September 24, 2024
A few days ago, I needed to setup github actions for running Rails tests that required MySQL, Redis, and Elasticsearch to be installed.
Here is a is a sample configuration to boot MySQL, Redis, and elasticsearch that can be accessed from 127.0.0.1
address.
services:
mysql:
image: mysql:8.0
ports:
- 3306:3306
env:
MYSQL_DATABASE: sample_database_test
MYSQL_ROOT_PASSWORD: root
options: >-
--health-cmd "mysqladmin ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
redis:
image: redis
ports:
- 6379:6379
# Set health checks to wait until redis has started
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:8.13.0
ports:
- 9200:9200
options: --health-cmd="curl http://localhost:9200/_cluster/health" -e "discovery.type=single-node" -e "xpack.security.enabled=false"
💖 💪 🙅 🚩
sugiarto
Posted on September 24, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.