docker

package
v0.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 5, 2025 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package docker contains the internal functions used by the docker cmd to manage environments

Index

Constants

This section is empty.

Variables

View Source
var CleanCmd = &cobra.Command{
	Use:               "clean [env-name]",
	Short:             "Clean the data of an environment.",
	Long:              "Clean the data of an environment without redeploying. After clean all custom data populated in the environment will be lost. This action is not reversible.",
	Args:              cobra.ExactArgs(1),
	ValidArgsFunction: validArgsFunction,
	Run: func(cmd *cobra.Command, args []string) {
		name := args[0]

		if !cleanForce {
			display.Warn("This will permanently delete all data in environment '%s'. This action cannot be undone.", name)
			confirmed, err := common.Confirm("Are you sure you want to continue? (y/n):")
			if err != nil {
				display.Error("Failed to read confirmation: %v", err)
				os.Exit(1)
			}
			if !confirmed {
				display.Info("Clean operation cancelled.")
				return
			}
		}

		docker, err := dockercore.Clean(dockercore.CleanOpts{
			Name: name,
		})
		if err != nil {
			display.Error("%v", err)
			os.Exit(1)
		}

		display.Urls(docker.GuiUrl, docker.ApiUrl, docker.BackofficeUrl, fmt.Sprintf("epos-opensource docker clean %s", name))
	},
}
View Source
var DeleteCmd = &cobra.Command{
	Use:               "delete [env-name...]",
	Short:             "Stop and remove Docker Compose environments.",
	Long:              "Deletes Docker Compose environments with the given names. This action is irreversible.",
	Args:              cobra.MinimumNArgs(1),
	ValidArgsFunction: validArgsFunction,
	Run: func(cmd *cobra.Command, args []string) {
		name := args[0:]

		if !deleteForce {
			envList := strings.Join(name, ", ")
			display.Warn("This will permanently delete the following environment(s): %s", envList)
			display.Warn("All containers, volumes, and associated resources will be removed. This action cannot be undone.")
			confirmed, err := common.Confirm("Are you sure you want to continue? (y/n):")
			if err != nil {
				display.Error("Failed to read confirmation: %v", err)
				os.Exit(1)
			}
			if !confirmed {
				display.Info("Delete operation cancelled.")
				return
			}
		}

		err := dockercore.Delete(dockercore.DeleteOpts{
			Name: name,
		})
		if err != nil {
			display.Error("%v", err)
			os.Exit(1)
		}
	},
}
View Source
var DeployCmd = &cobra.Command{
	Use:   "deploy [env-name]",
	Short: "Create a new environment using Docker Compose.",
	Long:  "Deploy a new Docker Compose environment with the specified name.",
	Args:  cobra.ExactArgs(1),
	Run: func(cmd *cobra.Command, args []string) {
		name := args[0]

		docker, err := dockercore.Deploy(dockercore.DeployOpts{
			EnvFile:     envFile,
			ComposeFile: composeFile,
			Path:        path,
			Name:        name,
			PullImages:  pullImages,
			CustomHost:  host,
		})
		if err != nil {
			display.Error("%v", err)
			os.Exit(1)
		}

		display.Urls(docker.GuiUrl, docker.ApiUrl, docker.BackofficeUrl, fmt.Sprintf("epos-opensource docker deploy %s", name))
	},
}
View Source
var ExportCmd = &cobra.Command{
	Use:   "export [path]",
	Short: "Export the default environment files to a directory.",
	Long:  "Export the default environment files: .env and docker-compose.yaml.",
	Args:  cobra.ExactArgs(1),
	Run: func(cmd *cobra.Command, args []string) {
		path := args[0]
		err := dockercore.Export(dockercore.ExportOpts{
			Path: path,
		})
		if err != nil {
			display.Error("%v", err)
			os.Exit(1)
		}
	},
}
View Source
var ListCmd = &cobra.Command{
	Use:   "list",
	Short: "List installed Docker environments.",
	Run: func(cmd *cobra.Command, args []string) {
		dockerEnvs, err := db.GetAllDocker()
		if err != nil {
			return
		}

		display.DockerList(dockerEnvs, "Installed Docker environments")
	},
}
View Source
var PopulateCmd = &cobra.Command{
	Use:   "populate [env-name] [ttl-paths...]",
	Short: "Ingest TTL files or example data into an environment.",
	Long: `Populate an existing environment with all *.ttl files found in the specified directories (recursively),
or ingest the files directly if individual file paths are provided.
Multiple directories and/or files can be provided and will be processed in order.`,
	ValidArgsFunction: validArgsFunction,
	Args: func(cmd *cobra.Command, args []string) error {
		if populateExamples {
			if len(args) < 1 {
				display.Error("requires environment name when using --example")
				return fmt.Errorf("requires environment name when using --example")
			}
			return nil
		}
		if len(args) < 2 {
			display.Error("requires environment name and at least one TTL path (or use --example flag)")
			return fmt.Errorf("requires environment name and at least one TTL path (or use --example flag)")
		}
		return nil
	},
	Run: func(cmd *cobra.Command, args []string) {
		name := args[0]
		ttlPaths := args[1:]

		d, err := dockercore.Populate(dockercore.PopulateOpts{
			TTLDirs:          ttlPaths,
			Name:             name,
			Parallel:         parallel,
			PopulateExamples: populateExamples,
		})
		if err != nil {
			display.Error("%v", err)
			os.Exit(1)
		}

		display.Urls(d.GuiUrl, d.ApiUrl, d.BackofficeUrl, fmt.Sprintf("epos-opensource docker populate %s", name))
	},
}
View Source
var UpdateCmd = &cobra.Command{
	Use:   "update [env-name]",
	Short: "Recreate an environment with new settings.",
	Long:  "Re-deploy an existing Docker Compose environment after modifying its configuration.",
	Args:  cobra.ExactArgs(1),
	Run: func(cmd *cobra.Command, args []string) {
		name := args[0]

		d, err := dockercore.Update(dockercore.UpdateOpts{
			EnvFile:     envFile,
			ComposeFile: composeFile,
			Name:        name,
			PullImages:  pullImages,
			Force:       force,
			CustomHost:  host,
			Reset:       reset,
		})
		if err != nil {
			display.Error("%v", err)
			os.Exit(1)
		}

		display.Urls(d.GuiUrl, d.ApiUrl, d.BackofficeUrl, fmt.Sprintf("epos-opensource docker update %s", name))
	},
}

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis
Package dockercore contains the internal functions used by the docker cmd to manage the environments
Package dockercore contains the internal functions used by the docker cmd to manage the environments

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL