CircleCI-Public / cimg-shared

Shared resources for prototype convenience images
MIT License
11 stars 14 forks source link

Add buildx variant tag support #84

Closed BytesGuy closed 1 year ago

BytesGuy commented 1 year ago

This PR adjusts how gen-dockerfiles works for buildx enabled repos. It will now push the main version tags from the buildx command directly (as build and push cannot be split easily in buildx) and use the push-images.sh file to push the variant tags.

Example build-images.sh

#!/usr/bin/env bash
# Do not edit by hand; please use build scripts/templates to make changes
docker context create cimg
docker buildx create --use cimg
docker buildx build --platform=linux/amd64,linux/arm64 --file 20.4/Dockerfile -t cimg/node:20.4.0 -t cimg/node:20.4 --push .
docker buildx build --platform=linux/amd64 --file 20.4/browsers/Dockerfile -t cimg/node:20.4.0-browsers -t cimg/node:20.4-browsers --push .
docker buildx build --platform=linux/amd64,linux/arm64 --file 18.16/Dockerfile -t cimg/node:18.16.1 -t cimg/node:18.16 --push .
docker buildx build --platform=linux/amd64 --file 18.16/browsers/Dockerfile -t cimg/node:18.16.1-browsers -t cimg/node:18.16-browsers --push .

Example push-images.sh

#!/usr/bin/env bash
# Do not edit by hand; please use build scripts/templates to make changes
docker buildx imagetools create -t cimg/node:current cimg/node:20.4.0
docker buildx imagetools create -t cimg/node:current-browsers cimg/node:20.4.0-browsers
docker buildx imagetools create -t cimg/node:lts cimg/node:18.16.1
docker buildx imagetools create -t cimg/node:lts-browsers cimg/node:18.16.1-browsers

This could be better consolidated into a single file in the future (or add variant tags to the buildx commands), but for now, while we support both traditional builds and buildx, this seems like the best solution.