Skip to content

Commit f77164c

Browse files
Add Valkey support (#767)
* add valkey stub * add .idea files to gitignore * add valkey-cli to sail bin * fix valkey stub add valkey support to InteractsWithDockerComposeServices.php file * Update .gitignore * Update sail --------- Co-authored-by: Taylor Otwell <[email protected]>
1 parent f649351 commit f77164c

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

bin/sail

+13
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ function display_help {
8585
echo " ${GREEN}sail psql${NC} Start a PostgreSQL CLI session within the 'pgsql' container"
8686
echo " ${GREEN}sail mongodb${NC} Start a Mongo Shell session within the 'mongodb' container"
8787
echo " ${GREEN}sail redis${NC} Start a Redis CLI session within the 'redis' container"
88+
echo " ${GREEN}sail valkey${NC} Start a Valkey CLI session within the 'valkey' container"
8889
echo
8990
echo "${YELLOW}Debugging:${NC}"
9091
echo " ${GREEN}sail debug ...${NC} Run an Artisan command in debug mode"
@@ -551,6 +552,18 @@ elif [ "$1" == "redis" ]; then
551552
sail_is_not_running
552553
fi
553554

555+
# Initiate a Valkey CLI terminal session within the "valkey" container...
556+
elif [ "$1" == "valkey" ]; then
557+
shift 1
558+
559+
if [ "$EXEC" == "yes" ]; then
560+
ARGS+=(exec)
561+
[ ! -t 0 ] && ARGS+=(-T)
562+
ARGS+=(valkey valkey-cli)
563+
else
564+
sail_is_not_running
565+
fi
566+
554567
# Share the site...
555568
elif [ "$1" == "share" ]; then
556569
shift 1

src/Console/Concerns/InteractsWithDockerComposeServices.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ trait InteractsWithDockerComposeServices
1818
'mariadb',
1919
'mongodb',
2020
'redis',
21+
'valkey',
2122
'memcached',
2223
'meilisearch',
2324
'typesense',
@@ -93,7 +94,7 @@ protected function buildDockerCompose(array $services)
9394
// Merge volumes...
9495
collect($services)
9596
->filter(function ($service) {
96-
return in_array($service, ['mysql', 'pgsql', 'mariadb', 'mongodb', 'redis', 'meilisearch', 'typesense', 'minio']);
97+
return in_array($service, ['mysql', 'pgsql', 'mariadb', 'mongodb', 'redis', 'valkey', 'meilisearch', 'typesense', 'minio']);
9798
})->filter(function ($service) use ($compose) {
9899
return ! array_key_exists($service, $compose['volumes'] ?? []);
99100
})->each(function ($service) use (&$compose) {
@@ -164,6 +165,10 @@ protected function replaceEnvVariables(array $services)
164165
$environment = str_replace('REDIS_HOST=127.0.0.1', 'REDIS_HOST=redis', $environment);
165166
}
166167

168+
if (in_array('valkey',$services)){
169+
$environment = str_replace('REDIS_HOST=127.0.0.1', 'REDIS_HOST=valkey', $environment);
170+
}
171+
167172
if (in_array('mongodb', $services)) {
168173
$environment .= "\nMONGODB_URI=mongodb://mongodb:27017";
169174
$environment .= "\nMONGODB_DATABASE=laravel";

stubs/valkey.stub

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
valkey:
2+
image: 'valkey/valkey:alpine'
3+
ports:
4+
- '${FORWARD_VALKEY_PORT:-6379}:6379'
5+
volumes:
6+
- 'sail-valkey:/data'
7+
networks:
8+
- sail
9+
healthcheck:
10+
test: ["CMD", "valkey-cli", "ping"]
11+
retries: 3
12+
timeout: 5s

0 commit comments

Comments
 (0)