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

feat(sage-monorepo): tag the images of a product with semver (ARCH-304) #2871

Merged

Conversation

tschaffter
Copy link
Member

@tschaffter tschaffter commented Oct 3, 2024

Contributes to https://sagebionetworks.jira.com/browse/ARCH-304

Changelog

  • Introduce configurations to the task openchallenges-apex:build-image
  • Add GH workflow to run openchallenges-apex:build-image and tag the image with semver when a tag is pushed
  • Update @nx-tools/* packages

Future PRs

  • Update the GH workflow to build and tag all the OC images
  • Update the GH workflow to build and tag all the images of all the products

References

@tschaffter
Copy link
Member Author

tschaffter commented Oct 3, 2024

Option 1: Specifying the version using environment variable

Task:

    "build-image": {
      "executor": "@nx-tools/nx-container:build",
      "options": {
        "context": "apps/openchallenges/apex",
        "metadata": {
          "images": ["ghcr.io/sage-bionetworks/openchallenges-apex"],
          "tags": [
            "type=edge,branch=main",
            "type=raw,value=local",
            "type=raw,value=$OPENCHALLENGES_VERSION",
            "type=sha"
          ]
        },
        "push": false
      }
    },

Output:

$ export OPENCHALLENGES_VERSION=1.0.0
$ nx build-image openchallenges-apex
$ docker images
REPOSITORY                                     TAG           IMAGE ID       CREATED         SIZE
ghcr.io/sage-bionetworks/openchallenges-apex   1.0.0         b38a869afd48   3 seconds ago   42.7MB
ghcr.io/sage-bionetworks/openchallenges-apex   local         b38a869afd48   3 seconds ago   42.7MB
ghcr.io/sage-bionetworks/openchallenges-apex   sha-0ff75a9   b38a869afd48   3 seconds ago   42.7MB

Warning

The task build-image will fail is the environment variable is not specified.

Option 2: Specifying the version as a CLI options

I tried the command below but I always get this array error. I can confirm that the key is correct "--metadata.tags" but I can't find a value that will be evaluated as an array.

$ nx build-image openchallenges-apex --metadata.tags="type=raw,value=1.0.0"

> nx run openchallenges-apex:build-image --metadata.tags=type=raw,value=1.0.0


 NX   Property 'tags' does not match the schema. 'type=raw,value=1.0.0' should be a 'array'.

Option 3: Specifying the version as an inline environment variable

Similar to Option 2 but passing the value as an inline - or even global - environment variable. This approach failed too.

INPUT_METADATA_TAGS="type=raw,value=1.0.0" nx build-image openchallenges-apex

Output:

$ docker images
REPOSITORY                                     TAG           IMAGE ID       CREATED         SIZE
ghcr.io/sage-bionetworks/openchallenges-apex   local         803a07876a25   3 seconds ago   42.7MB
ghcr.io/sage-bionetworks/openchallenges-apex   sha-fa8714c   803a07876a25   3 seconds ago   42.7MB

Option 4: Specifying a task configuration when the environment variable is expected to exist (in CI workflow)

This PR implements this approach. See the files changed.

@tschaffter tschaffter self-assigned this Oct 3, 2024
@tschaffter tschaffter marked this pull request as ready for review October 3, 2024 20:56
@tschaffter tschaffter changed the title feat(sage-monorepo): tag the images of a product with semver feat(sage-monorepo): tag the images of a product with semver (ARCH-293) Oct 3, 2024
@tschaffter tschaffter changed the title feat(sage-monorepo): tag the images of a product with semver (ARCH-293) feat(sage-monorepo): tag the images of a product with semver (ARCH-304) Oct 3, 2024
@tschaffter tschaffter merged commit d1854b3 into Sage-Bionetworks:main Oct 3, 2024
7 of 8 checks passed
@tschaffter tschaffter deleted the sage-monorepo/tag-images branch October 3, 2024 21:42
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.

1 participant