19 lines
846 B
Docker
19 lines
846 B
Docker
FROM redis:latest
|
|
|
|
# Import the Redis configuration file
|
|
COPY redis.conf /etc/redis/redis.conf
|
|
|
|
# Append the password from the REDIS_PASSWORD environment variable to the Redis configuration file
|
|
ARG REDIS_PASSWORD=default_password
|
|
# If the password is the default password, show a warning message
|
|
RUN if [ "$REDIS_PASSWORD" = "default_password" ]; then echo "WARNING: Using the default password for Redis. Please set the REDIS_PASSWORD environment variable."; fi
|
|
# Append the password to the Redis configuration file if it is not the default password
|
|
RUN if [ "$REDIS_PASSWORD" != "default_password" ]; then echo "requirepass $REDIS_PASSWORD" >> /etc/redis/redis.conf; fi
|
|
# Set the working directory inside the container
|
|
WORKDIR /data
|
|
|
|
# Expose port 6379
|
|
EXPOSE 6379
|
|
|
|
# Start Redis when the container starts
|
|
CMD redis-server /etc/redis/redis.conf |