diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 4816101..4674582 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -9,6 +9,13 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + + - uses: hadolint/hadolint-action@v3.1.0 + name: Lint Dockerfile + with: + dockerfile: Dockerfile + ignore: DL3007,DL3018 + - name: Build Dockerfile run: docker build . --file Dockerfile --tag redis:$(date +%s) @@ -16,6 +23,13 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + + - uses: hadolint/hadolint-action@v3.1.0 + 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) @@ -23,5 +37,12 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + + - uses: hadolint/hadolint-action@v3.1.0 + 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) diff --git a/.github/workflows/shell-script.yml b/.github/workflows/shell-script.yml new file mode 100644 index 0000000..c8c838c --- /dev/null +++ b/.github/workflows/shell-script.yml @@ -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 diff --git a/Dockerfile b/Dockerfile index 85653d4..ede992f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,12 @@ FROM alpine:3.15 as builder -MAINTAINER Opstree Solutions +LABEL maintainer="Opstree Solutions" ARG TARGETARCH -LABEL VERSION=1.0 \ - ARCH=$TARGETARCH \ - 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" ARG REDIS_DOWNLOAD_URL="http://download.redis.io/" @@ -14,22 +14,25 @@ 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 -LABEL VERSION=1.0 \ - ARCH=$TARGETARCH \ - 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 diff --git a/Dockerfile.exporter b/Dockerfile.exporter index 751aabb..55c412d 100644 --- a/Dockerfile.exporter +++ b/Dockerfile.exporter @@ -6,21 +6,23 @@ 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-$TARGETARCH.tar.gz \ - ${EXPORTER_URL}/v${REDIS_EXPORTER_VERSION}/redis_exporter-v${REDIS_EXPORTER_VERSION}.linux-$TARGETARCH.tar.gz && \ - cd /tmp && tar -xvzf redis_exporter-v${REDIS_EXPORTER_VERSION}.linux-$TARGETARCH.tar.gz && \ - mv redis_exporter-v${REDIS_EXPORTER_VERSION}.linux-$TARGETARCH 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 ARG TARGETARCH -MAINTAINER Opstree Solutions +LABEL maintainer="Opstree Solutions" -LABEL VERSION=1.0 \ - ARCH=$TARGETARCH \ - 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 diff --git a/Dockerfile.sentinel b/Dockerfile.sentinel index 912a236..63f0a23 100644 --- a/Dockerfile.sentinel +++ b/Dockerfile.sentinel @@ -2,9 +2,9 @@ FROM alpine:3.15 as builder ARG TARGETARCH -LABEL VERSION=1.0 \ - ARCH=$TARGETARCH \ - 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" ARG REDIS_DOWNLOAD_URL="http://download.redis.io/" @@ -12,20 +12,20 @@ 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 ARG TARGETARCH -LABEL VERSION=1.0 \ - ARCH=$TARGETARCH \ - 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-cli /usr/local/bin/redis-cli diff --git a/create-cluster.sh b/create-cluster.sh index 65bdde9..b9e6762 100755 --- a/create-cluster.sh +++ b/create-cluster.sh @@ -2,4 +2,4 @@ PODS="$1" -yes yes | redis-cli --cluster create ${PODS} +yes yes | redis-cli --cluster create "${PODS}" diff --git a/healthcheck-Sentinel.sh b/healthcheck-Sentinel.sh index 65a8622..13fea27 100755 --- a/healthcheck-Sentinel.sh +++ b/healthcheck-Sentinel.sh @@ -7,7 +7,7 @@ check_redis_health() { if [[ "${TLS_MODE}" == "true" ]]; then redis-cli --tls --cert "${REDIS_TLS_CERT}" --key "${REDIS_TLS_CERT_KEY}" --cacert "${REDIS_TLS_CA_KEY}" -h "$(hostname)" -p 26379 ping else - redis-cli -h $(hostname) -p 26379 ping + redis-cli -h "$(hostname)" -p 26379 ping fi } diff --git a/healthcheck.sh b/healthcheck.sh index 184ca1d..2b8166c 100755 --- a/healthcheck.sh +++ b/healthcheck.sh @@ -7,7 +7,7 @@ check_redis_health() { if [[ "${TLS_MODE}" == "true" ]]; then redis-cli --tls --cert "${REDIS_TLS_CERT}" --key "${REDIS_TLS_CERT_KEY}" --cacert "${REDIS_TLS_CA_KEY}" -h "$(hostname)" ping else - redis-cli -h $(hostname) ping + redis-cli -h "$(hostname)" ping fi }