Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

feat(plugins/docker): add docker-ref plugin #3912

Merged
merged 4 commits into from
Sep 30, 2022

Conversation

denysvitali
Copy link
Contributor

The docker-pull plugin really pulls the image in the case of On Demand Runners. Since we do require there a docker.AccessInfo, we can't avoid pulling the image (because HasRegistry automatically becomes true, and not providing a registry causes an error).

To avoid patching docker-pull further, a docker-ref is created. This is only used in the very specific case where a docker-pull can't be used because all of the following conditions are met:

  • Access to the registry is not available
  • On-Demand Runner (ODR) is being used

As a solution, this plugin allows you to be a sort of "noop" that adds a reference to a pre-built
Docker image (e.g: in an external CI) in the build stage.


Example usage:

app "whoami" {
  build {
    use "docker-ref" {
      image = "traefik/whoami"
      tag   = "latest"
    }
  }

  deploy {
    use "kubernetes" {
      // ...
    }
  }
}

The `docker-pull` plugin really pulls the image in the case of On Demand Runners.
Since we do require there a `docker.AccessInfo`, we can't avoid pulling the image
(because HasRegistry automatically becomes true, and not providing a registry causes an error).

To avoid patching `docker-pull` further, a `docker-ref` is created.
This is only used in the very specific case where a `docker-pull` can't be used because all of the following
conditions are met:

- Access to the registry is not available
- On-Demand Runner (ODR) is being used

As a solution, this plugin allows you to be a sort of "noop" that adds a reference to a pre-built
Docker image (e.g: in an external CI) in the `build` stage.
@paladin-devops paladin-devops added the ecosystem Things related to waypoint interacting with external systems label Sep 29, 2022
Copy link
Contributor

@paladin-devops paladin-devops left a comment

Choose a reason for hiding this comment

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

This is looking awesome! The website docs should definitely include the documentation for this plugin as well. 😄

I just tried this out locally with Docker and it worked great! Giving it a shot with ODRs next.

@paladin-devops
Copy link
Contributor

This plugin also works with ODRs! 🎉

$ waypoint build                 

» Building docker-ref-nodejs...
  Performing operation on "docker" with runner profile "docker-01GDHSV8JJ6X6GS4XBGHQ6YG7V"

» Cloning data from Git
  URL: https://github.com/hashicorp/waypoint-examples
  Ref: nomad-remote-ops

» Downloading from Git
  Git Commit: 28f79b1f31ff630a10187295431adfca07be0b33
   Timestamp: 2022-09-29 22:12:49 +0000 UTC
     Message: Add example for docker-ref plugin.
  
✓ Running build v1
✓ Using Docker image in remote registry: hashicorp/waypoint:latest
✓ Running push build v1

Created artifact v1

» Variables used:
  VARIABLE | VALUE | TYPE | SOURCE  
-----------+-------+------+---------

$ waypoint artifact list-builds

» docker-ref-nodejs
    | ID | WORKSPACE |  BUILDER   |    STARTED     |   COMPLETED    | PIPELINE  
----+----+-----------+------------+----------------+----------------+-----------
  ✔ |  1 | default   | docker-ref | 54 seconds ago | 54 seconds ago |           

$ waypoint artifact list       

» docker-ref-nodejs
    | ID |  REGISTRY  | DETAILS |    STARTED     |   COMPLETED     
----+----+------------+---------+----------------+-----------------
  ✔ |  1 | docker-ref | build:1 | 57 seconds ago | 57 seconds ago  

Copy link
Contributor

@paladin-devops paladin-devops left a comment

Choose a reason for hiding this comment

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

@denysvitali I think the last thing we need to do here is get the documentation generated! As mentioned elsewhere, make gen/website-mdx will take care of this for you. I should also add that since this is a new plugin, you won't see the files in the diff, and you'll need to git add each of the .mdx files generated in website/content/partials/components for docker-ref.

Once they're added to the repo, the other required change to get the documentation to appear on the website is in website/content/plugins/docker.mdx. There, you should add @include "components/builder-docker-ref.mdx", so the content will be displayed for the builder plugin!

https://github.com/swisscom/waypoint/blob/3b2731519929713eb52a632aa856b9d52647d4ed/website/content/plugins/docker.mdx?plain=1#L12-L20

Copy link
Contributor

@paladin-devops paladin-devops left a comment

Choose a reason for hiding this comment

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

@denysvitali thanks for adding the docs, this is a great plugin! 😄 🐋 💰

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport/0.10.x core ecosystem Things related to waypoint interacting with external systems plugin/docker plugin website
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants