OpenToAllCTF / OTA-Challenge-Bot

:robot: Slack bot for challenge management in large teams :robot:
MIT License
60 stars 13 forks source link

Add docker-compose, redis #220

Closed l4cr0ss closed 4 years ago

l4cr0ss commented 4 years ago

Changes

Add a docker-compose.yml config file that will spin up two containers on invocation of docker-compose up, one running the OTA bot and another running an instance of redis connected to the OTA bot via a local network link.

From the OTA bot, a connection to the redis instance is possible using the hostname of the redis container.

Redis config

The redis container uses a custom config that is copied in from config/redis.conf. A template was added to the config directory for this file that was modified from the official redis.conf for Redis 6.0 in the following way:

$ diff redis.conf redis.conf.template -y --suppress-common-lines
  tcp-backlog 511                                                   | tcp-backlog 127
  logfile ""                                                        | # logfile ""
  # syslog-enabled no                                               | syslog-enabled yes
  # syslog-ident redis                                              | syslog-ident redis
  # syslog-facility local0                                          | syslog-facility local0
  stop-writes-on-bgsave-error yes                                   | stop-writes-on-bgsave-error no

https://redis.io/topics/config

Access Redis locally

To access the redis while it is running inside the container, modify your docker-compose.yml like so:

$ git diff docker-compose.yml
  diff --git a/docker-compose.yml b/docker-compose.yml
  index 78a6dd0..562b7a9 100644
  --- a/docker-compose.yml
  +++ b/docker-compose.yml
  @@ -7,5 +7,7 @@ services:
     redis:
       image: "redis:latest"
       command: redis-server /usr/local/etc/redis/redis.conf
  +    ports:
  +      - "6380:6379"
       volumes:
         - ./config/redis.conf:/usr/local/etc/redis/redis.conf

Test connectivity via redis-cli

Assuming the above port-forwarding setup, you can run the following command from your local machine to test connectivity to the redis instance:

$ redis-cli -p 6380
  127.0.0.1:6380> keys "*"
  (empty list or set)
  127.0.0.1:6380>