Skip to content

Conversation

@straight-shoota
Copy link
Member

@straight-shoota straight-shoota commented Dec 1, 2025

As discussed in #389, exporting the docker images to disk and reimporting them in the next job is very expensive. It should be more efficient to push them directly from the builder job to the registry.

Successful workflow run: https://app.circleci.com/pipelines/github/crystal-lang/crystal/20041/workflows/bcae698e-c557-456d-ad93-b23cf4348786

@ysbaddaden
Copy link
Contributor

ysbaddaden commented Dec 2, 2025

The Makefile is becoming undecipherable. Wouldn't a stupid, POSIX compliant, Makefile with a few blunt targets and copy-pasted commands be much more readable and maintainable? We don't have many targets that we need any abstraction. Let's forget small steps, be blunt, and be done with it 📦

$ cd docker/
$ make VERSION=$(CRYSTAL_VERSION) TARBALLS=/tmp/workspace/build
.POSIX:
.PHONY:

TARBALLS = ./tarballs
BUILD_CONTEXT = ./build
PLATFORMS = linux/amd64,linux/arm64

VERSION = latest
TAG = crystal-lang/crystal:$(VERSION)

all: images smoke-test push

setup: .PHONY
  mkdir -p $(BUILD_CONTEXT)
  cp $(TARBALLS)/crystal-$(VERSION)-1-linux-x86_64.tar.gz $(BUILD_CONTEXT)/crystal-amd64.tar.gz
  cp $(TARBALLS)/crystal-$(VERSION)-1-linux-aarch64.tar.gz $(BUILD_CONTEXT)/crystal-arm64.tar.gz

images: alpine ubuntu 84codes

alpine: setup
  docker buildx build alpine.Dockerfile -t $(TAG)-alpine --target runtime --platform $(PLATFORMS) $(BUILD_CONTEXT)
  docker buildx build alpine.Dockerfile -t $(TAG)-alpine-build --target build --platform $(PLATFORMS) $(BUILD_CONTEXT)

ubuntu: setup
  docker buildx build ubuntu.Dockerfile -t $(TAG)-ubuntu --target runtime --platform $(PLATFORMS) $(BUILD_CONTEXT)
  docker buildx build ubuntu.Dockerfile -t $(TAG)-ubuntu-build --target build --platform $(PLATFORMS) $(BUILD_CONTEXT)

84codes: .PHONY
  docker buildx build --build-arg crystal_version=$(VERSION) -f alpine-84codes.Dockerfile --platform $(PLATFORMS) -t $(TAG)-alpine-84codes-build .
  docker buildx build --build-arg crystal_version=$(VERSION) -f ubuntu-84codes.Dockerfile --platform $(PLATFORMS) -t $(TAG)-ubuntu-84codes-build .

smoke-test: .PHONY
  docker run --rm -v $(PWD)/smoke.sh:/smoke.sh -e CRYSTAL_VERSION=$(VERSION) $(TAG)-alpine /smoke.sh $*
  docker run --rm -v $(PWD)/smoke.sh:/smoke.sh -e CRYSTAL_VERSION=$(VERSION) $(TAG)-ubuntu /smoke.sh $*

push: .PHONY
  docker push $(TAG)-alpine $(TAG)-alpine-build $(TAG)-alpine-84-codes-build
  docker push $(TAG)-ubuntu $(TAG)-ubuntu-build $(TAG)-ubuntu-84-codes-build

clean: .PHONY
  rm -rf $(BUILD_CONTEXT)

@straight-shoota
Copy link
Member Author

I suppose we could expand the recipes to be less cryptic.
However, I do prefer individual recipes for each image with explicit prerequisites. When I need to build a specific image, I'd like to be able to do just that without having to build all image variants and provide all tarballs.

straight-shoota and others added 3 commits December 8, 2025 10:43
Co-authored-by: Julien Portalier <julien@portalier.com>
@straight-shoota straight-shoota merged commit d1d8657 into master Dec 8, 2025
@straight-shoota straight-shoota deleted the feat/push-docker-images branch December 8, 2025 23:07
straight-shoota added a commit to crystal-lang/crystal that referenced this pull request Dec 8, 2025
Updates `distribution-scripts` dependency to crystal-lang/distribution-scripts@d1d8657

This includes the following changes:

* crystal-lang/distribution-scripts#395
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants