Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Builder should use latest alpine version of go release(s) using dockerhubapi. #236

Open
vimystic opened this issue Apr 2, 2024 · 1 comment

Comments

@vimystic
Copy link
Contributor

vimystic commented Apr 2, 2024

Update heighliner logic to get latest apline version for any given version of go that the chain(s) are using.
Locations of interest : builder.go & go_versions.go files
If the latest alpine is not retrievable using this , then use the alpine version provided by the buildconfig of the chain.

Example in python.

import requests

def get_latest_alpine_tag(go_version):
    # Docker Hub API endpoint for the Go repository
    url = "https://hub.docker.com/v2/repositories/library/golang/tags/"

    # Initialize variables for pagination
    page = 1
    tags = []

    while True:
        # Make the API request with pagination parameters
        params = {"page": page, "page_size": 100}
        response = requests.get(url, params=params)

        # Check if the request was successful
        if response.status_code == 200:
            # Parse the JSON response
            data = response.json()

            # Extract the tags from the current page
            page_tags = [tag["name"] for tag in data["results"]]

            # Filter the tags that match the desired Go version
            filtered_tags = [tag for tag in page_tags if tag.startswith(go_version)]

            # Add the filtered tags to the list of all tags
            tags.extend(filtered_tags)

            # Check if there are more pages
            if data["next"] is None:
                break

            # Increment the page number for the next request
            page += 1
        else:
            print("Failed to retrieve tags from Docker Hub.")
            return None

    # Filter the tags to find the ones with the Alpine version
    alpine_tags = [tag for tag in tags if "alpine" in tag]

    # Sort the Alpine versions to determine the latest one
    latest_alpine_tag = max(alpine_tags, key=lambda x: x.split("-")[1]) if alpine_tags else None

    return latest_alpine_tag

# Example usage
go_version = "1.17"
latest_tag = get_latest_alpine_tag(go_version)
if latest_tag:
    print(f"Latest Alpine tag for Go {go_version}: {latest_tag}")
else:
    print("No Alpine tag found for the specified Go version.")

@jonathanpberger jonathanpberger changed the title Update builder to use the latest alpine version of go release(s) using dockerhubapi. Builder should use latest alpine version of go release(s) using dockerhubapi. Apr 10, 2024
@jonathanpberger jonathanpberger changed the title Builder should use latest alpine version of go release(s) using dockerhubapi. Builder should use latest alpine version of go release(s) using dockerhubapi. Apr 10, 2024
@fmorency
Copy link

fmorency commented Jun 5, 2024

I think I just got bitten by this

Go version from go.mod: 1.22.4, will build with version: 1.22.4 image: 1.22.4-alpine3.18
Building image from current working directory source, resulting docker image tags: +[manifest:local]
Step 1/51 : ARG BASE_VERSION
Step 2/51 : FROM golang:${BASE_VERSION} AS init-env
error building docker image for manifest from ref:  - manifest for golang:1.22.4-alpine3.18 not found: manifest unknown: manifest unknown

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

No branches or pull requests

2 participants