Skip to content

Commit

Permalink
Remove .NET related files and add DockerContainer.go
Browse files Browse the repository at this point in the history
  • Loading branch information
PiotrFerenc committed Apr 18, 2024
1 parent e0c3035 commit 36a005c
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 106 deletions.
25 changes: 0 additions & 25 deletions docker-action/dotnet/.dockerignore

This file was deleted.

16 changes: 0 additions & 16 deletions docker-action/dotnet/DockerActions.sln

This file was deleted.

22 changes: 0 additions & 22 deletions docker-action/dotnet/DockerNewSolution/DockerNewSolution.csproj

This file was deleted.

20 changes: 0 additions & 20 deletions docker-action/dotnet/DockerNewSolution/Dockerfile

This file was deleted.

23 changes: 0 additions & 23 deletions docker-action/dotnet/DockerNewSolution/Program.cs

This file was deleted.

29 changes: 29 additions & 0 deletions internal/Container/DockerContainer.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package Container

import (
"context"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/client"
)

func StartContainer(imageName string, env, vol []string, ctx context.Context) (string, error) {
cli, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
if err != nil {
return "", err
}

resp, err := cli.ContainerCreate(ctx, &container.Config{
Image: imageName,
Env: env,
}, &container.HostConfig{
Binds: vol,
}, nil, nil, "")
if err != nil {
return "", err
}

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

0 comments on commit 36a005c

Please sign in to comment.