Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented redis persistence #18

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["config:base", ":semanticCommits"]
}
29 changes: 29 additions & 0 deletions .github/workflows/cron_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: 'Daily tests'
on:
workflow_dispatch:
inputs:
debug_enabled:
type: boolean
description: Debug with tmate
required: false
default: false
ddev_version:
type: string
description: DDEV version to test
required: false
default: '["stable"]'
test_type:
type: string
description: Test type to run. Can be "local" or "release"
required: false
default: 'release'
schedule:
- cron: '25 08 * * *'

jobs:
run_tests:
name: Run tests
uses: ddev/ddev-redis/.github/workflows/reusable_test_ddev_addon.yml@master
with:
ddev_version: '["stable", "HEAD", "edge"]'
test_type: 'release'
11 changes: 11 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: 'Test DDEV Addon'
on:
pull_request:
merge_group:

jobs:
run_tests:
name: Run tests
uses: ddev/ddev-redis/.github/workflows/reusable_test_ddev_addon.yml@master
with:
test_type: 'local'
26 changes: 26 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Release
on:
push:
paths-ignore:
- '**/renovate.json'
- README.md
branches:
- master
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18
cache: yarn
- name: Install Yarn dependencies
run: yarn install
- name: Release
run: yarn semantic-release
82 changes: 82 additions & 0 deletions .github/workflows/reusable_test_ddev_addon.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Test DDEV addon
on:
workflow_call:
inputs:
debug_enabled:
type: boolean
description: Debug with tmate
required: false
default: false
ddev_version:
type: string
description: DDEV version to test
required: false
default: '["stable"]'
test_type:
type: string
description: Test type to run. Can be "local" or "release"
required: false
default: "release"

# This is required for "gautamkrishnar/keepalive-workflow"
seebeen marked this conversation as resolved.
Show resolved Hide resolved
permissions:
contents: write

defaults:
run:
shell: bash

env:
# NIGHTLY_DDEV_PR_URL: "https://nightly.link/ddev/ddev/actions/runs/1720215802/ddev-linux-amd64.zip"
# Allow ddev get to use a github token to prevent rate limiting by tests
DDEV_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Allow `--HEAD` flag when running tests against HEAD
seebeen marked this conversation as resolved.
Show resolved Hide resolved

jobs:
run_ddev_tests:
name: Test ${{ matrix.ddev_version }}
defaults:
run:
shell: bash
runs-on: ubuntu-latest
strategy:
matrix:
ddev_version: ${{ fromJSON(inputs.ddev_version)}}
fail-fast: false

steps:
- uses: actions/checkout@v3
- name: Set up Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@master

- name: Environment setup
run: |
brew tap bats-core/bats-core
brew install bats-core bats-support bats-assert mkcert
mkcert -install

- name: Use ddev edge
if: matrix.ddev_version == 'edge'
run: brew install ddev/ddev-edge/ddev

- name: Use ddev HEAD
if: matrix.ddev_version == 'HEAD'
run: brew install --HEAD ddev/ddev/ddev

- name: Use ddev stable
if: matrix.ddev_version == 'stable'
run: brew install ddev/ddev/ddev

- name: Download docker images
run: mkdir junk && pushd junk && ddev config --auto && ddev debug download-images >/dev/null

- name: tmate debugging session
uses: mxschmitt/action-tmate@v3
with:
limit-access-to-actor: true
github-token: ${{ secrets.GITHUB_TOKEN }}
if: inputs.debug_enabled == 'true'

- name: Run BATS
run: bats tests --filter-tags ${{ inputs.test_type }}
91 changes: 0 additions & 91 deletions .github/workflows/tests.yml

This file was deleted.

28 changes: 28 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"branches": [
"master"
],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/git",
[
"@semantic-release/exec",
{
"prepareCmd": "zip -qr /tmp/release.zip *.yaml redis commands"
}
],
[
"@semantic-release/github",
{
"assets": [
{
"path": "/tmp/release.zip",
"name": "ddev-redis--${nextRelease.version}.zip",
"label": "DDev Redis Addon v${nextRelease.version}"
}
]
}
]
]
}
Binary file added .yarn/install-state.gz
Binary file not shown.
874 changes: 874 additions & 0 deletions .yarn/releases/yarn-3.6.1.cjs

Large diffs are not rendered by default.

77 changes: 65 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,77 @@
[![tests](https://github.com/ddev/ddev-redis/actions/workflows/tests.yml/badge.svg)](https://github.com/ddev/ddev-redis/actions/workflows/tests.yml) ![project is maintained](https://img.shields.io/maintenance/yes/2024.svg)
<div align="center">

## What is this?
# ddev-redis - Redis container for DDEV

This repository allows you to quickly install Redis into a [DDEV](https://ddev.readthedocs.io) project using just `ddev get ddev/ddev-redis`.
[![GitHub release (with filter)](https://img.shields.io/github/v/release/ddev/ddev-redis)](https://github.com/ddev/ddev-redis/releases)
[![Tests](https://github.com/ddev/ddev-redis/actions/workflows/cron_tests.yml/badge.svg)](https://github.com/ddev/ddev-redis/actions/workflows/cron_tests.yml)
![project is maintained](https://img.shields.io/maintenance/yes/2024.svg)

</div>

This repository provides [Redis](https://redis.com) container for [DDEV](https://ddev.readthedocs.io/).

It is based on [redis:6-alpine](https://hub.docker.com/layers/library/redis/6-alpine) docker image and [DDEV custom compose files](https://ddev.readthedocs.io/en/stable/users/extend/custom-compose-files/)

## Version 2 features

There are a lot of differences between [official](https://github.com/ddev/ddev-redis) addon and this one

| Feature | v1 | v2 |
| ----------------- | ---------------- | ------------------------ |
| Maximum Memory | Unlimited | 512Mb |
| Persistence | No | **Yes** |
| Image Size | 112.9Mb | 14.38Mb |
seebeen marked this conversation as resolved.
Show resolved Hide resolved
| Anonymous Volumes | On every restart | **NO** |
| Optimized config | No | **Yes** |

### Anonymous volumes - Wait, what?

Official redis docker image mounts an anonymous volume on `/data` because... reasons. That volume is recreated on every restart. This one mounts the persistence directory on `/data` and names it according to the project name, and gives it a proper label. This way, each DDEV project has it's own data volume, and data can persist accordingly

![Anonymous volume in action](images/anon-volume.jpg)
seebeen marked this conversation as resolved.
Show resolved Hide resolved

### Persistence?

Yes, persistence. This image is configured to persist data on `/data` volume. This means that if you stop the container, and start it again, the data will be there. This is useful for long-term caching of data, and for keeping the cache primed between ddev restarts.

## Installation

1. `ddev get ddev/ddev-redis`
2. `ddev restart`
```
$ ddev get ddev/ddev-redis
$ ddev restart
```

## Explanation
> [!IMPORTANT]
> Authentication is setup by default, and the password is `redis`.
> If needed, you can auth with a username and password.
> Username is `redis` as well.

This Redis recipe for [DDEV](https://ddev.readthedocs.io) installs a [`.ddev/docker-compose.redis.yaml`](docker-compose.redis.yaml) using the `redis` Docker image.

## Interacting with Redis
## Configuration

* The Redis instance will listen on TCP port 6379 (the Redis default).
* Configure your application to access Redis on the host:port `redis:6379`.
* To reach the Redis CLI interface, run `ddev redis-cli` to begin a session. You can also run Redis CLI commands directly on the command-line, e.g., `ddev redis-cli INFO`.
### Redis Version
You can change the redis version by defining an environment variable using an `.env` file in the .ddev folder, or by exporting it in your shell.

```bash
export DDEV_REDIS_VERSION="7.2"
```
### Redis Server

Redis configuration files are split in the `.ddev/redis/conf` folder, you can modify them as you wish.
Otherwise, plugin just works out of the box.

**Contributed and maintained by [@hussainweb](https://github.com/hussainweb) based on the original [ddev-contrib recipe](https://github.com/ddev/ddev-contrib/tree/master/docker-compose-services/redis) by [@gormus](https://github.com/gormus)**

## Commands

Addon exposes the following commands

| Command | Usage | Description |
| ----------------- | ------------------ | ---------------------------------- |
| `redis` | `ddev redis` | Launches the **redis-cli** |
| `redis *COMMAND*` | `ddev redis` | Run an arbitrary redis-cli command |
| `redis-flush` | `ddev redis-flush` | Clears all the Redis Databases |
___

**Contributed and maintained by [@hussainweb](https://github.com/hussainweb) based on the original [ddev-contrib recipe](https://github.com/ddev/ddev-contrib/tree/master/docker-compose-services/redis) by [@gormus](https://github.com/gormus)**
**Co-maintained by [@stasadev](https://github.com/stasadev)**
**Overhauled and redesigned by [Oblak Studio](https://github.com/oblakstudio)**
7 changes: 7 additions & 0 deletions commands/redis/redis
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh
#ddev-generated
## Description: Run redis-cli inside the redis container
## Usage: redis [flags] [args]
## Example: "redis KEYS *" or "ddev redis-cli INFO" or "ddev redis-cli --version"

redis-cli -p 6379 -h redis -a redis --no-auth-warning "$@"
Comment on lines +3 to +7
Copy link
Member

@stasadev stasadev Sep 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## Description: Run redis-cli inside the redis container
## Usage: redis [flags] [args]
## Example: "redis KEYS *" or "ddev redis-cli INFO" or "ddev redis-cli --version"
redis-cli -p 6379 -h redis -a redis --no-auth-warning "$@"
## Description: Run redis-cli inside the redis container
## Usage: redis [flags] [args]
## Example: ddev redis KEYS "'*'" or "ddev redis INFO" or "ddev redis --version"
set -x
redis-cli -p 6379 -h redis -a redis --no-auth-warning "$@"

Fixed the command examples.
Quotes around '*' - because it is expanded when running from zsh.
Redis commands are so complicated, let's add set -x to see what is actually executing.

7 changes: 0 additions & 7 deletions commands/redis/redis-cli

This file was deleted.

7 changes: 7 additions & 0 deletions commands/redis/redis-flush
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh
#ddev-generated
## Description: Run redis-cli inside the redis container
## Usage: redis-flush
## Example: "redis-flush"

redis-cli -a redis --no-auth-warning FLUSHALL ASYNC
Comment on lines +3 to +7
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## Description: Run redis-cli inside the redis container
## Usage: redis-flush
## Example: "redis-flush"
redis-cli -a redis --no-auth-warning FLUSHALL ASYNC
## Description: Clear all Redis databases
## Usage: redis-flush
## Example: "ddev redis-flush"
set -x
redis-cli -a redis --no-auth-warning FLUSHALL ASYNC

Fixed the command description and example.
Redis commands are so complicated, let's add set -x to see what is actually executing.

Loading