Skip to content

Commit

Permalink
build: make latest tag same hash, push latest for most (ddev#6622) [s…
Browse files Browse the repository at this point in the history
…kip ci]
  • Loading branch information
rfay authored Oct 17, 2024
1 parent f2db51c commit 788720e
Show file tree
Hide file tree
Showing 14 changed files with 32 additions and 54 deletions.
25 changes: 12 additions & 13 deletions containers/containers_shared.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,17 @@ container-name:
@echo "container: $(DOCKER_REPO):$(VERSION)"

push:
docker buildx use multi-arch-builder >/dev/null 2>&1 || docker buildx create --name multi-arch-builder --use
docker buildx build --push --platform $(BUILD_ARCHS) \
-t $(DOCKER_REPO):$(VERSION) \
--label "build-info=$(DOCKER_REPO):$(VERSION) commit=$(shell git describe --tags --always) built $$(date) by $$(id -un) on $$(hostname)" \
--label "maintainer=DDEV <[email protected]>" \
$(DOCKER_ARGS) .
# If this is a stable version, then push the "latest" tag, which we don't currently
# use except with ddev-gitpod-base
if [[ "$(VERSION)" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$$ ]] ; then \
set -eu -o pipefail; \
for item in $(DEFAULT_IMAGES); do \
docker buildx use multi-arch-builder >/dev/null 2>&1 || docker buildx create --name multi-arch-builder --use; \
tags="-t $(DOCKER_ORG)/$${item}:$(VERSION)"; \
if [[ "$(VERSION)" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$$ ]] ; then \
tags="$${tags} -t $(DOCKER_ORG)/$${item}:latest"; \
fi; \
docker buildx build --push --platform $(BUILD_ARCHS) \
-t $(DOCKER_REPO):latest \
--label "build-info=$(DOCKER_REPO):$(VERSION) commit=$(shell git describe --tags --always) built $$(date) by $$(id -un) on $$(hostname)" \
--target=$${item} \
$${tags} \
--label "build-info=$(DOCKER_ORG)/$${item}:$(VERSION) commit=$(shell git describe --tags --always) built $$(date) by $$(id -un) on $$(hostname)" \
--label "maintainer=DDEV <[email protected]>" \
$(DOCKER_ARGS) . ;\
fi
$(DOCKER_ARGS) . ; \
done
9 changes: 7 additions & 2 deletions containers/ddev-dbserver/build_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,21 @@ if [ ${DB_TYPE} = "mysql" ] && [[ "$ARCHS" == *"linux/arm64"* ]]; then
fi
printf "\n\n========== Building ddev/ddev-dbserver-${DB_TYPE}-${DB_MAJOR_VERSION}:${IMAGE_TAG} from ${BASE_IMAGE} for ${ARCHS} with pinned version ${DB_PINNED_VERSION} ==========\n"

