chore: fix build dependencies and frontend config
Migrate Docker SDK from github.com/docker/docker (+incompatible) to github.com/moby/moby/client v0.3.0 + moby/moby/api v1.54.0 (proper Go modules). Adapt all container/image/network operations to the new moby API (Filters, ContainerListOptions, PullResponse, InspectResult, etc.). Add AsyncTriggerDeploy runDeploy method. Fix SvelteKit build: disable prerender, set strict=false for SPA, bump vite-plugin-svelte to v5 for vite 6 compat. Add .dockerignore to exclude .git, node_modules, plans.
This commit is contained in:
@@ -4,18 +4,17 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/docker/docker/api/types/filters"
|
||||
"github.com/docker/docker/api/types/network"
|
||||
"github.com/moby/moby/api/types/network"
|
||||
"github.com/moby/moby/client"
|
||||
)
|
||||
|
||||
// EnsureNetwork creates a Docker network with the given name if it does not
|
||||
// already exist. It returns the network ID in all cases.
|
||||
func (c *Client) EnsureNetwork(ctx context.Context, networkName string) (string, error) {
|
||||
// Check if the network already exists.
|
||||
filterArgs := filters.NewArgs()
|
||||
filterArgs.Add("name", networkName)
|
||||
filterArgs := make(client.Filters).Add("name", networkName)
|
||||
|
||||
networks, err := c.api.NetworkList(ctx, network.ListOptions{
|
||||
listResult, err := c.api.NetworkList(ctx, client.NetworkListOptions{
|
||||
Filters: filterArgs,
|
||||
})
|
||||
if err != nil {
|
||||
@@ -23,14 +22,14 @@ func (c *Client) EnsureNetwork(ctx context.Context, networkName string) (string,
|
||||
}
|
||||
|
||||
// NetworkList with a name filter may return partial matches, so check exact name.
|
||||
for _, n := range networks {
|
||||
for _, n := range listResult.Items {
|
||||
if n.Name == networkName {
|
||||
return n.ID, nil
|
||||
}
|
||||
}
|
||||
|
||||
// Create the network.
|
||||
resp, err := c.api.NetworkCreate(ctx, networkName, network.CreateOptions{
|
||||
resp, err := c.api.NetworkCreate(ctx, networkName, client.NetworkCreateOptions{
|
||||
Driver: "bridge",
|
||||
Labels: map[string]string{
|
||||
LabelProject: "docker-watcher",
|
||||
@@ -45,7 +44,10 @@ func (c *Client) EnsureNetwork(ctx context.Context, networkName string) (string,
|
||||
|
||||
// ConnectNetwork attaches a container to an existing network.
|
||||
func (c *Client) ConnectNetwork(ctx context.Context, networkID string, containerID string) error {
|
||||
err := c.api.NetworkConnect(ctx, networkID, containerID, &network.EndpointSettings{})
|
||||
_, err := c.api.NetworkConnect(ctx, networkID, client.NetworkConnectOptions{
|
||||
Container: containerID,
|
||||
EndpointConfig: &network.EndpointSettings{},
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("connect container %s to network %s: %w", containerID, networkID, err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user