Skip to content
This repository is currently being migrated. It's locked while the migration is in progress.

Hack a multi-arch image build using buildah. #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
40 changes: 40 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ IMAGE ?= storageos/init:test
GO_BUILD_CMD = go build -v
GO_ENV = GOOS=linux CGO_ENABLED=0

MPIMAGE ?= docker.io/soegarots/mpinit:latest

# Test node image name.
NODE_IMAGE ?= storageos/node:1.4.0
# Test scripts path.
Expand All @@ -27,6 +29,44 @@ docker-build:
docker-push:
docker push ${IMAGE}

SUDO = sudo
BUILDAH = $(SUDO) buildah
PODMAN = $(SUDO) podman

BUILD_DEPS =

BUILD_ARGS_COMMON =
BUILD_ARGS_ARM64 = $(BUILD_ARGS_COMMON)
BUILD_ARGS_AMD64 = $(BUILD_ARGS_COMMON)

BUILDAH_MANIFEST = mpbuild-init
BUILDAH_URI = docker://$(MPIMAGE)

mpbuild: mpbuild-prep mpbuild-amd64 mpbuild-arm64

mprelease: mpbuild-finalise

mpbuild-prep:
$(BUILDAH) manifest rm $(BUILDAH_MANIFEST) || true
$(BUILDAH) manifest create $(BUILDAH_MANIFEST)

mpbuild-amd64: $(BUILD_DEPS)
$(BUILDAH) build --tag $(MPIMAGE) $(BUILD_ARGS_AMD64) --manifest $(BUILDAH_MANIFEST) --arch amd64 .

mpbuild-arm64: $(BUILD_DEPS)
$(BUILDAH) build --tag $(MPIMAGE) $(BUILD_ARGS_ARM64) --manifest $(BUILDAH_MANIFEST) --arch arm64 .

mpbuild-finalise:
$(BUILDAH) manifest push --all $(BUILDAH_MANIFEST) $(BUILDAH_URI)


cache-build-amd64: $(BUILD_DEPS)
$(PODMAN) build --arch amd64 $(BUILD_ARGS_AMD64) -t deleteme:latest .

cache-build-arm64: $(BUILD_DEPS)
$(PODMAN) build --arch arm64 $(BUILD_ARGS_ARM64) -t deleteme:latest .


# Run tests
test: generate fmt vet
go test -v -race `go list -v ./...`
Expand Down
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Init Container for StorageOS

[![Test and build image](https://github.com/storageos/init/workflows/Test%20and%20build%20image/badge.svg)](https://github.com/storageos/init/actions?query=workflow%3A%22Test+and+build+image%22) [![Build Status](https://travis-ci.com/storageos/init.svg?branch=master)](https://travis-ci.com/storageos/init)
[![Test and build image](https://github.com/storageos/init/workflows/Test%20and%20build%20image/badge.svg)](https://github.com/storageos/init/actions?query=workflow%3A%22Test+and+build+image%22) [![Build Status](https://travis-ci.com/storageos/init.svg?branch=master)](https://travis-ci.com/storageos/init)

Init container to prepare the environment for StorageOS.

Expand Down Expand Up @@ -37,6 +37,22 @@ The version must be set in the `Dockerfile`. To set it, run:
NEW_VERSION=<version> make release
```

## HACK: multi-arch build and release

This will push `docker.io/soegarots/mpinit:latest` to Docker Hub. Change the image and tag using the Makefile variable `MPIMAGE`. If you don't have write access on Docker Hub, it will build but won't push.

```sh
$ sudo podman login --username MY-DOCKER_HUB_USERNAME
...

$ make mpbuild
...

$ make mprelease
...

```

## Run it on host

Build the init container with `make docker-build` and run it on the host with
Expand Down