Skip to content

Commit

Permalink
add linux/arm64 variant
Browse files Browse the repository at this point in the history
  • Loading branch information
csandanov committed Feb 26, 2025
1 parent 94099e5 commit d35df82
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 31 deletions.
19 changes: 10 additions & 9 deletions .github/actions/action.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
name: Build
description: Build memcached image
name: push
description: combine multi-arch image and push
inputs:
version:
description: version
required: true
tags:
description: image tags
required: true
latest:
description: if tag latest
required: false
latest_major:
description: if tag latest major version
required: false
runs:
using: "composite"
steps:
- name: Build image
env:
MEMCACHED_VER: ${{ inputs.version }}
TAGS: ${{ inputs.tags }}
LATEST: ${{ inputs.latest }}
LATEST_MAJOR: ${{ inputs.latest_major }}
run: |
set -e
make
make test
. $GITHUB_ACTION_PATH/release.sh
shell: bash
33 changes: 23 additions & 10 deletions .github/actions/release.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
#!/usr/bin/env bash

set -e
set -exo pipefail

if [[ "${GITHUB_REF}" == refs/heads/master || "${GITHUB_REF}" == refs/tags/* ]]; then
docker login -u "${DOCKER_USERNAME}" -p "${DOCKER_PASSWORD}"
if [[ "${GITHUB_REF}" == refs/heads/master || "${GITHUB_REF}" == refs/tags/* ]]; then
minor_ver="${MEMCACHED_VER%.*}"
major_ver="${minor_ver%.*}"

if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
export STABILITY_TAG="${GITHUB_REF##*/}"
fi
tags=("${minor_ver}")

if [[ -n "${LATEST_MAJOR}" ]]; then
tags+=("${major_ver}")
fi

IFS=',' read -ra tags <<< "${TAGS}"
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
stability_tag=("${GITHUB_REF##*/}")
tags=("${minor_ver}-${stability_tag}")
if [[ -n "${LATEST_MAJOR}" ]]; then
tags+=("${major_ver}-${stability_tag}")
fi
else
if [[ -n "${LATEST}" ]]; then
tags+=("latest")
fi
fi

for tag in "${tags[@]}"; do
make release TAG="${tag}";
done
for tag in "${tags[@]}"; do
make buildx-imagetools-create TAG=${tag}
done
fi
50 changes: 44 additions & 6 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,51 @@ on:
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
MEMCACHED1: '1.6.37'

jobs:
memcached-1:
memcached1-build:
strategy:
matrix:
platform:
- linux/amd64
- linux/arm64
include:
- platform: linux/amd64
runner: ubuntu-24.04
arch: amd64
- platform: linux/arm64
runner: ubuntu-24.04-arm
arch: arm64
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v4
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- uses: docker/setup-buildx-action@v3
- name: build and push
env:
MEMCACHED_VER: ${{ env.MEMCACHED1 }}
ARCH: ${{ matrix.arch }}
PLATFORM: ${{ matrix.platform }}
run: |
make buildx-build
make test
make buildx-push
memcached1-push:
runs-on: ubuntu-latest
needs:
- memcached1-build
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions
with:
version: '1.6.37'
tags: 1,latest
- uses: actions/checkout@v4
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- uses: ./.github/actions
with:
version: ${{ env.MEMCACHED1 }}
latest: true
latest_major: true
31 changes: 25 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@

MEMCACHED_VER ?= 1.6.37

TAG ?= $(shell echo "${MEMCACHED_VER}" | grep -oE '^[0-9]+\.[0-9]+')
MEMCACHED_VER_MINOR ?= $(shell echo "${MEMCACHED_VER}" | grep -oE '^[0-9]+\.[0-9]+')

TAG ?= $(MEMCACHED_VER_MINOR)

REPO = wodby/memcached
NAME = memcached-$(MEMCACHED_VER)

ifneq ($(STABILITY_TAG),)
ifneq ($(TAG),latest)
override TAG := $(TAG)-$(STABILITY_TAG)
endif
PLATFORM ?= linux/arm64

ifneq ($(ARCH),)
override TAG := $(TAG)-$(ARCH)
endif

.PHONY: build test push shell run start stop logs clean release
.PHONY: build buildx-build buildx-imagetools-create buildx-push test push shell run start stop logs clean release

default: build

Expand All @@ -22,6 +24,23 @@ build:
--build-arg MEMCACHED_VER=$(MEMCACHED_VER) \
./

buildx-build:
docker buildx build --platform $(PLATFORM) -t $(REPO):$(TAG) \
--build-arg MEMCACHED_VER=$(MEMCACHED_VER) \
--load \
./

buildx-push:
docker buildx build --platform $(PLATFORM) --push -t $(REPO):$(TAG) \
--build-arg MEMCACHED_VER=$(MEMCACHED_VER) \
./

buildx-imagetools-create:
docker buildx imagetools create -t $(REPO):$(TAG) \
$(REPO):$(MEMCACHED_VER_MINOR)-amd64 \
$(REPO):$(MEMCACHED_VER_MINOR)-arm64
.PHONY: buildx-imagetools-create

test:
cd ./tests && IMAGE=$(REPO):$(TAG) NAME=$(NAME) ./run.sh

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Supported tags and respective `Dockerfile` links:

- `1`, `latest` [_(Dockerfile)_]

All images built for `linux/amd64` and `linux/arm64`

## Orchestration Actions

Usage:
Expand Down

0 comments on commit d35df82

Please sign in to comment.