Skip to content

Commit

Permalink
feat: support for pulling docker image without service
Browse files Browse the repository at this point in the history
Fixes #49
  • Loading branch information
agaffney committed Mar 5, 2024
1 parent cc512bf commit 67ed19a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
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
}
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

0 comments on commit 67ed19a

Please sign in to comment.