# Build up the -t section with optionally both tags
tag_directive="-t ${DOCKER_ORG}/ddev-dbserver-${DB_TYPE}-${DB_MAJOR_VERSION}:${IMAGE_TAG}"
if [[ ${IMAGE_TAG} =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
tag_directive="$tag_directive -t ${DOCKER_ORG}/ddev-dbserver-${DB_TYPE}-${DB_MAJOR_VERSION}:latest"
fi
if [ ! -z ${PUSH:-} ]; then
echo "building/pushing ddev/ddev-dbserver-${DB_TYPE}-${DB_MAJOR_VERSION}:${IMAGE_TAG}"
set -x
docker buildx build --push --platform ${ARCHS} ${DOCKER_ARGS} --build-arg="BASE_IMAGE=${BASE_IMAGE}" --build-arg="DB_PINNED_VERSION=${DB_PINNED_VERSION}" --build-arg="DB_VERSION=${DB_MAJOR_VERSION}" -t "${DOCKER_ORG}/ddev-dbserver-${DB_TYPE}-${DB_MAJOR_VERSION}:${IMAGE_TAG}" .
docker buildx build --push --platform ${ARCHS} ${DOCKER_ARGS} --build-arg="BASE_IMAGE=${BASE_IMAGE}" --build-arg="DB_PINNED_VERSION=${DB_PINNED_VERSION}" --build-arg="DB_VERSION=${DB_MAJOR_VERSION}" ${tag_directive} .
set +x
fi

# By default, load/import into local docker
set -x
if [ -z "${PUSH:-}" ]; then
echo "Loading to local docker ddev/ddev-dbserver-${DB_TYPE}-${DB_MAJOR_VERSION}:${IMAGE_TAG}"
docker buildx build --load ${DOCKER_ARGS} --build-arg="DB_TYPE=${DB_TYPE}" --build-arg="DB_VERSION=${DB_MAJOR_VERSION}" --build-arg="BASE_IMAGE=${BASE_IMAGE}" --build-arg="DB_PINNED_VERSION=${DB_PINNED_VERSION}" -t "${DOCKER_ORG}/ddev-dbserver-${DB_TYPE}-${DB_MAJOR_VERSION}:${IMAGE_TAG}" .
docker buildx build --load ${DOCKER_ARGS} --build-arg="DB_TYPE=${DB_TYPE}" --build-arg="DB_VERSION=${DB_MAJOR_VERSION}" --build-arg="BASE_IMAGE=${BASE_IMAGE}" --build-arg="DB_PINNED_VERSION=${DB_PINNED_VERSION}" ${tag_directive} .
fi
2 changes: 1 addition & 1 deletion containers/ddev-gitpod-base/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# https://github.com/ddev/ddev/pull/6613 had an attempt to build our own
# multi-arch workspace-base image, but it had its own problems and was abandoned.
FROM gitpod/workspace-base:latest AS workspace-base
FROM gitpod/workspace-base:latest AS ddev-gitpod-base
SHELL ["/bin/bash", "-c"]

USER root
Expand Down
1 change: 1 addition & 0 deletions containers/ddev-gitpod-base/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Docker repo for a push
DOCKER_REPO ?= $(DOCKER_ORG)/ddev-gitpod-base
DEFAULT_IMAGES = ddev-gitpod-base

VERSION := $(shell git describe --tags --always --dirty)

Expand Down
2 changes: 1 addition & 1 deletion containers/ddev-nginx-proxy-router/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM nginx:1.20.1
FROM nginx:1.20.1 AS ddev-nginx-proxy-router

ENV MKCERT_VERSION=v1.4.6

Expand Down
1 change: 1 addition & 0 deletions containers/ddev-nginx-proxy-router/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Docker repo for a push
DOCKER_REPO ?= $(DOCKER_ORG)/ddev-nginx-proxy-router
DEFAULT_IMAGES = ddev-nginx-proxy-router

VERSION := $(shell git describe --tags --always --dirty)

Expand Down
12 changes: 2 additions & 10 deletions containers/ddev-php-base/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,10 @@ images: $(DEFAULT_IMAGES)

$(DEFAULT_IMAGES):
set -eu -o pipefail; \
DOCKER_BUILDKIT=1 docker build --label com.ddev.buildhost=${shell hostname} --target=$@ -t $(DOCKER_ORG)/$@:$(VERSION) $(DOCKER_ARGS) .


push:
set -eu -o pipefail; \
for item in $(DEFAULT_IMAGES); do \
docker buildx build --push --platform $(BUILD_ARCHS) --label com.ddev.buildhost=${shell hostname} --target=$$item -t $(DOCKER_ORG)/$$item:$(VERSION) $(DOCKER_ARGS) .; \
echo "pushed $(DOCKER_ORG)/$$item:$(VERSION)"; \
done
docker buildx build --label com.ddev.buildhost=${shell hostname} --target=$@ -t $(DOCKER_ORG)/$@:$(VERSION) $(DOCKER_ARGS) .

test: $(DEFAULT_IMAGES)
DOCKER_BUILDKIT=1 docker build --label com.ddev.buildhost=${shell hostname} --label com.ddev.buildinfo="$(BUILDINFO)" -t $(DOCKER_ORG)/$<:$(VERSION) $(DOCKER_ARGS) .
docker buildx build --label com.ddev.buildhost=${shell hostname} --label com.ddev.buildinfo="$(BUILDINFO)" -t $(DOCKER_ORG)/$<:$(VERSION) $(DOCKER_ARGS) .
for item in $(DEFAULT_IMAGES); do \
if [ -x tests/$$item/test.sh ]; then tests/$$item/test.sh $(DOCKER_ORG)/$$item:$(VERSION); fi; \
done
Expand Down
2 changes: 1 addition & 1 deletion containers/ddev-ssh-agent/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM debian:bullseye-slim
FROM debian:bullseye-slim AS ddev-ssh-agent

RUN apt-get update && apt-get install -y bash expect file gpg openssh-client socat psmisc && apt-get autoclean

Expand Down
6 changes: 2 additions & 4 deletions containers/ddev-ssh-agent/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

VERSION := $(shell git describe --tags --always --dirty)

DEFAULT_IMAGES = ddev-ssh-agent

# Tests always run against amd64 (build host). Once tests have passed, a multi-arch build
# will be generated and pushed (the amd64 build will be cached automatically to prevent it from building twice).
BUILD_ARCHS=linux/amd64,linux/arm64
Expand All @@ -9,9 +11,5 @@ include ../containers_shared.mk

DOCKER_REPO ?= $(DOCKER_ORG)/ddev-ssh-agent

multi-arch:
docker buildx build --platform $(BUILD_ARCHS) -t $(DOCKER_REPO):$(VERSION) $(DOCKER_ARGS) .; \
echo "created multi-arch builds $(BUILD_ARCHS) for $(DOCKER_REPO)";

test: container
test/test.sh $(DOCKER_REPO):$(VERSION)
2 changes: 1 addition & 1 deletion containers/ddev-traefik-router/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM traefik:3.0
FROM traefik:3.0 AS ddev-traefik-router

ENV TRAEFIK_MONITOR_PORT=10999
RUN apk add bash curl htop vim
Expand Down
1 change: 1 addition & 0 deletions containers/ddev-traefik-router/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
VERSION := $(shell git describe --tags --always --dirty)
DEFAULT_IMAGES = ddev-traefik-router

# Tests always run against amd64 (build host). Once tests have passed, a multi-arch build
# will be generated and pushed (the amd64 build will be cached automatically to prevent it from building twice).
Expand Down
14 changes: 0 additions & 14 deletions containers/ddev-webserver/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,6 @@ DOCKER_REPO ?= $(DOCKER_ORG)/ddev-webserver

images: $(DEFAULT_IMAGES)

push:
set -eu -o pipefail; \
for item in $(DEFAULT_IMAGES); do \
docker buildx build --push --platform $(BUILD_ARCHS) --label com.ddev.buildhost=${shell hostname} --target=$$item -t $(DOCKER_ORG)/$$item:$(VERSION) $(DOCKER_ARGS) .; \
echo "pushed $(DOCKER_ORG)/$$item"; \
done

multi-arch:
set -eu -o pipefail; \
for item in $(DEFAULT_IMAGES); do \
docker buildx build --platform $(BUILD_ARCHS) --label com.ddev.buildhost=${shell hostname} --target=$$item -t $(DOCKER_ORG)/$$item:$(VERSION) $(DOCKER_ARGS) .; \
echo "created multi-arch builds $(BUILD_ARCHS) for $(DOCKER_ORG)/$$item"; \
done

$(DEFAULT_IMAGES):
docker build --label com.ddev.buildhost=${shell hostname} --target=$@ -t $(DOCKER_ORG)/$@:$(VERSION) $(DOCKER_ARGS) .

Expand Down
2 changes: 1 addition & 1 deletion containers/test-ssh-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM debian:bullseye-slim
FROM debian:bullseye-slim AS test-ssh-server

RUN apt-get -qq update
RUN DEBIAN_FRONTEND=noninteractive apt-get -qq install -y -o Dpkg::Options::="--force-confold" --no-install-recommends --no-install-suggests -y bash openssh-server vim
Expand Down
7 changes: 1 addition & 6 deletions containers/test-ssh-server/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# PKG := github.com/ddev/repo_name

VERSION := $(shell git describe --tags --always --dirty)
DEFAULT_IMAGES = test-ssh-server

# Tests always run against amd64 (build host). Once tests have passed, a multi-arch build
# will be generated and pushed (the amd64 build will be cached automatically to prevent it from building twice).
Expand All @@ -17,11 +18,5 @@ include ../containers_shared.mk
# Docker repo for a push
DOCKER_REPO ?= $(DOCKER_ORG)/test-ssh-server

# Additional targets can be added here
# Also, existing targets can be overridden by copying and customizing them.
multi-arch:
docker buildx build --platform $(BUILD_ARCHS) -t $(DOCKER_REPO):$(VERSION) $(DOCKER_ARGS) .; \
echo "created multi-arch builds $(BUILD_ARCHS) for $(DOCKER_REPO)";

test: container
true

0 comments on commit 788720e

Please sign in to comment.