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

Support build image on multi arch #46

Merged
merged 2 commits into from
Sep 23, 2023
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
86 changes: 62 additions & 24 deletions .github/workflows/push-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,80 @@ on:
push:
branches: [master]

env:
REDIS_VERSION: latest
REDIS_SENTINEL_VERSION: latest
REDIS_EXPORTER_VERSION: latest

jobs:
build_redis:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Login to Quay
run: docker login quay.io -u ${{ secrets.QUAY_USERNAME }} -p ${{ secrets.QUAY_PASSWORD }}
- name: Build and push Redis
env:
REDIS_VERSION: latest
run: |
docker build . --file Dockerfile --tag quay.io/opstree/redis:${REDIS_VERSION}
docker push quay.io/opstree/redis:${REDIS_VERSION}
uses: docker/login-action@v2
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: Build and push multi-arch latest image
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: quay.io/opstree/redis:${{ env.REDIS_VERSION }}

build_redis_sentinel:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Login to Quay
run: docker login quay.io -u ${{ secrets.QUAY_USERNAME }} -p ${{ secrets.QUAY_PASSWORD }}
- name: Build and push Redis Sentinel
env:
REDIS_SENTINEL_VERSION: latest
run: |
docker build . --file Dockerfile.sentinel --tag quay.io/opstree/redis-sentinel:${REDIS_SENTINEL_VERSION}
docker push quay.io/opstree/redis-sentinel:${REDIS_SENTINEL_VERSION}
uses: docker/login-action@v2
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: Build and push multi-arch latest image
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile.sentinel
platforms: linux/amd64,linux/arm64
push: true
tags: quay.io/opstree/redis-sentinel:${{ env.REDIS_SENTINEL_VERSION }}

build_redis_exporter:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Login to Quay
run: docker login quay.io -u ${{ secrets.QUAY_USERNAME }} -p ${{ secrets.QUAY_PASSWORD }}
- name: Build and push Redis Exporter
env:
REDIS_EXPORTER_VERSION: latest
run: |
docker build . --file Dockerfile.exporter --tag quay.io/opstree/redis-exporter:${REDIS_EXPORTER_VERSION}
docker push quay.io/opstree/redis-exporter:${REDIS_EXPORTER_VERSION}
uses: docker/login-action@v2
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: Build and push multi-arch latest image
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile.exporter
platforms: linux/amd64,linux/arm64
push: true
tags: quay.io/opstree/redis-exporter:${{ env.REDIS_EXPORTER_VERSION }}
8 changes: 6 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ FROM alpine:3.15 as builder

MAINTAINER Opstree Solutions

ARG TARGETARCH

LABEL VERSION=1.0 \
ARCH=AMD64 \
ARCH=$TARGETARCH \
DESCRIPTION="A production grade performance tuned redis docker image created by Opstree Solutions"

ARG REDIS_DOWNLOAD_URL="http://download.redis.io/"
Expand All @@ -23,8 +25,10 @@ FROM alpine:3.15

MAINTAINER Opstree Solutions

ARG TARGETARCH

LABEL VERSION=1.0 \
ARCH=AMD64 \
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
Expand Down
14 changes: 9 additions & 5 deletions Dockerfile.exporter
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
FROM alpine:3.15 as builder

ARG TARGETARCH

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-amd64.tar.gz \
${EXPORTER_URL}/v${REDIS_EXPORTER_VERSION}/redis_exporter-v${REDIS_EXPORTER_VERSION}.linux-amd64.tar.gz && \
cd /tmp && tar -xvzf redis_exporter-v${REDIS_EXPORTER_VERSION}.linux-amd64.tar.gz && \
mv redis_exporter-v${REDIS_EXPORTER_VERSION}.linux-amd64 redis_exporter
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

FROM scratch

ARG TARGETARCH

MAINTAINER Opstree Solutions

LABEL VERSION=1.0 \
ARCH=AMD64 \
ARCH=$TARGETARCH \
DESCRIPTION="A production grade redis exporter docker image created by Opstree Solutions"

COPY --from=builder /etc/ssl/certs /etc/ssl/certs
Expand Down
8 changes: 6 additions & 2 deletions Dockerfile.sentinel
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
FROM alpine:3.15 as builder

ARG TARGETARCH

LABEL VERSION=1.0 \
ARCH=AMD64 \
ARCH=$TARGETARCH \
DESCRIPTION="A production grade performance tuned redis docker image created by Opstree Solutions"

ARG REDIS_DOWNLOAD_URL="http://download.redis.io/"
Expand All @@ -19,8 +21,10 @@ RUN curl -fL -Lo /tmp/redis-${REDIS_SENTINEL_VERSION}.tar.gz ${REDIS_DOWNLOAD_UR

FROM alpine:3.15

ARG TARGETARCH

LABEL VERSION=1.0 \
ARCH=AMD64 \
ARCH=$TARGETARCH \
DESCRIPTION="A production grade performance tuned redis docker image created by Opstree Solutions"


Expand Down