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: support for pulling docker image without service #83

Merged
merged 1 commit into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions pkgmgr/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ type PackageInstallStepDocker struct {
Args []string `yaml:"args,omitempty"`
Binds []string `yaml:"binds,omitempty"`
Ports []string `yaml:"ports,omitempty"`
PullOnly bool `yaml:"pullOnly"`
}

func (p *PackageInstallStepDocker) preflight(cfg Config, pkgName string) error {
Expand Down Expand Up @@ -289,16 +290,26 @@ func (p *PackageInstallStepDocker) install(cfg Config, pkgName string) error {
Binds: tmpBinds,
Ports: tmpPorts,
}
if err := svc.Create(); err != nil {
return err
}
if err := svc.Start(); err != nil {
return err
if p.PullOnly {
if err := svc.pullImage(); err != nil {
return err
}
} else {
if err := svc.Create(); err != nil {
return err
}
if err := svc.Start(); err != nil {
return err
}
}
return nil
}

func (p *PackageInstallStepDocker) uninstall(cfg Config, pkgName string) error {
// Nothing to uninstall if we were only fetching the image
if p.PullOnly {
return nil
Copy link
Member

Choose a reason for hiding this comment

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

Why not remove the image?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could also do that

}
containerName := fmt.Sprintf("%s-%s", pkgName, p.ContainerName)
svc, err := NewDockerServiceFromContainerName(containerName, cfg.Logger)
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions pkgmgr/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ docker exec -ti {{ .Package.Name }}-cardano-node cardano-cli $@
Docker: &PackageInstallStepDocker{
ContainerName: "mithril-client",
Image: "ghcr.io/blinklabs-io/mithril-client:0.5.17-1",
PullOnly: true,
},
},
{
Expand All @@ -79,6 +80,7 @@ docker run --rm -ti ghcr.io/blinklabs-io/mithril-client:0.5.17 $@
Docker: &PackageInstallStepDocker{
ContainerName: "mithril-client",
Image: "ghcr.io/blinklabs-io/mithril-client:0.7.0-1",
PullOnly: true,
},
},
{
Expand Down