Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
gazdagandras committed Dec 21, 2023
2 parents ada46cd + 4d01a33 commit 7ee3d5e
Show file tree
Hide file tree
Showing 13 changed files with 191 additions and 76 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,40 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: hadolint/[email protected]
name: Lint Dockerfile
with:
dockerfile: Dockerfile
ignore: DL3007,DL3018

- name: Build Dockerfile
run: docker build . --file Dockerfile --tag redis:$(date +%s)

build_dockerfile_exporter:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: hadolint/[email protected]
name: Lint Dockerfile.exporter
with:
dockerfile: Dockerfile.exporter
ignore: DL3007,DL3018

- name: Build Dockerfile.exporter
run: docker build . --file Dockerfile.exporter --tag redis-exporter:$(date +%s)

build_dockerfile_sentinel:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: hadolint/[email protected]
name: Lint Dockerfile.sentinel
with:
dockerfile: Dockerfile.sentinel
ignore: DL3007,DL3018

- name: Build Dockerfile.sentinel
run: docker build . --file Dockerfile.sentinel --tag redis-sentinel:$(date +%s)
86 changes: 62 additions & 24 deletions .github/workflows/push-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,80 @@ on:
push:
branches: [master]

env:
REDIS_VERSION: latest
REDIS_SENTINEL_VERSION: latest
REDIS_EXPORTER_VERSION: latest

jobs:
build_redis:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Login to Quay
run: docker login quay.io -u ${{ secrets.QUAY_USERNAME }} -p ${{ secrets.QUAY_PASSWORD }}
- name: Build and push Redis
env:
REDIS_VERSION: latest
run: |
docker build . --file Dockerfile --tag quay.io/opstree/redis:${REDIS_VERSION}
docker push quay.io/opstree/redis:${REDIS_VERSION}
uses: docker/login-action@v2
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: Build and push multi-arch latest image
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: quay.io/opstree/redis:${{ env.REDIS_VERSION }}

build_redis_sentinel:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Login to Quay
run: docker login quay.io -u ${{ secrets.QUAY_USERNAME }} -p ${{ secrets.QUAY_PASSWORD }}
- name: Build and push Redis Sentinel
env:
REDIS_SENTINEL_VERSION: latest
run: |
docker build . --file Dockerfile.sentinel --tag quay.io/opstree/redis-sentinel:${REDIS_SENTINEL_VERSION}
docker push quay.io/opstree/redis-sentinel:${REDIS_SENTINEL_VERSION}
uses: docker/login-action@v2
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: Build and push multi-arch latest image
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile.sentinel
platforms: linux/amd64,linux/arm64
push: true
tags: quay.io/opstree/redis-sentinel:${{ env.REDIS_SENTINEL_VERSION }}

build_redis_exporter:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Login to Quay
run: docker login quay.io -u ${{ secrets.QUAY_USERNAME }} -p ${{ secrets.QUAY_PASSWORD }}
- name: Build and push Redis Exporter
env:
REDIS_EXPORTER_VERSION: latest
run: |
docker build . --file Dockerfile.exporter --tag quay.io/opstree/redis-exporter:${REDIS_EXPORTER_VERSION}
docker push quay.io/opstree/redis-exporter:${REDIS_EXPORTER_VERSION}
uses: docker/login-action@v2
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: Build and push multi-arch latest image
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile.exporter
platforms: linux/amd64,linux/arm64
push: true
tags: quay.io/opstree/redis-exporter:${{ env.REDIS_EXPORTER_VERSION }}
14 changes: 14 additions & 0 deletions .github/workflows/shell-script.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Shell scripts CI

on:
pull_request:
branches: [ "master" ]

jobs:
shellcheck:
name: Shellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
38 changes: 24 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,40 @@
FROM alpine:3.15 as builder

MAINTAINER Opstree Solutions
LABEL maintainer="Opstree Solutions"

LABEL VERSION=1.0 \
ARCH=AMD64 \
DESCRIPTION="A production grade performance tuned redis docker image created by Opstree Solutions"
ARG TARGETARCH

LABEL version=1.0 \
arch=$TARGETARCH \
description="A production grade performance tuned redis docker image created by Opstree Solutions"

ARG REDIS_DOWNLOAD_URL="http://download.redis.io/"

ARG REDIS_VERSION="stable"

RUN apk add --no-cache su-exec tzdata make curl build-base linux-headers bash openssl-dev

RUN curl -fL -Lo /tmp/redis-${REDIS_VERSION}.tar.gz ${REDIS_DOWNLOAD_URL}/redis-${REDIS_VERSION}.tar.gz && \
cd /tmp && \
tar xvzf redis-${REDIS_VERSION}.tar.gz && \
cd redis-${REDIS_VERSION} && \
make && \
WORKDIR /tmp

RUN curl -fL -Lo redis-${REDIS_VERSION}.tar.gz ${REDIS_DOWNLOAD_URL}/redis-${REDIS_VERSION}.tar.gz && \
tar xvzf redis-${REDIS_VERSION}.tar.gz

WORKDIR /tmp/redis-${REDIS_VERSION}

RUN make && \
make install BUILD_TLS=yes

FROM alpine:3.15

MAINTAINER Opstree Solutions
LABEL maintainer="Opstree Solutions"

ARG TARGETARCH

ENV REDIS_PORT=6379

LABEL VERSION=1.0 \
ARCH=AMD64 \
DESCRIPTION="A production grade performance tuned redis docker image created by Opstree Solutions"
LABEL version=1.0 \
arch=$TARGETARCH \
description="A production grade performance tuned redis docker image created by Opstree Solutions"

COPY --from=builder /usr/local/bin/redis-server /usr/local/bin/redis-server
COPY --from=builder /usr/local/bin/redis-cli /usr/local/bin/redis-cli
Expand All @@ -52,10 +61,11 @@ RUN chown -R 1000:0 /etc/redis && \
chmod -R g+rw /var/run

VOLUME ["/data"]
VOLUME ["/node-conf"]

WORKDIR /data

EXPOSE 6379
EXPOSE ${REDIS_PORT}

USER 1000

Expand Down
24 changes: 15 additions & 9 deletions Dockerfile.exporter
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
FROM alpine:3.15 as builder

ARG TARGETARCH

ARG EXPORTER_URL="https://github.com/oliver006/redis_exporter/releases/download"

ARG REDIS_EXPORTER_VERSION="1.48.0"

RUN apk add --no-cache curl ca-certificates && \
curl -fL -Lo /tmp/redis_exporter-v${REDIS_EXPORTER_VERSION}.linux-amd64.tar.gz \
${EXPORTER_URL}/v${REDIS_EXPORTER_VERSION}/redis_exporter-v${REDIS_EXPORTER_VERSION}.linux-amd64.tar.gz && \
cd /tmp && tar -xvzf redis_exporter-v${REDIS_EXPORTER_VERSION}.linux-amd64.tar.gz && \
mv redis_exporter-v${REDIS_EXPORTER_VERSION}.linux-amd64 redis_exporter
WORKDIR /tmp

RUN apk add --no-cache curl ca-certificates && \
curl -fL -Lo redis_exporter-v${REDIS_EXPORTER_VERSION}.linux-$TARGETARCH.tar.gz \
${EXPORTER_URL}/v${REDIS_EXPORTER_VERSION}/redis_exporter-v${REDIS_EXPORTER_VERSION}.linux-$TARGETARCH.tar.gz && \
tar -xvzf redis_exporter-v${REDIS_EXPORTER_VERSION}.linux-$TARGETARCH.tar.gz && \
mv redis_exporter-v${REDIS_EXPORTER_VERSION}.linux-$TARGETARCH redis_exporter

FROM scratch

MAINTAINER Opstree Solutions
ARG TARGETARCH

LABEL maintainer="Opstree Solutions"

LABEL VERSION=1.0 \
ARCH=AMD64 \
DESCRIPTION="A production grade redis exporter docker image created by Opstree Solutions"
LABEL vesrion=1.0 \
arch=$TARGETARCH \
description="A production grade redis exporter docker image created by Opstree Solutions"

COPY --from=builder /etc/ssl/certs /etc/ssl/certs
COPY --from=builder /tmp/redis_exporter/redis_exporter /usr/local/bin/redis_exporter
Expand Down
30 changes: 18 additions & 12 deletions Dockerfile.sentinel
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
FROM alpine:3.15 as builder

LABEL VERSION=1.0 \
ARCH=AMD64 \
DESCRIPTION="A production grade performance tuned redis docker image created by Opstree Solutions"
ARG TARGETARCH

LABEL version=1.0 \
arch=$TARGETARCH \
description="A production grade performance tuned redis docker image created by Opstree Solutions"

ARG REDIS_DOWNLOAD_URL="http://download.redis.io/"

ARG REDIS_SENTINEL_VERSION="stable"

RUN apk add --no-cache su-exec tzdata make curl build-base linux-headers bash openssl-dev

RUN curl -fL -Lo /tmp/redis-${REDIS_SENTINEL_VERSION}.tar.gz ${REDIS_DOWNLOAD_URL}/redis-${REDIS_SENTINEL_VERSION}.tar.gz && \
cd /tmp && \
WORKDIR /tmp

RUN curl -fL -Lo redis-${REDIS_SENTINEL_VERSION}.tar.gz ${REDIS_DOWNLOAD_URL}/redis-${REDIS_SENTINEL_VERSION}.tar.gz && \
tar xvzf redis-${REDIS_SENTINEL_VERSION}.tar.gz && \
cd redis-${REDIS_SENTINEL_VERSION} && \
make && \
make install BUILD_TLS=yes
make -C redis-${REDIS_SENTINEL_VERSION} && \
make -C redis-${REDIS_SENTINEL_VERSION} install BUILD_TLS=yes

FROM alpine:3.15

LABEL VERSION=1.0 \
ARCH=AMD64 \
DESCRIPTION="A production grade performance tuned redis docker image created by Opstree Solutions"
ARG TARGETARCH

ENV SENTINEL_PORT=26379

LABEL version=1.0 \
arch=$TARGETARCH \
description="A production grade performance tuned redis docker image created by Opstree Solutions"


COPY --from=builder /usr/local/bin/redis-cli /usr/local/bin/redis-cli
Expand All @@ -47,7 +53,7 @@ VOLUME ["/sentinel-data"]

WORKDIR /sentinel-data

EXPOSE 26379
EXPOSE ${SENTINEL_PORT}

USER 1000

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ That's it
#### Redis Docker Image

```shell
make build-redis-image
make build-redis
```

#### Redis Exporter Docker Image

```shell
make build-redis-exporter-image
make build-redis-exporter
```

## Running Setup
Expand Down
2 changes: 1 addition & 1 deletion create-cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

PODS="$1"

yes yes | redis-cli --cluster create ${PODS}
yes yes | redis-cli --cluster create "${PODS}"
15 changes: 11 additions & 4 deletions entrypoint-sentinel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ sentinel_mode_setup(){
echo "sentinel down-after-milliseconds ${MASTER_GROUP_NAME} ${DOWN_AFTER_MILLISECONDS}"
echo "sentinel parallel-syncs ${MASTER_GROUP_NAME} ${PARALLEL_SYNCS}"
echo "sentinel failover-timeout ${MASTER_GROUP_NAME} ${FAILOVER_TIMEOUT}"
if [[ -n "${MASTER_PASSWORD}" ]];then
echo "sentinel auth-pass ${MASTER_GROUP_NAME} ${MASTER_PASSWORD}"
fi
}>> /etc/redis/sentinel.conf

}
Expand Down Expand Up @@ -70,12 +73,15 @@ acl_setup(){
fi
}

start_sentinel() {
port_setup() {
{
echo port "${SENTINEL_PORT}"
} >> /etc/redis/sentinel.conf
}

start_sentinel() {
echo "Starting sentinel service ....."
redis-sentinel /etc/redis/sentinel.conf


exec redis-sentinel /etc/redis/sentinel.conf
}

main_function() {
Expand All @@ -84,6 +90,7 @@ main_function() {
sentinel_mode_setup
tls_setup
acl_setup
port_setup
if [[ -f "${EXTERNAL_CONFIG_FILE}" ]]; then
external_config
fi
Expand Down
Loading

0 comments on commit 7ee3d5e

Please sign in to comment.