Skip to content

Commit

Permalink
feat: support multi version build (#84)
Browse files Browse the repository at this point in the history
* feat: support multi version build

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

* update

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

---------

Signed-off-by: drivebyer <[email protected]>
  • Loading branch information
drivebyer authored Sep 13, 2024
1 parent 2c40687 commit 5ee526b
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 21 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 @@ -14,7 +14,7 @@ jobs:
name: Lint Dockerfile
with:
dockerfile: Dockerfile
ignore: DL3007,DL3018
ignore: DL3007,DL3018,SC2086,DL4006

- name: Build Dockerfile
run: docker build . --file Dockerfile --tag redis:$(date +%s)
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 All @@ -42,7 +42,7 @@ jobs:
name: Lint Dockerfile.sentinel
with:
dockerfile: Dockerfile.sentinel
ignore: DL3007,DL3018
ignore: DL3007,DL3018,SC2086,DL4006

- name: Build Dockerfile.sentinel
run: docker build . --file Dockerfile.sentinel --tag redis-sentinel:$(date +%s)
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//'); \
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//'); \
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 5ee526b

Please sign in to comment.