Skip to content

Commit

Permalink
Dockerfile & shell files lint (#58)
Browse files Browse the repository at this point in the history
* add hadolint to CI

Signed-off-by: Azanul <[email protected]>

* maintainer is depreciated

Signed-off-by: Azanul <[email protected]>

* shell check changes

Signed-off-by: Azanul <[email protected]>

* add shellcheck CI

Signed-off-by: Azanul <[email protected]>

* invalid label key fix

Signed-off-by: Azanul <[email protected]>

* Docker files lint fixes

Signed-off-by: Azanul <[email protected]>

* CI fail

Signed-off-by: Azanul <[email protected]>

* check shellcheck

Signed-off-by: Azanul <[email protected]>

* shellcheck fix

Signed-off-by: Azanul <[email protected]>

---------

Signed-off-by: Azanul <[email protected]>
  • Loading branch information
Azanul authored Oct 6, 2023
1 parent e34e811 commit 7372305
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 36 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)
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
29 changes: 16 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,35 +1,38 @@
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/"

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
Expand Down
20 changes: 11 additions & 9 deletions Dockerfile.exporter
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 11 additions & 11 deletions Dockerfile.sentinel
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,30 @@ 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/"

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
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}"
2 changes: 1 addition & 1 deletion healthcheck-Sentinel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion healthcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 7372305

Please sign in to comment.