# Sử dụng base image FROM buildpack-deps:22.04-curl # Cài đặt các công cụ cần thiết để biên dịch Redis RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ curl \ wget \ net-tools \ vim \ locales \ && rm -rf /var/lib/apt/lists/* # Cài đặt Redis phiên bản mới nhất ARG REDIS_VERSION=7.0.12 RUN wget http://download.redis.io/releases/redis-${REDIS_VERSION}.tar.gz \ && tar xzf redis-${REDIS_VERSION}.tar.gz \ && rm redis-${REDIS_VERSION}.tar.gz \ && cd redis-${REDIS_VERSION} \ && make && make install \ && cd .. && rm -rf redis-${REDIS_VERSION} # Sao chép file cấu hình Redis COPY redis.conf /etc/redis/redis.conf # Tạo người dùng và thư mục làm việc ARG USERNAME=redisuser ARG USER_UID=1000 ARG USER_GID=$USER_UID RUN groupadd --gid $USER_GID $USERNAME \ && useradd --uid $USER_UID --gid $USERNAME -m -s /bin/bash $USERNAME \ && mkdir -p /data && chown $USERNAME:$USERNAME /data USER $USERNAME WORKDIR /data # Cấu hình biến môi trường ENV LANG=C.UTF-8 \ LC_ALL=C.UTF-8 \ HOME=/data \ REDIS_CONFIG_FILE=/etc/redis/redis.conf # Expose cổng Redis EXPOSE 6379 # Command chạy Redis với cấu hình RUN [ "redis-server", "/etc/redis/redis.conf" ]