Skip to content

bug(build): Image config is not configured correctly #645

@gaocegege

Description

@gaocegege

Description

The func imageConfig relies on ir package to get the entrypoints/labels. But in our new design of gateway build func, the ir.DefaultImage is not initialized because we run the starlark interpretation in BuildFunc. Thus we cannot get the right config.

We should move the logic into BuildFunc with gateway client's ResolveImageConfig

func (b generalBuilder) build(ctx context.Context, pw progresswriter.Writer) error {
	imageConfig, err := b.imageConfig(ctx)
	if err != nil {
		return errors.Wrap(err, "failed to get labels")
	}
	// k := platforms.Format(platforms.DefaultSpec())
	ctx, cancel := context.WithCancel(ctx)
	defer cancel()
	eg, ctx := errgroup.WithContext(ctx)
...

func (b generalBuilder) imageConfig(ctx context.Context) (string, error) {
	labels, err := ir.Labels()
	if err != nil {
		return "", errors.Wrap(err, "failed to get labels")
	}
	ports, err := ir.ExposedPorts()
	if err != nil {
		return "", errors.Wrap(err, "failed to get expose ports")
	}
	labels[types.ImageLabelContext] = b.BuildContextDir

	ep, err := ir.Entrypoint(b.BuildContextDir)
	if err != nil {
		return "", errors.Wrap(err, "failed to get entrypoint")
	}
	data, err := ImageConfigStr(labels, ports, ep)
	if err != nil {
		return "", errors.Wrap(err, "failed to get image config")
	}
	return data, nil
}

Reproduction

Additional Info


Message from the maintainers:

Impacted by this bug? Give it a 👍. We prioritise the issues with the most 👍.

Metadata

Metadata

Assignees

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions