Dockerfile37 lines · 950 chars # Build Redis from official Linux source tarball (Ubuntu 22.04 base)
# Stage 1: build
FROM ubuntu:22.04 AS builder
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
curl \
build-essential \
tcl \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /tmp/build
# Download and extract Redis source (Linux release)
RUN curl -fsSL https://download.redis.io/releases/redis-7.0.0.tar.gz -o redis.tar.gz \
&& tar xzf redis.tar.gz --strip-components=1 -C /tmp/build
WORKDIR /tmp/build
# Build and install Redis to /usr/local
RUN make -j"$(nproc)" && make install PREFIX=/usr/local
# Stage 2: runtime
FROM ubuntu:22.04
ENV PATH=/usr/local/bin:$PATH
RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /usr/local /usr/local
EXPOSE 6379
CMD ["redis-server"]