Skip to content

Commit 4a9c29e

Browse files
authored
Merge pull request #6 from decisivellc/base-updates
Add multi-architecture build support
2 parents 268881d + dbb28a6 commit 4a9c29e

6 files changed

Lines changed: 149 additions & 135 deletions

File tree

.github/workflows/master.yml

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,46 @@
1-
name: Build Master
1+
name: Build and Push Multi-Arch Images
22

33
on:
44
push:
55
branches:
66
- master
7+
workflow_dispatch:
78

89
jobs:
9-
build:
10+
build-and-push:
1011
runs-on: ubuntu-latest
1112
steps:
12-
- uses: actions/checkout@master
13-
- name: build
14-
run: make image IMAGE_VERSION=latest
15-
- uses: actions/docker/login@master
16-
env:
17-
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
18-
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
19-
- name: push
20-
run: make push IMAGE_VERSION=latest
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
- name: Set up QEMU
17+
uses: docker/setup-qemu-action@v3
18+
with:
19+
platforms: linux/amd64,linux/arm64
20+
21+
- name: Set up Docker Buildx
22+
uses: docker/setup-buildx-action@v3
23+
with:
24+
install: true
25+
26+
- name: Log in to Docker Hub
27+
uses: docker/login-action@v3
28+
with:
29+
username: ${{ secrets.DOCKER_USERNAME }}
30+
password: ${{ secrets.DOCKER_PASSWORD }}
31+
32+
- name: Build and push multi-arch images
33+
uses: docker/build-push-action@v5
34+
with:
35+
context: .
36+
platforms: linux/amd64,linux/arm64
37+
push: true
38+
tags: |
39+
codice/ddf-base:3.0
40+
codice/ddf-base:latest
41+
cache-from: type=gha
42+
cache-to: type=gha,mode=max
43+
44+
- name: Inspect multi-arch manifest
45+
run: docker buildx imagetools inspect codice/ddf-base:3.0
2146

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,5 @@ Temporary Items
2727

2828
.tools
2929
.idea/
30+
.claude/
31+
CLAUDE.md

