Last active
February 3, 2023 01:32
-
-
Save gmlewis/536345ad27c6986e41ae8ff7f5c0f7ff to your computer and use it in GitHub Desktop.
Work in progress - pushing image to Azure Container Registry using Dagger.io
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package common | |
import ( | |
"context" | |
"log" | |
"dagger.io/dagger" | |
) | |
// PublishToAzure performs a Dockerfile build on the provided repo and pushes to the | |
// Azure Container Registry. | |
func (c *Client) PublishToAzure(ctx context.Context, prodDir *dagger.Directory, azureAddress string, buildOpts ...dagger.ContainerBuildOpts) error { | |
dockerfile := "Dockerfile" | |
for _, opt := range buildOpts { | |
dockerfile = opt.Dockerfile // Possible Dockerfile override | |
} | |
log.Printf("PublishToAzure using %q: %v", dockerfile, azureAddress) | |
prodImage := c.Client.Container().Build(prodDir, buildOpts...) | |
out, err := prodImage.Stdout(ctx) | |
if err != nil { | |
return err | |
} | |
log.Printf("Build %q: %v", dockerfile, out) | |
ref, err := prodImage.Publish(ctx, azureAddress) | |
if err != nil { | |
return err | |
} | |
log.Printf("Successfully published %q image to %v - ref: %v", dockerfile, azureAddress, ref) | |
return nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment