Skip to content

Commit 31c66a0

Browse files
authored
Add Valkey Container (#11156)
1 parent cc82a48 commit 31c66a0

4 files changed

Lines changed: 56 additions & 0 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
3+
4+
ARG BASE_IMAGE
5+
6+
FROM $BASE_IMAGE
7+
8+
@INCLUDE_MAIN_RUN_INSTRUCTION@
9+
10+
RUN set -eux && \
11+
valkey-cli --version && \
12+
valkey-server --version && \
13+
mkdir /data && \
14+
chown valkey:valkey /data
15+
16+
VOLUME /data
17+
WORKDIR /data
18+
19+
COPY valkey-docker-entrypoint.sh /usr/local/bin/
20+
21+
RUN chmod +x /usr/local/bin/valkey-docker-entrypoint.sh
22+
23+
ENTRYPOINT ["/usr/local/bin/valkey-docker-entrypoint.sh"]
24+
25+
EXPOSE 6379
26+
CMD ["valkey-server"]
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
# Copyright (c) Microsoft Corporation.
3+
# Licensed under the MIT License.
4+
set -e
5+
6+
# first arg is `-f` or `--some-option`
7+
# or first arg is `something.conf`
8+
if [ "${1#-}" != "$1" ] || [ "${1%.conf}" != "$1" ]; then
9+
set -- valkey-server "$@"
10+
fi
11+
12+
# allow the container to be started with `--user`
13+
if [ "$1" = 'valkey-server' -a "$(id -u)" = '0' ]; then
14+
find . \! -user valkey -exec chown valkey '{}' +
15+
exec setpriv --reuid=valkey --regid=valkey --init-groups --inh-caps=-all "$BASH_SOURCE" "$@"
16+
fi
17+
18+
# set an appropriate umask (if one isn't set already)
19+
# - https://github.com/docker-library/redis/issues/305
20+
# - https://github.com/redis/redis/blob/bb875603fb7ff3f9d19aad906bd45d7db98d9a39/utils/systemd-redis_server.service#L37
21+
um="$(umask)"
22+
if [ "$um" = '0022' ]; then
23+
umask 0077
24+
fi
25+
26+
exec "$@" $VALKEY_EXTRA_FLAGS
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
valkey
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
valkey
2+
cronie
3+
util-linux

0 commit comments

Comments
 (0)