Не удается подключиться к dockerized redis на Heroku - PullRequest
0 голосов
/ 03 августа 2020

Я новичок в Heroku. Я пытаюсь развернуть образ Docker для Redis на Heroku и хочу использовать его для тестирования своего приложения. Я могу развернуть образ Redis, Redis запускается на Heroku. Я могу увидеть это через:

heroku logs --tail

Проблема в том, что я не могу подключиться к экземпляру Redis. Всякий раз, когда я пытаюсь подключиться к URL-адресу и порту, предоставленным Heroku через redis-cli, он ничего не выводит на консоль. Пожалуйста, помогите мне с моей проблемой.

Вот конечные строки 'heroku logs --tail':

2020-08-03T11:58:32.423011+00:00 app[api]: Deploy 82745f3f by user abhi.kuvalekar@gmail.com
2020-08-03T11:58:32.924452+00:00 heroku[web.1]: State changed from crashed to starting
2020-08-03T11:58:34.239124+00:00 heroku[web.1]: Starting process with command `/bin/sh -c redis-server\ --port\ \16581`
2020-08-03T11:58:36.730721+00:00 app[web.1]: 3:C 03 Aug 2020 11:58:36.730 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
2020-08-03T11:58:36.730779+00:00 app[web.1]: 3:C 03 Aug 2020 11:58:36.730 # Redis version=6.0.6, bits=64, commit=00000000, modified=0, pid=3, just started
2020-08-03T11:58:36.730780+00:00 app[web.1]: 3:C 03 Aug 2020 11:58:36.730 # Configuration loaded
2020-08-03T11:58:36.731523+00:00 app[web.1]: 3:M 03 Aug 2020 11:58:36.731 # You requested maxclients of 10000 requiring at least 10032 max file descriptors.
2020-08-03T11:58:36.731527+00:00 app[web.1]: 3:M 03 Aug 2020 11:58:36.731 # Server can't set maximum open files to 10032 because of OS error: Operation not permitted.
2020-08-03T11:58:36.731573+00:00 app[web.1]: 3:M 03 Aug 2020 11:58:36.731 # Current maximum open files is 10000. maxclients has been reduced to 9968 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.
2020-08-03T11:58:36.732137+00:00 app[web.1]: 3:M 03 Aug 2020 11:58:36.732 * Running mode=standalone, port=16581.
2020-08-03T11:58:36.732184+00:00 app[web.1]: 3:M 03 Aug 2020 11:58:36.732 # Server initialized
2020-08-03T11:58:36.732230+00:00 app[web.1]: 3:M 03 Aug 2020 11:58:36.732 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
2020-08-03T11:58:36.739313+00:00 app[web.1]: 3:M 03 Aug 2020 11:58:36.739 * Ready to accept connections
2020-08-03T11:58:38.510995+00:00 heroku[web.1]: State changed from starting to up

Вот мой файл heroku.yml:

build:
  docker:
    web: Dockerfile

Вот мой Dockerfile:

FROM alpine:3.12

# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added
RUN addgroup -S -g 1000 redis && adduser -S -G redis -u 999 redis
# alpine already has a gid 999, so we'll use the next id

RUN apk add --no-cache \
# grab su-exec for easy step-down from root
        'su-exec>=0.2' \
# add tzdata for https://github.com/docker-library/redis/issues/138
        tzdata

ENV REDIS_VERSION 6.0.6
ENV REDIS_DOWNLOAD_URL http://download.redis.io/releases/redis-6.0.6.tar.gz
ENV REDIS_DOWNLOAD_SHA 12ad49b163af5ef39466e8d2f7d212a58172116e5b441eebecb4e6ca22363d94

RUN set -eux; \
    \
    apk add --no-cache --virtual .build-deps \
        coreutils \
        gcc \
        linux-headers \
        make \
        musl-dev \
        openssl-dev \
# install real "wget" to avoid:
#   + wget -O redis.tar.gz http://download.redis.io/releases/redis-6.0.6.tar.gz
#   Connecting to download.redis.io (45.60.121.1:80)
#   wget: bad header line:     XxhODalH: btu; path=/; Max-Age=900
        wget \
    ; \
    \
    wget -O redis.tar.gz "$REDIS_DOWNLOAD_URL"; \
    echo "$REDIS_DOWNLOAD_SHA *redis.tar.gz" | sha256sum -c -; \
    mkdir -p /usr/src/redis; \
    tar -xzf redis.tar.gz -C /usr/src/redis --strip-components=1; \
    rm redis.tar.gz; \
    \
# disable Redis protected mode [1] as it is unnecessary in context of Docker
# (ports are not automatically exposed when running inside Docker, but rather explicitly by specifying -p / -P)
# [1]: https://github.com/antirez/redis/commit/edd4d555df57dc84265fdfb4ef59a4678832f6da
    grep -E '^ *createBoolConfig[(]"protected-mode",.*, *1 *,.*[)],$' /usr/src/redis/src/config.c; \
    sed -ri 's!^( *createBoolConfig[(]"protected-mode",.*, *)1( *,.*[)],)$!\10\2!' /usr/src/redis/src/config.c; \
    grep -E '^ *createBoolConfig[(]"protected-mode",.*, *0 *,.*[)],$' /usr/src/redis/src/config.c; \
# for future reference, we modify this directly in the source instead of just supplying a default configuration flag because apparently "if you specify any argument to redis-server, [it assumes] you are going to specify everything"
# see also https://github.com/docker-library/redis/issues/4#issuecomment-50780840
# (more exactly, this makes sure the default behavior of "save on SIGTERM" stays functional by default)
    \
    export BUILD_TLS=yes; \
    make -C /usr/src/redis -j "$(nproc)" all; \
    make -C /usr/src/redis install; \
    \
# TODO https://github.com/antirez/redis/pull/3494 (deduplicate "redis-server" copies)
    serverMd5="$(md5sum /usr/local/bin/redis-server | cut -d' ' -f1)"; export serverMd5; \
    find /usr/local/bin/redis* -maxdepth 0 \
        -type f -not -name redis-server \
        -exec sh -eux -c ' \
            md5="$(md5sum "$1" | cut -d" " -f1)"; \
            test "$md5" = "$serverMd5"; \
        ' -- '{}' ';' \
        -exec ln -svfT 'redis-server' '{}' ';' \
    ; \
    \
    rm -r /usr/src/redis; \
    \
    runDeps="$( \
        scanelf --needed --nobanner --format '%n#p' --recursive /usr/local \
            | tr ',' '\n' \
            | sort -u \
            | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \
    )"; \
    apk add --no-network --virtual .redis-rundeps $runDeps; \
    apk del --no-network .build-deps; \
    \
    redis-cli --version; \
    redis-server --version

RUN mkdir /data && chown redis:redis /data
WORKDIR /data

CMD redis-server --port $PORT
...