Skip to content

HAMR-179 Build the docker image and push it to github's registry#274

Merged
michael-richey merged 16 commits intomainfrom
michael.richey/publish-docker-image
Sep 6, 2024
Merged

HAMR-179 Build the docker image and push it to github's registry#274
michael-richey merged 16 commits intomainfrom
michael.richey/publish-docker-image

Conversation

@michael-richey
Copy link
Copy Markdown
Collaborator

@michael-richey michael-richey commented Sep 5, 2024

What does this PR do?

Modify the release process to build a docker image that we can distribute.

Description of the Change

This change comes straight from the github documentation on how to build a docker image and publish it to github packages.

What could go wrong?

This bit is untested but comes from the documentation:

on:
  release:
    types: [published]

I was building on any push to my feature branch to test the building and publishing. Since this will create a latest version of the image, we want to make sure we only run it when we publish a release.

Verification

Starting state:

~$ docker image ls
REPOSITORY   TAG       IMAGE ID   CREATED   SIZE
~$

Verify image was created from this repository:

~$ gh attestation verify oci://ghcr.io/datadog/datadog-sync-cli --repo DataDog/datadog-sync-cli
Loaded digest sha256:edf626695aeb3aef98818eebaae0dfa8236bfe8cc6d77007a798f9188a3289dc for oci://ghcr.io/datadog/datadog-sync-cli
Loaded 1 attestation from GitHub API
✓ Verification succeeded!

sha256:edf626695aeb3aef98818eebaae0dfa8236bfe8cc6d77007a798f9188a3289dc was attested by:
REPO                      PREDICATE_TYPE                  WORKFLOW                                                                                 
DataDog/datadog-sync-cli  https://slsa.dev/provenance/v1  .github/workflows/build_publish_docker.yml@refs/heads/michael.richey/publish-docker-image
~$

Download the docker image:

~$ docker run --rm ghcr.io/datadog/datadog-sync-cli
Unable to find image 'ghcr.io/datadog/datadog-sync-cli:latest' locally
latest: Pulling from datadog/datadog-sync-cli
8b91b88d5577: Pull complete 
824416e23423: Pull complete 
482d64d97d4e: Pull complete 
c87b3089b2ed: Pull complete 
91bdacd599c6: Pull complete 
96dd7bc6fadb: Pull complete 
13d2db1b4640: Pull complete 
2656443a97f4: Pull complete 
03b4039beaa9: Pull complete 
Digest: sha256:edf626695aeb3aef98818eebaae0dfa8236bfe8cc6d77007a798f9188a3289dc
Status: Downloaded newer image for ghcr.io/datadog/datadog-sync-cli:latest
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
Usage: datadog-sync [OPTIONS] COMMAND [ARGS]...

  Initialize cli

Options:
  --help  Show this message and exit.

Commands:
  diffs   Log resource diffs.
  import  Import Datadog resources.
  sync    Sync Datadog resources to destination.
~$

Running the local docker image (after setting env vars)

~$ docker run --rm -v ~/dd/datadog-sync-cli:/datadog-sync:rw -e DD_SOURCE_API_KEY=${DATADOG_API_KEY} -e DD_SOURCE_APP_KEY=${DATADOG_APP_KEY} -e DD_SOURCE_API_URL=${DATADOG_API_URL} -e DD_DESTINATION_API_KEY=${DATADOG_API_KEY} -e DD_DESTINATION_APP_KEY=${DATADOG_APP_KEY} -e DD_DESTINATION_API_URL=${DATADOG_API_URL} ghcr.io/datadog/datadog-sync-cli import --resources="dashboards" --filter='Type=dashboards;Name=id;Value=redacted;Operator=ExactMatch'
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
2024-09-06 18:08:52,532 - INFO - clients validated successfully
2024-09-06 18:08:52,535 - INFO - Starting import...
2024-09-06 18:08:52,616 - INFO - Getting resources for dashboards
100%|██████████| 1/1 [00:00<00:00,  4.42it/s]
2024-09-06 18:08:52,842 - INFO - Finished getting resources. Successes: 1, Failures: 0, Skipped: 0, Filtered: 0
2024-09-06 18:08:52,842 - INFO - Importing individual resource items
100%|██████████| 1/1 [00:00<00:00, 76.47it/s] 
2024-09-06 18:08:52,857 - INFO - Finished importng individual resource items. Successes: 0, Failures: 0, Skipped: 0, Filtered: 1.
2024-09-06 18:08:52,859 - INFO - Finished import
~$ 

@michael-richey michael-richey changed the title HAMR-179 Build the docker image and push it HAMR-179 Build the docker image and push it to github's registry Sep 6, 2024
Copy link
Copy Markdown
Collaborator

@heyronhay heyronhay left a comment

Choose a reason for hiding this comment

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

Nice! Good verification :)

@michael-richey michael-richey merged commit fc9ba4c into main Sep 6, 2024
@michael-richey michael-richey deleted the michael.richey/publish-docker-image branch September 6, 2024 20:39
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