project

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package project detects the kind of Docker project in a directory, loads the optional soloenv.yml config, and resolves which local port to expose.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DockerfileExpose

func DockerfileExpose(dir, dockerfile string) int

DockerfileExpose reads the first EXPOSE port from the Dockerfile, or 0 if none.

func ResolveAuth

func ResolveAuth(cfg *Config, flagPassword string, flagProtect bool) (user, password string, err error)

ResolveAuth returns user and password for basic auth. Empty password means no auth.

func ResolveComposePort

func ResolveComposePort(dir, composeFile, service string, override int) (int, error)

ResolveComposePort determines the host port to expose for a compose project. override (from flag/config) wins if > 0. Otherwise it parses the rendered compose config: if service is given, its first published port is used; if not, and exactly one published port exists across services, that one is used.

func ResolveEnvFile

func ResolveEnvFile(dir string, cfg *Config, flagPath string) (string, error)

ResolveEnvFile picks the env file for docker compose/run. Priority: flag > config > .env.staging > .env.soloenv

func ResolveTTL

func ResolveTTL(cfg *Config, flagTTL string) (time.Duration, error)

ResolveTTL parses duration from flag or config (e.g. "2h", "45m").

Types

type Config

type Config struct {
	Port     int    `yaml:"port"`
	Service  string `yaml:"service"`
	Build    *bool  `yaml:"build"`
	EnvFile  string `yaml:"env_file"`
	Password string `yaml:"password"`
	AuthUser string `yaml:"auth_user"`
	TTL      string `yaml:"ttl"`
}

Config is the optional soloenv.yml file in the project directory.

func LoadConfig

func LoadConfig(dir string) (*Config, error)

LoadConfig reads soloenv.yml/soloenv.yaml from dir if present. A missing file is not an error: it returns an empty config.

type Kind

type Kind int

Kind is the type of Docker project detected.

const (
	// KindNone means no recognizable Docker project was found.
	KindNone Kind = iota
	// KindCompose means a Docker Compose file is present.
	KindCompose
	// KindDockerfile means a lone Dockerfile is present.
	KindDockerfile
)

type Project

type Project struct {
	Dir         string
	Kind        Kind
	ComposeFile string // filename relative to Dir (compose only)
	Dockerfile  string // filename relative to Dir (dockerfile only)
}

Project describes the detected Docker project.

func Detect

func Detect(dir string) (*Project, error)

Detect inspects dir and returns the detected Project. Compose takes priority over a lone Dockerfile, matching `docker compose` behavior.

Jump to

Keyboard shortcuts

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