Dockerfile

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,35 @@
11
# Generate commands from argbash templates
2-
FROM matejak/argbash:2.7.1-1 as argbash
3-
ADD "https://raw.githubusercontent.com/oconnormi/dev-tools/master/templates/ddf-create-cdm.m4" /work/create-cdm.m4
2+
FROM --platform=$BUILDPLATFORM matejak/argbash:2.7.1-1 AS argbash
3+
# Copy all templates including vendored create-cdm.m4 (eliminates external dependency)
44
COPY argbash-templates/* /work/
55
RUN ./build.sh
66

77
# Create base for final image
8-
FROM eclipse-temurin:17-jre-alpine as base
8+
FROM azul/zulu-openjdk-alpine:17-latest AS base
99
LABEL maintainer=oconnormi
1010
LABEL org.codice.application.type=ddf
1111

1212
ENV ENTRYPOINT_HOME=/opt/entrypoint
1313

1414
RUN mkdir -p $ENTRYPOINT_HOME
1515

16-
RUN apk add --no-cache curl openssl gettext bash
17-
RUN curl -L https://github.com/oconnormi/props/releases/download/v0.2.0/props_linux_amd64 -o /usr/local/bin/props \
18-
&& chmod 755 /usr/local/bin/props
19-
RUN curl -LsSk https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64 -o /usr/local/bin/jq \
20-
&& chmod 755 /usr/local/bin/jq
16+
# Install Alpine packages (jq now from Alpine repos for multi-arch support)
17+
RUN apk add --no-cache curl openssl gettext bash jq
18+
19+
# Install props tool with multi-architecture support from codice/props fork
20+
ARG TARGETARCH
21+
ARG PROPS_VERSION=0.1.1
22+
RUN set -eux; \
23+
case "${TARGETARCH}" in \
24+
amd64) PROPS_ARCH='amd64' ;; \
25+
arm64) PROPS_ARCH='arm64' ;; \
26+
*) echo "Unsupported architecture: ${TARGETARCH}" && exit 1 ;; \
27+
esac; \
28+
echo "Installing props v${PROPS_VERSION} for ${TARGETARCH}"; \
29+
curl -fsSL "https://github.com/codice/props/releases/download/v${PROPS_VERSION}/props_${PROPS_VERSION}_linux_${PROPS_ARCH}" \
30+
-o /usr/local/bin/props; \
31+
chmod 755 /usr/local/bin/props; \
32+
props version || props help
2133

2234
COPY entrypoint/* $ENTRYPOINT_HOME/
2335
COPY --from=argbash /out/cmd/* /usr/local/bin/

Jenkinsfile

Lines changed: 0 additions & 32 deletions
This file was deleted.

Makefile

Lines changed: 91 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,109 @@ IMAGE_NAME:=codice/ddf-base
33

44
GIT_SHA:=$(shell git rev-parse HEAD)
55
MASTER_SHA:=$(shell git show-ref -s refs/heads/master)
6-
IMAGE_VERSION=2.29-alpine
6+
IMAGE_VERSION=3.0
77

8-
# Compute Build Tag
8+
# Multi-architecture configuration
9+
PLATFORMS:=linux/amd64,linux/arm64
10+
BUILDER_NAME:=ddf-multiarch
11+
12+
# Compute Build Tags
913
BUILD_TAG=$(IMAGE_NAME):$(IMAGE_VERSION)
14+
LATEST_TAG=$(IMAGE_NAME):latest
1015

1116
.DEFAULT_GOAL := help
1217

1318
.PHONY: help
1419
help: ## Display help.
1520
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
1621

22+
.PHONY: info
23+
info: ## Show build information (versions, tags, platforms)
24+
@echo "Image Name: $(IMAGE_NAME)"
25+
@echo "Version: $(IMAGE_VERSION)"
26+
@echo "Build Tag: $(BUILD_TAG)"
27+
@echo "Latest Tag: $(LATEST_TAG)"
28+
@echo "Platforms: $(PLATFORMS)"
29+
@echo "Builder: $(BUILDER_NAME)"
30+
@echo "Git SHA: $(GIT_SHA)"
31+
32+
.PHONY: setup-buildx
33+
setup-buildx: ## Set up Docker Buildx builder (first time only)
34+
@echo "Setting up Docker Buildx builder: $(BUILDER_NAME)"
35+
@if ! docker buildx ls | grep -q $(BUILDER_NAME); then \
36+
docker buildx create --name $(BUILDER_NAME) --use --bootstrap; \
37+
echo "Builder $(BUILDER_NAME) created and activated"; \
38+
else \
39+
docker buildx use $(BUILDER_NAME); \
40+
echo "Builder $(BUILDER_NAME) already exists, activated"; \
41+
fi
42+
1743
.PHONY: image
18-
image: ## Build the docker image
19-
@echo "Building $(BUILD_TAG)"
20-
@docker build --pull -t $(BUILD_TAG) .
44+
image: ## Build the docker image for current architecture
45+
@echo "Building $(BUILD_TAG) for current architecture"
46+
@docker build --pull -t $(BUILD_TAG) -t $(LATEST_TAG) .
47+
48+
.PHONY: dev-build
49+
dev-build: image ## Alias for 'image' target
50+
51+
.PHONY: image-multiarch
52+
image-multiarch: setup-buildx ## Build multi-arch images locally (stores in build cache)
53+
@echo "Building $(BUILD_TAG) for $(PLATFORMS)"
54+
@docker buildx build \
55+
--platform $(PLATFORMS) \
56+
--pull \
57+
-t $(BUILD_TAG) \
58+
-t $(LATEST_TAG) \
59+
.
60+
@echo "Multi-arch build complete (stored in build cache)"
2161

2262
.PHONY: push
23-
push: image ## Push the docker image
63+
push: image ## Push single-architecture docker image
2464
@echo "Pushing $(BUILD_TAG)"
2565
@docker push $(BUILD_TAG)
66+
@docker push $(LATEST_TAG)
67+
68+
.PHONY: push-multiarch
69+
push-multiarch: setup-buildx ## Build and push multi-arch images to registry
70+
@echo "Building and pushing $(BUILD_TAG) for $(PLATFORMS)"
71+
@docker buildx build \
72+
--platform $(PLATFORMS) \
73+
--pull \
74+
-t $(BUILD_TAG) \
75+
-t $(LATEST_TAG) \
76+
--push \
77+
.
78+
@echo "Multi-arch images pushed successfully"
79+
80+
.PHONY: test-amd64
81+
test-amd64: ## Test AMD64 architecture build
82+
@echo "Testing AMD64 build..."
83+
@docker run --rm --platform linux/amd64 $(BUILD_TAG) /bin/bash -c "props version && jq --version"
84+
@echo "AMD64 test passed"
85+
86+
.PHONY: test-arm64
87+
test-arm64: ## Test ARM64 architecture build
88+
@echo "Testing ARM64 build..."
89+
@docker run --rm --platform linux/arm64 $(BUILD_TAG) /bin/bash -c "props version && jq --version"
90+
@echo "ARM64 test passed"
91+
92+
.PHONY: test-all
93+
test-all: image-multiarch test-amd64 test-arm64 ## Build and test both architectures
94+
95+
.PHONY: inspect
96+
inspect: ## Inspect multi-arch manifest
97+
@echo "Inspecting manifest for $(BUILD_TAG)"
98+
@docker buildx imagetools inspect $(BUILD_TAG)
99+
100+
.PHONY: clean
101+
clean: ## Clean up build resources
102+
@echo "Cleaning up build resources..."
103+
@docker buildx prune -f
104+
@echo "Cleanup complete"
105+
106+
.PHONY: clean-builder
107+
clean-builder: ## Remove buildx builder
108+
@echo "Removing builder $(BUILDER_NAME)"
109+
@docker buildx rm $(BUILDER_NAME) || true
110+
@echo "Builder removed"
26111

argbash-templates/create-source.m4

Lines changed: 0 additions & 78 deletions
This file was deleted.

0 commit comments

Comments
 (0)