From e181e4d5cb75741d1f486e63b51f13619c136152 Mon Sep 17 00:00:00 2001 From: Zankaria Date: Sun, 1 Dec 2024 17:54:28 +0100 Subject: [PATCH 1/4] docker: remove fixed database container name --- compose.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/compose.yml b/compose.yml index 4b87e0b6..0cb9002f 100644 --- a/compose.yml +++ b/compose.yml @@ -28,7 +28,6 @@ services: #MySQL Service db: image: mysql:8.0.35 - container_name: db restart: unless-stopped tty: true ports: From 5a3fead5791bddc431047ab3c38440cdd4da9d85 Mon Sep 17 00:00:00 2001 From: Zankaria Date: Sun, 1 Dec 2024 17:11:27 +0100 Subject: [PATCH 2/4] docker: add redis instance --- compose.yml | 11 +++++++++++ docker/redis/Dockerfile | 6 ++++++ docker/redis/redis.conf | 16 ++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 docker/redis/Dockerfile create mode 100644 docker/redis/redis.conf diff --git a/compose.yml b/compose.yml index 0cb9002f..71d876a2 100644 --- a/compose.yml +++ b/compose.yml @@ -24,6 +24,7 @@ services: - ./local-instances/${INSTANCE:-0}/www:/var/www - ./docker/php/www.conf:/usr/local/etc/php-fpm.d/www.conf - ./docker/php/jit.ini:/usr/local/etc/php/conf.d/jit.ini + - redis-sock:/var/run/redis #MySQL Service db: @@ -37,3 +38,13 @@ services: MYSQL_ROOT_PASSWORD: password volumes: - ./local-instances/${INSTANCE:-0}/mysql:/var/lib/mysql + + redis: + build: + context: ./ + dockerfile: ./docker/redis/Dockerfile + volumes: + - redis-sock:/var/run/redis + +volumes: + redis-sock: diff --git a/docker/redis/Dockerfile b/docker/redis/Dockerfile new file mode 100644 index 00000000..9ab7f7fc --- /dev/null +++ b/docker/redis/Dockerfile @@ -0,0 +1,6 @@ +FROM redis:7.4-alpine + +RUN mkdir -p /var/run/redis && chmod 777 /var/run/redis +COPY ./docker/redis/redis.conf /etc/redis.conf + +ENTRYPOINT [ "docker-entrypoint.sh", "/etc/redis.conf" ] diff --git a/docker/redis/redis.conf b/docker/redis/redis.conf new file mode 100644 index 00000000..609d57ff --- /dev/null +++ b/docker/redis/redis.conf @@ -0,0 +1,16 @@ +# Accept connections on the specified port, default is 6379 (IANA #815344). +# If port 0 is specified Redis will not listen on a TCP socket. +#port 6379 +port 0 + +# Unix socket. +# +# Specify the path for the Unix socket that will be used to listen for +# incoming connections. There is no default, so Redis will not listen +# on a unix socket when not specified. +# +unixsocket /var/run/redis/redis-server.sock +# Executig a socket is a no-op, and we need to share acces to other programs. +# Shared the connection only with programs in the redis group for security. +#unixsocketperm 700 +unixsocketperm 666 From b7a9f47a1b198c70ec70fda978b0b18892da5d65 Mon Sep 17 00:00:00 2001 From: Zankaria Date: Sun, 1 Dec 2024 17:33:17 +0100 Subject: [PATCH 3/4] RedisCacheDriver.php: fixup --- inc/Data/Driver/RedisCacheDriver.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/inc/Data/Driver/RedisCacheDriver.php b/inc/Data/Driver/RedisCacheDriver.php index a2354482..389fff32 100644 --- a/inc/Data/Driver/RedisCacheDriver.php +++ b/inc/Data/Driver/RedisCacheDriver.php @@ -8,7 +8,7 @@ class RedisCacheDriver implements CacheDriver { private string $prefix; private \Redis $inner; - public function __construct(string $prefix, string $host, ?int $port, ?string $password, string $database) { + public function __construct(string $prefix, string $host, ?int $port, ?string $password, int $database) { $this->inner = new \Redis(); if (str_starts_with($host, 'unix:') || str_starts_with($host, ':')) { $ret = \explode(':', $host); @@ -30,10 +30,10 @@ class RedisCacheDriver implements CacheDriver { throw new \RuntimeException('Unable to configure Redis serializer'); } if (!$this->inner->select($database)) { - throw new \RuntimeException('Unable to connect to Redis!'); + throw new \RuntimeException('Unable to connect to Redis database!'); } - $$this->prefix = $prefix; + $this->prefix = $prefix; } public function get(string $key): mixed { From 0e3f1555c08abd8c1b376361eeebe142b6da9dfc Mon Sep 17 00:00:00 2001 From: Zankaria Date: Sun, 1 Dec 2024 17:47:53 +0100 Subject: [PATCH 4/4] config.php: fix default config for redis cache --- inc/config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/config.php b/inc/config.php index 454cae4f..068d1706 100644 --- a/inc/config.php +++ b/inc/config.php @@ -174,7 +174,7 @@ // Redis server to use. Location, port, password, database id. // Note that vichan may clear the database at times, so you may want to pick a database id just for // vichan to use. - $config['cache']['redis'] = array('localhost', 6379, '', 1); + $config['cache']['redis'] = [ 'localhost', 6379, null, 1 ]; // EXPERIMENTAL: Should we cache configs? Warning: this changes board behaviour, i'd say, a lot. // If you have any lambdas/includes present in your config, you should move them to instance-functions.php