Skip to content

Commit

Permalink
Fix IRB container package
Browse files Browse the repository at this point in the history
- implement docker API changes

Signed-off-by: Marcus Brandenburger <bur@zurich.ibm.com>
  • Loading branch information
mbrandenburger committed Sep 5, 2024
1 parent 33fd56f commit 015d700
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion samples/demos/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ include $(TOP)/build.mk

DEMOS = irb

build clean:
build test clean:
$(foreach DIR, $(DEMOS), $(MAKE) -C $(DIR) $@ || exit;)

4 changes: 2 additions & 2 deletions samples/demos/irb/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ include $(TOP)/build.mk

COMPONENTS = protos chaincode experimenter

all: pull-images ercc build test
all: ercc build test

pull-images:
$(DOCKER) pull redis:latest
Expand All @@ -23,7 +23,7 @@ ercc:
build: ercc
$(foreach DIR, $(COMPONENTS), $(MAKE) -C $(DIR) $@ || exit;)

test:
test: pull-images
$(GO) test -v ./...

run:
Expand Down
16 changes: 7 additions & 9 deletions samples/demos/irb/pkg/container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"context"
"fmt"

"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/client"
"github.com/docker/go-connections/nat"
Expand Down Expand Up @@ -40,12 +39,10 @@ func (c *Container) Start() error {
Image: c.Image,
Cmd: c.CMD,
Env: c.Env,
},
&container.HostConfig{
PortBindings: nat.PortMap{
nat.Port(fmt.Sprintf("%s/tcp", c.HostPort)): []nat.PortBinding{{HostIP: c.HostIP, HostPort: c.HostPort}},
ExposedPorts: nat.PortSet{
nat.Port(c.HostPort + "/tcp"): struct{}{},
},
}, nil, nil, c.Name)
}, nil, nil, nil, c.Name)
if err != nil {
return err
}
Expand All @@ -54,12 +51,12 @@ func (c *Container) Start() error {
return err
}

if err := cli.ContainerStart(ctx, resp.ID, types.ContainerStartOptions{}); err != nil {
if err := cli.ContainerStart(ctx, resp.ID, container.StartOptions{}); err != nil {
return err
}

go func() {
reader, err := cli.ContainerLogs(context.Background(), resp.ID, types.ContainerLogsOptions{
reader, err := cli.ContainerLogs(context.Background(), resp.ID, container.LogsOptions{
ShowStdout: true,
ShowStderr: true,
Follow: true,
Expand Down Expand Up @@ -93,11 +90,12 @@ func (c *Container) Stop() error {
return err
}

// default timeout is 10s
if err := cli.ContainerStop(ctx, c.containerID, container.StopOptions{}); err != nil {
return err
}

if err := cli.ContainerRemove(ctx, c.containerID, types.ContainerRemoveOptions{}); err != nil {
if err := cli.ContainerRemove(ctx, c.containerID, container.RemoveOptions{}); err != nil {
return err
}

Expand Down

0 comments on commit 015d700

Please sign in to comment.