Ben
Ben

Reputation: 5192

aws codebuild / using local redis (ubuntu image)

Getting into code build; currently looking to use redis on a local ubuntu image;
using the following script :

version: 0.2
phases:
  install:
    commands:
      - apt update
      - apt install -y redis-server wget 
  pre_build:
    commands:
      - wget https://raw.githubusercontent.com/Hronom/wait-for-redis/master/wait-for-redis.sh
      - chmod +x ./wait-for-redis.sh
      - service redis-server start
      - ./wait-for-redis.sh localhost:6379
  build:
    commands:
      - redis-cli info
      - redis-cli info server

For now it seems to us that docker-compose is not ultimately required, we would first look into using it that way - expecting a standard ubuntu behaviour.

We're installing postgres with a similar approach, it does start properly and is fully usable.

Here we're unable to start redis properly, wait-for-redis keeps retrying (keep getting error Could not connect to Redis at localhost:6379: Connection refused)

With an ec2 linux image (yum based), we don't have such issue

What would be the correct way start redis in that ubuntu context ?

Upvotes: 1

Views: 946

Answers (1)

Done Data Solutions
Done Data Solutions

Reputation: 2286

Just ran into the same problem.

When I added a cat /var/log/redis/*.log to the buildspec I discovered that Redis was not able to bind:

Creating Server TCP listening socket ::1:6379: bind: Cannot assign requested address

Further research showed this to be a known issue: https://github.com/redis/redis/issues/3241

... which can be fixed by adding these lines to the buildspec (before using redis):

- sed -i '/^bind/s/bind.*/bind 127.0.0.1/' /etc/redis/redis.conf
- service redis-server restart

Upvotes: 1

Related Questions