Skip to content

Commit

Permalink
feat: support multi version build
Browse files Browse the repository at this point in the history
Signed-off-by: drivebyer <[email protected]>
  • Loading branch information
drivebyer committed Sep 13, 2024
1 parent 2c40687 commit bf9dc75
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 19 deletions.
23 changes: 19 additions & 4 deletions .github/workflows/push-image.yaml → .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Docker
name: Docker Image CD

on:
push:
Expand All @@ -11,6 +11,9 @@ env:

jobs:
build_redis:
strategy:
matrix:
version: [v6.2.14, v7.0.15, latest]
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -32,9 +35,14 @@ jobs:
file: Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: quay.io/opstree/redis:${{ env.REDIS_VERSION }}
build-args: |
REDIS_VERSION: ${{ matrix.version }}
tags: quay.io/opstree/redis:${{ matrix.version }}

build_redis_sentinel:
strategy:
matrix:
version: [v6.2.14, v7.0.15, latest]
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -56,9 +64,14 @@ jobs:
file: Dockerfile.sentinel
platforms: linux/amd64,linux/arm64
push: true
tags: quay.io/opstree/redis-sentinel:${{ env.REDIS_SENTINEL_VERSION }}
build-args: |
REDIS_SENTINEL_VERSION: ${{ matrix.version }}
tags: quay.io/opstree/redis-sentinel:${{ matrix.version }}

build_redis_exporter:
strategy:
matrix:
version: [v1.48.0]
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -80,4 +93,6 @@ jobs:
file: Dockerfile.exporter
platforms: linux/amd64,linux/arm64
push: true
tags: quay.io/opstree/redis-exporter:${{ env.REDIS_EXPORTER_VERSION }}
build-args: |
REDIS_EXPORTER_VERSION: ${{ matrix.version }}
tags: quay.io/opstree/redis-exporter:${{ matrix.version }}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Docker Image CI

on:
pull_request:
branches: [ "master" ]
branches: [master]

jobs:
build_dockerfile:
Expand All @@ -28,7 +28,7 @@ jobs:
name: Lint Dockerfile.exporter
with:
dockerfile: Dockerfile.exporter
ignore: DL3007,DL3018
ignore: DL3007,DL3018,SC2086,DL4006

- name: Build Dockerfile.exporter
run: docker build . --file Dockerfile.exporter --tag redis-exporter:$(date +%s)
Expand Down
9 changes: 6 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@ 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

WORKDIR /tmp

RUN curl -fL -Lo redis-${REDIS_VERSION}.tar.gz ${REDIS_DOWNLOAD_URL}/redis-${REDIS_VERSION}.tar.gz && \
RUN REDIS_VERSION=$(echo ${REDIS_VERSION} | sed 's/^v//'); \

Check failure on line 17 in Dockerfile

View workflow job for this annotation

GitHub Actions / build_dockerfile

DL4006 warning: Set the SHELL option -o pipefail before RUN with a pipe in it. If you are using /bin/sh in an alpine image or if your shell is symlinked to busybox then consider explicitly setting your SHELL to /bin/ash, or disable this check

Check failure on line 17 in Dockerfile

View workflow job for this annotation

GitHub Actions / build_dockerfile

SC2086 info: Double quote to prevent globbing and word splitting.
case "${REDIS_VERSION}" in \
latest | stable) REDIS_DOWNLOAD_URL="http://download.redis.io";; \
*) REDIS_DOWNLOAD_URL="http://download.redis.io/releases";; \
esac; \
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}
Expand Down
7 changes: 4 additions & 3 deletions Dockerfile.exporter
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ ARG REDIS_EXPORTER_VERSION="1.48.0"

WORKDIR /tmp

RUN apk add --no-cache curl ca-certificates && \
RUN REDIS_EXPORTER_VERSION=$(echo ${REDIS_EXPORTER_VERSION} | sed 's/^v//'); \
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 && \
${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
Expand Down
21 changes: 14 additions & 7 deletions Dockerfile.sentinel
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,31 @@ 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

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 && \
arch="$(uname -m)"; \
RUN REDIS_SENTINEL_VERSION=$(echo ${REDIS_SENTINEL_VERSION} | sed 's/^v//'); \

Check failure on line 15 in Dockerfile.sentinel

View workflow job for this annotation

GitHub Actions / build_dockerfile_sentinel

DL4006 warning: Set the SHELL option -o pipefail before RUN with a pipe in it. If you are using /bin/sh in an alpine image or if your shell is symlinked to busybox then consider explicitly setting your SHELL to /bin/ash, or disable this check

Check failure on line 15 in Dockerfile.sentinel

View workflow job for this annotation

GitHub Actions / build_dockerfile_sentinel

SC2086 info: Double quote to prevent globbing and word splitting.
case "${REDIS_SENTINEL_VERSION}" in \
latest | stable) REDIS_DOWNLOAD_URL="http://download.redis.io";; \
*) REDIS_DOWNLOAD_URL="http://download.redis.io/releases";; \
esac; \
\
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

WORKDIR /tmp/redis-${REDIS_SENTINEL_VERSION}

RUN arch="$(uname -m)"; \
extraJemallocConfigureFlags="--with-lg-page=16"; \
if [ "$arch" = "aarch64" ] || [ "$arch" = "arm64" ]; then \
sed -ri 's!cd jemalloc && ./configure !&'"$extraJemallocConfigureFlags"' !' /tmp/redis-${REDIS_SENTINEL_VERSION}/deps/Makefile; \
fi; \
export BUILD_TLS=yes; \
make -C redis-${REDIS_SENTINEL_VERSION} all; \
make -C redis-${REDIS_SENTINEL_VERSION} install
make all; \
make install

FROM alpine:3.15

Expand Down

0 comments on commit bf9dc75

Please sign in to comment.