Skip to content

Conversation

liangyuanpeng
Copy link

  • add builder image ARG to Dockerfile

What this PR does / why we need it:

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #1710

Please check the following list:

  • Does the affected code have corresponding tests, e.g. unit test, E2E test?
  • Does this change require a documentation update?
  • Does this introduce breaking changes that would require an announcement or bumping the major version?
  • Do all new files have an appropriate license header?

Makefile Outdated
OSNAME = $(shell uname -o)
ARCHNAME = $(shell uname -m)
GO_VERSION = $(shell awk '/^go /{print $$2}' go.mod|head -n1)
BUILDER_IMAGE = golang:$(GO_VERSION)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid the builder image being updated automatically, obtain the go version from go.mod

@liangyuanpeng liangyuanpeng force-pushed the dockerfile_update branch 3 times, most recently from e4cdadc to 373c79b Compare April 29, 2025 13:20
Copy link

codecov bot commented Apr 29, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.69%. Comparing base (e8bca4d) to head (d038c4e).
⚠️ Report is 47 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1716      +/-   ##
==========================================
- Coverage   84.73%   84.69%   -0.04%     
==========================================
  Files         127      127              
  Lines        5718     5718              
==========================================
- Hits         4845     4843       -2     
- Misses        620      622       +2     
  Partials      253      253              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@TerryHowe TerryHowe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

with:
go-version-file: go.mod
- name: Build image
run: make image-build
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A CI build container image has been added, which will increase the CI time, but I think it can enhance the confidence in building the container image.

Comment on lines +216 to +218
.PHONY: image-push
image-push: PUSH=--push
image-push: image-build
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In future work, we can use this to replace this step in the workflow.

docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7,linux/s390x,linux/ppc64le -t ${{ steps.prepare.outputs.ref }} --push .

PLATFORMS ?= linux/amd64,linux/arm64
DOCKER_BUILDX_CMD ?= docker buildx
IMAGE_BUILD_CMD ?= $(DOCKER_BUILDX_CMD) build
IMAGE_GIT_TAG ?= $(shell git describe --tags --dirty --always)
Copy link
Author

@liangyuanpeng liangyuanpeng Apr 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no too much history, in here

oras/Makefile

Line 18 in e8bca4d

GIT_TAG = $(shell git describe --tags --abbrev=0 --exact-match 2>/dev/null)
It is not suitable for use every time a image is built, so I make a new one

Comment on lines +192 to +227
IMAGE_REGISTRY ?= ghcr.io/oras-project
IMAGE_NAME := oras
IMAGE_REPO ?= $(IMAGE_REGISTRY)/$(IMAGE_NAME)
IMAGE_TAG ?= $(IMAGE_REPO):$(IMAGE_GIT_TAG)

ifdef EXTRA_TAG
IMAGE_EXTRA_TAG ?= $(IMAGE_REPO):$(EXTRA_TAG)
endif
ifdef IMAGE_EXTRA_TAG
IMAGE_BUILD_EXTRA_OPTS += -t $(IMAGE_EXTRA_TAG)
endif

# Build the multiplatform container image locally and push to repo.
.PHONY: image-local-push
image-local-push: PUSH=--push
image-local-push: image-local-build

# Build the multiplatform container image locally.
.PHONY: image-local-build
image-local-build:
BUILDER=$(shell $(DOCKER_BUILDX_CMD) create --use)
$(MAKE) image-build PUSH=$(PUSH)
$(DOCKER_BUILDX_CMD) rm $$BUILDER

.PHONY: image-push
image-push: PUSH=--push
image-push: image-build

image-build:
$(IMAGE_BUILD_CMD) -t $(IMAGE_TAG) \
--platform=$(PLATFORMS) \
--build-arg BASE_IMAGE=$(BASE_IMAGE) \
--build-arg BUILDER_IMAGE=$(BUILDER_IMAGE) \
--build-arg CGO_ENABLED=$(CGO_ENABLED) \
$(PUSH) \
$(IMAGE_BUILD_EXTRA_OPTS) ./
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

* add dependabot for auto update base image

Signed-off-by: Lan <[email protected]>
@qweeah
Copy link
Contributor

qweeah commented Apr 30, 2025

Thanks @liangyuanpeng for contributing. Can you help look into the CI failure?

@polarathene
Copy link

If this is just for CI purposes, wouldn't it be better to skip the Makefile addition and just leverage GH actions?

FWIW, Go projects often adopt GoReleaser to automate builds, some also use the Docker build support from GoReleaser, but I'd say the GH workflow is simpler to maintain.

Copy link

This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the stale Inactive issues or pull requests label Jul 27, 2025
@FeynmanZhou FeynmanZhou removed the stale Inactive issues or pull requests label Aug 9, 2025
Co-authored-by: Billy Zha <[email protected]>
Signed-off-by: Terry Howe <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Configure dependabot to update Dockerfile
5 participants