| |
| FROM redis:latest |
|
|
| |
| WORKDIR /usr/src/app |
|
|
| |
| RUN apt-get update && apt-get install -y curl unzip && \ |
| curl -sSL https://ngrok-agent.s3.amazonaws.com/ngrok.asc | tee /etc/apt/trusted.gpg.d/ngrok.asc >/dev/null && \ |
| echo "deb https://ngrok-agent.s3.amazonaws.com buster main" | tee /etc/apt/sources.list.d/ngrok.list && \ |
| apt-get update && \ |
| apt-get install -y ngrok |
|
|
| |
| RUN mkdir -p /usr/local/etc/redis |
|
|
| |
| RUN REDIS_PASSWORD="huggingface_spaces_$(date +%s | sha256sum | base64 | head -c 32)" && \ |
| NGROK_AUTH_TOKEN="huggingface_$(date +%s | sha256sum | base64 | head -c 20)" && \ |
| echo "requirepass \$REDIS_PASSWORD" > /usr/local/etc/redis/redis.conf && \ |
| echo "save ''" >> /usr/local/etc/redis/redis.conf && \ |
| echo "appendonly no" >> /usr/local/etc/redis/redis.conf && \ |
| echo "port 7860" >> /usr/local/etc/redis/redis.conf && \ |
| echo '#!/bin/bash' > /usr/local/bin/start-redis.sh && \ |
| echo 'echo "La contrase帽a de Redis es: ${REDIS_PASSWORD}"' >> /usr/local/bin/start-redis.sh && \ |
| echo 'redis-server /usr/local/etc/redis/redis.conf &' >> /usr/local/bin/start-redis.sh && \ |
| echo 'sleep 2' >> /usr/local/bin/start-redis.sh && \ |
| echo 'ngrok http 7860 --authtoken ${NGROK_AUTH_TOKEN} &' >> /usr/local/bin/start-redis.sh && \ |
| echo 'while true; do' >> /usr/local/bin/start-redis.sh && \ |
| echo ' sleep 5;' >> /usr/local/bin/start-redis.sh && \ |
| echo ' if ! pidof redis-server > /dev/null; then' >> /usr/local/bin/start-redis.sh && \ |
| echo ' echo "Redis ha dejado de funcionar. Reiniciando...";' >> /usr/local/bin/start-redis.sh && \ |
| echo ' redis-server /usr/local/etc/redis/redis.conf &' >> /usr/local/bin/start-redis.sh && \ |
| echo ' fi' >> /usr/local/bin/start-redis.sh && \ |
| echo 'done' >> /usr/local/bin/start-redis.sh && \ |
| chmod +x /usr/local/bin/start-redis.sh |
|
|
| |
| RUN chmod -R 777 /usr/local/etc/redis /usr/src/app |
|
|
| |
| EXPOSE 7860 |
|
|
| |
| CMD ["/usr/local/bin/start-redis.sh"] |
|
|