From a94a9a26b005c975fff33cffa645f9efe9e18cad Mon Sep 17 00:00:00 2001 From: Azanul Date: Fri, 6 Oct 2023 19:42:03 +0530 Subject: [PATCH 1/9] add hadolint to CI Signed-off-by: Azanul --- .github/workflows/docker-image.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 4816101..d2b9970 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -9,6 +9,12 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + + - uses: hadolint/hadolint-action@v3.1.0 + name: Lint Dockerfile + with: + dockerfile: Dockerfile + - name: Build Dockerfile run: docker build . --file Dockerfile --tag redis:$(date +%s) @@ -16,6 +22,12 @@ 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 + - name: Build Dockerfile.exporter run: docker build . --file Dockerfile.exporter --tag redis-exporter:$(date +%s) @@ -23,5 +35,11 @@ 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 + - name: Build Dockerfile.sentinel run: docker build . --file Dockerfile.sentinel --tag redis-sentinel:$(date +%s) From 0749eda010278088b22d20a1adc2761aac3da061 Mon Sep 17 00:00:00 2001 From: Azanul Date: Fri, 6 Oct 2023 19:42:32 +0530 Subject: [PATCH 2/9] maintainer is depreciated Signed-off-by: Azanul --- Dockerfile | 4 ++-- Dockerfile.exporter | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 85653d4..0ec0e33 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM alpine:3.15 as builder -MAINTAINER Opstree Solutions +LABEL maintainer="Opstree Solutions" ARG TARGETARCH @@ -23,7 +23,7 @@ RUN curl -fL -Lo /tmp/redis-${REDIS_VERSION}.tar.gz ${REDIS_DOWNLOAD_URL}/redis- FROM alpine:3.15 -MAINTAINER Opstree Solutions +LABEL maintainer="Opstree Solutions" ARG TARGETARCH diff --git a/Dockerfile.exporter b/Dockerfile.exporter index 751aabb..ccd9261 100644 --- a/Dockerfile.exporter +++ b/Dockerfile.exporter @@ -16,7 +16,7 @@ FROM scratch ARG TARGETARCH -MAINTAINER Opstree Solutions +LABEL maintainer="Opstree Solutions" LABEL VERSION=1.0 \ ARCH=$TARGETARCH \ From 2265418ade2fb02bf61aa98da7f0af5d77f16749 Mon Sep 17 00:00:00 2001 From: Azanul Date: Fri, 6 Oct 2023 20:14:54 +0530 Subject: [PATCH 3/9] shell check changes Signed-off-by: Azanul --- create-cluster.sh | 2 +- healthcheck-Sentinel.sh | 2 +- healthcheck.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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 } From d9dfe502c01aa7ca84d7440e314b2f0e394f1e5c Mon Sep 17 00:00:00 2001 From: Azanul Date: Fri, 6 Oct 2023 20:27:39 +0530 Subject: [PATCH 4/9] add shellcheck CI Signed-off-by: Azanul --- .github/workflows/shell-script.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .github/workflows/shell-script.yml 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 From d0b72563118968ceb99837e821a34664cf3fa5d7 Mon Sep 17 00:00:00 2001 From: Azanul Date: Fri, 6 Oct 2023 21:04:15 +0530 Subject: [PATCH 5/9] invalid label key fix Signed-off-by: Azanul --- Dockerfile | 6 +++--- Dockerfile.exporter | 6 +++--- Dockerfile.sentinel | 12 ++++++------ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0ec0e33..afe88aa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,9 +27,9 @@ 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 ccd9261..2dcaa89 100644 --- a/Dockerfile.exporter +++ b/Dockerfile.exporter @@ -18,9 +18,9 @@ ARG TARGETARCH 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..0b9c60c 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/" @@ -23,9 +23,9 @@ 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 From 4354b106060b41a975d79bc563253b716d930a0a Mon Sep 17 00:00:00 2001 From: Azanul Date: Fri, 6 Oct 2023 23:59:36 +0530 Subject: [PATCH 6/9] Docker files lint fixes Signed-off-by: Azanul --- Dockerfile | 16 ++++++++-------- Dockerfile.exporter | 10 +++++----- Dockerfile.sentinel | 10 +++++----- hadolint.yaml | 3 +++ 4 files changed, 21 insertions(+), 18 deletions(-) create mode 100644 hadolint.yaml diff --git a/Dockerfile b/Dockerfile index afe88aa..da54a6f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,9 +4,9 @@ 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,12 +14,12 @@ 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 && \ +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 && \ - cd redis-${REDIS_VERSION} && \ - make && \ - make install BUILD_TLS=yes + make -C redis-${REDIS_VERSION} && \ + make -C redis-${REDIS_VERSION} install BUILD_TLS=yes FROM alpine:3.15 diff --git a/Dockerfile.exporter b/Dockerfile.exporter index 2dcaa89..2a71dfe 100644 --- a/Dockerfile.exporter +++ b/Dockerfile.exporter @@ -6,11 +6,11 @@ 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 +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 diff --git a/Dockerfile.sentinel b/Dockerfile.sentinel index 0b9c60c..63f0a23 100644 --- a/Dockerfile.sentinel +++ b/Dockerfile.sentinel @@ -12,12 +12,12 @@ 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 diff --git a/hadolint.yaml b/hadolint.yaml new file mode 100644 index 0000000..f02c9fb --- /dev/null +++ b/hadolint.yaml @@ -0,0 +1,3 @@ +ignored: + - DL3007 + - DL3018 \ No newline at end of file From 61839eeeeb0e44477940f5a1ee9d478a1d12deaa Mon Sep 17 00:00:00 2001 From: Azanul Date: Sat, 7 Oct 2023 00:56:19 +0530 Subject: [PATCH 7/9] CI fail Signed-off-by: Azanul --- .github/workflows/docker-image.yml | 3 +++ Dockerfile | 9 ++++++--- Dockerfile.exporter | 2 ++ hadolint.yaml | 3 --- 4 files changed, 11 insertions(+), 6 deletions(-) delete mode 100644 hadolint.yaml diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index d2b9970..4674582 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -14,6 +14,7 @@ jobs: name: Lint Dockerfile with: dockerfile: Dockerfile + ignore: DL3007,DL3018 - name: Build Dockerfile run: docker build . --file Dockerfile --tag redis:$(date +%s) @@ -27,6 +28,7 @@ jobs: 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) @@ -40,6 +42,7 @@ jobs: 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/Dockerfile b/Dockerfile index da54a6f..ede992f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,9 +17,12 @@ RUN apk add --no-cache su-exec tzdata make curl build-base linux-headers bash op 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 && \ - make -C redis-${REDIS_VERSION} && \ - make -C redis-${REDIS_VERSION} install BUILD_TLS=yes + tar xvzf redis-${REDIS_VERSION}.tar.gz + +WORKDIR /tmp/redis-${REDIS_VERSION} + +RUN make && \ + make install BUILD_TLS=yes FROM alpine:3.15 diff --git a/Dockerfile.exporter b/Dockerfile.exporter index 2a71dfe..55c412d 100644 --- a/Dockerfile.exporter +++ b/Dockerfile.exporter @@ -6,6 +6,8 @@ ARG EXPORTER_URL="https://github.com/oliver006/redis_exporter/releases/download" ARG REDIS_EXPORTER_VERSION="1.48.0" +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 && \ diff --git a/hadolint.yaml b/hadolint.yaml deleted file mode 100644 index f02c9fb..0000000 --- a/hadolint.yaml +++ /dev/null @@ -1,3 +0,0 @@ -ignored: - - DL3007 - - DL3018 \ No newline at end of file From 6d1a52c66bfc5a843fa7ba48f4e0df55ac0e317b Mon Sep 17 00:00:00 2001 From: Azanul Date: Sat, 7 Oct 2023 01:09:49 +0530 Subject: [PATCH 8/9] check shellcheck Signed-off-by: Azanul --- create-cluster.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/create-cluster.sh b/create-cluster.sh index b9e6762..65bdde9 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} From 3a32b1463c5744c9ba594cf721f8ea820efb2bd5 Mon Sep 17 00:00:00 2001 From: Azanul Date: Sat, 7 Oct 2023 01:12:48 +0530 Subject: [PATCH 9/9] shellcheck fix Signed-off-by: Azanul --- create-cluster.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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}"