forked from valkey-io/valkey
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fa48ba3
commit 80b1feb
Showing
2 changed files
with
66 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,68 @@ | ||
# Use a base image | ||
FROM alpine:latest | ||
|
||
ENV DEBIAN_FRONTEND noninteractive | ||
ENV TZ Etc/UTC | ||
# Install necessary dependencies | ||
RUN apt-get update && \ | ||
apt-get install -y --no-install-recommends tzdata && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# Download, compile, and install Redis | ||
RUN wget https://github.com/roshkhatri/valkey/archive/unstable.tar.gz && \ | ||
tar xvzf unstable.tar.gz && \ | ||
cd unstable && \ | ||
make && \ | ||
make install | ||
|
||
# Expose Redis default port | ||
FROM debian:bookworm-slim | ||
|
||
# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added | ||
RUN set -eux; \ | ||
groupadd -r -g 999 valkey; \ | ||
useradd -r -g valkey -u 999 valkey | ||
|
||
# runtime dependencies | ||
RUN set -eux; \ | ||
apt-get update; \ | ||
apt-get install -y --no-install-recommends \ | ||
tzdata \ | ||
; \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
ENV VALKEY_UNSTABLE_URL https://github.com/roshkhatri/valkey/archive/unstable.tar.gz | ||
|
||
RUN set -eux; \ | ||
\ | ||
savedAptMark="$(apt-mark showmanual)"; \ | ||
apt-get update; \ | ||
apt-get install -y --no-install-recommends \ | ||
ca-certificates \ | ||
wget \ | ||
\ | ||
dpkg-dev \ | ||
gcc \ | ||
libc6-dev \ | ||
libssl-dev \ | ||
make \ | ||
pkg-config\ | ||
; \ | ||
rm -rf /var/lib/apt/lists/*; | ||
|
||
# Download, compile, and install Valkey | ||
RUN wget "$VALKEY_UNSTABLE_URL" && \ | ||
mkdir -p /usr/src/valkey; \ | ||
tar -xzf unstable.tar.gz -C /usr/src/valkey --strip-components=1; \ | ||
rm unstable.tar.gz; \ | ||
grep -E '^ *createBoolConfig[(]"protected-mode",.*, *1 *,.*[)],$' /usr/src/valkey/src/config.c; \ | ||
sed -ri 's!^( *createBoolConfig[(]"protected-mode",.*, *)1( *,.*[)],)$!\10\2!' /usr/src/valkey/src/config.c; \ | ||
grep -E '^ *createBoolConfig[(]"protected-mode",.*, *0 *,.*[)],$' /usr/src/valkey/src/config.c; \ | ||
\ | ||
gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \ | ||
extraJemallocConfigureFlags="--build=$gnuArch"; \ | ||
dpkgArch="$(dpkg --print-architecture)"; \ | ||
case "${dpkgArch##*-}" in \ | ||
amd64 | i386 | x32) extraJemallocConfigureFlags="$extraJemallocConfigureFlags --with-lg-page=12" ;; \ | ||
*) extraJemallocConfigureFlags="$extraJemallocConfigureFlags --with-lg-page=16" ;; \ | ||
esac; \ | ||
extraJemallocConfigureFlags="$extraJemallocConfigureFlags --with-lg-hugepage=21"; \ | ||
grep -F 'cd jemalloc && ./configure ' /usr/src/valkey/deps/Makefile; \ | ||
sed -ri 's!cd jemalloc && ./configure !&'"$extraJemallocConfigureFlags"' !' /usr/src/valkey/deps/Makefile; \ | ||
grep -F "cd jemalloc && ./configure $extraJemallocConfigureFlags " /usr/src/valkey/deps/Makefile; \ | ||
export BUILD_TLS=yes; \ | ||
make -C /usr/src/valkey -j "$(nproc)" all; \ | ||
make -C /usr/src/valkey install; | ||
|
||
RUN mkdir /data && chown valkey:valkey /data | ||
WORKDIR /data | ||
VOLUME /data | ||
|
||
# Expose Valkey default port | ||
EXPOSE 6379 | ||
|
||
# Run Redis server by default | ||
CMD ["./src/valkey-server"] | ||
# Run Valkey server by default | ||
CMD ["/usr/local/bin/valkey-server"] |