Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support multi version build #84

Merged
merged 2 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading