php

package
v0.0.0-...-25f2897 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2020 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfigDir   = "/usr/local/etc"
	WorkingDir  = "/app"
	ComposerDir = "/composer"
)

Variables

View Source
var SharedKeys = struct {
	BuildContext  string
	ComposerFiles string
	ConfigFiles   string
}{
	BuildContext:  "build-context",
	ComposerFiles: "composer-files",
	ConfigFiles:   "config-files",
}

Functions

func InstallExtensions

func InstallExtensions(
	stageDef StageDefinition,
	state llb.State,
	buildOpts builddef.BuildOpts,
) llb.State

InstallExtensions adds a step to the given LLB state to isntall PHP extensions for a given StageDefinition. It uses the locked extensions available in the StageLocks. The same state is returned if no extensions are locked.

The set of extensions is splitted into core extensions and community extensions. The former are installed using docker-php-ext-install whereas ther latter are installed using notpecl (a replacement for pecl). It takes care of deleting downloaded/unpacked files after installing extensions.

func RegisterKind

func RegisterKind(registry *registry.KindRegistry)

RegisterKind adds a LLB DAG builder to the given KindRegistry for php definition kind.

Types

type ComposerDumpFlags

type ComposerDumpFlags struct {
	// APCU enables --apcu flag during composer dump (will use APCu to cache found/not found classes)
	APCU bool `mapstructure:"apcu"`
	// ClassmapAuthoritative enables the matching optimization flag during composer dump.
	ClassmapAuthoritative bool `mapstructure:"classmap_authoritative"`
}

ComposerDumpFlags represents the optimization flags taken by Composer for `composer dump-autoloader`. Only advanced optimizations can be enabled, as the --optimize flag is automatically added whenever building images, except for dev stage (see cacheWarmup()).

func (ComposerDumpFlags) Flags

func (fl ComposerDumpFlags) Flags() (string, error)

func (ComposerDumpFlags) IsValid

func (fl ComposerDumpFlags) IsValid() error

type ComposerLock

type ComposerLock struct {
	PlatformReqs    *builddef.VersionMap
	PlatformReqsDev *builddef.VersionMap
}

func LoadComposerLock

func LoadComposerLock(
	ctx context.Context,
	solver statesolver.StateSolver,
	sourceContext *builddef.Context,
) (ComposerLock, error)

loadComposerLock loads composer.lock file from build context and adds extensions listed in platform-reqs key and in locked packages requirements to stageDef.PlatformReqs. It returns nil if the composer.lock file couldn't be found.

type Definition

type Definition struct {
	BaseStage Stage `mapstructure:",squash"`

	BaseImage     string          `mapstructure:"base"`
	Version       string          `mapstructure:"version"`
	Alpine        bool            `mapstructure:"alpine"`
	MajMinVersion string          `mapstructure:"-"`
	Infer         *bool           `mapstructure:"infer"`
	Stages        DerivedStageSet `mapstructure:"stages"`

	SourceContext *builddef.Context `mapstructure:"source_context"`

	Locks DefinitionLocks `mapstructure:"-"`
}

Definition holds the specialized config parameters for php images. It represents the "base" stage and as such holds the PHP version (ths is the only parameter that can't be overriden by derived stages).

func DefaultDefinition

func DefaultDefinition() Definition

DefaultDefinition returns a Definition with all its fields initialized with default values.

func NewKind

func NewKind(genericDef *builddef.BuildDef) (Definition, error)

func (Definition) Copy

func (def Definition) Copy() Definition

func (Definition) IsValid

func (def Definition) IsValid() error

func (Definition) Merge

func (base Definition) Merge(overriding Definition) Definition

func (*Definition) ResolveStageDefinition

func (def *Definition) ResolveStageDefinition(
	stageName string,
	composerLockLoader func(*StageDefinition) error,
	withStageLocks bool,
) (StageDefinition, error)

type DefinitionLocks

type DefinitionLocks struct {
	BaseImage     string                `mapstructure:"base_image"`
	OSRelease     builddef.OSRelease    `mapstructure:"osrelease"`
	ExtensionDir  string                `mapstructure:"extension_dir"`
	Stages        map[string]StageLocks `mapstructure:"stages"`
	SourceContext *builddef.Context     `mapstructure:"source_context"`
}

DefinitionLocks defines version locks for system packages and PHP extensions used by each stage.

func (DefinitionLocks) RawLocks

func (l DefinitionLocks) RawLocks() map[string]interface{}

type DerivedStage

type DerivedStage struct {
	Stage `mapstructure:",squash"`

	DeriveFrom string `mapstructure:"derive_from"`
	// Dev marks if this is a dev stage (with lighter build process). It's used
	// as a pointer to distinguish when the value is nil or when it's false. In
	// the former case, the value from the parent stage is used.
	Dev *bool `mapstructure:"dev"`
}

func (DerivedStage) Copy

func (s DerivedStage) Copy() DerivedStage

func (DerivedStage) Merge

func (s DerivedStage) Merge(overriding DerivedStage) DerivedStage

type DerivedStageSet

type DerivedStageSet map[string]DerivedStage

func (DerivedStageSet) Copy

func (set DerivedStageSet) Copy() DerivedStageSet

func (DerivedStageSet) Merge

func (base DerivedStageSet) Merge(overriding DerivedStageSet) DerivedStageSet

type PHPHandler

type PHPHandler struct {
	// contains filtered or unexported fields
}

func NewPHPHandler

func NewPHPHandler() *PHPHandler

func (*PHPHandler) Build

func (h *PHPHandler) Build(
	ctx context.Context,
	buildOpts builddef.BuildOpts,
) (llb.State, *image.Image, error)

func (*PHPHandler) DebugConfig

func (h *PHPHandler) DebugConfig(
	buildOpts builddef.BuildOpts,
) (interface{}, error)

func (*PHPHandler) UpdateLocks

func (h *PHPHandler) UpdateLocks(
	ctx context.Context,
	pkgSolvers pkgsolver.PackageSolversMap,
	opts builddef.UpdateLocksOpts,
) (builddef.Locks, error)

func (*PHPHandler) WithPeclBackend

func (h *PHPHandler) WithPeclBackend(pb pecl.Backend)

func (*PHPHandler) WithSolver

func (h *PHPHandler) WithSolver(solver statesolver.StateSolver)

type Stage

type Stage struct {
	ExternalFiles     []llbutils.ExternalFile     `mapstructure:"external_files"`
	SystemPackages    *builddef.VersionMap        `mapstructure:"system_packages"`
	FPM               *bool                       `mapstructure:"fpm"`
	Command           *[]string                   `mapstructure:"command"`
	Extensions        *builddef.VersionMap        `mapstructure:"extensions"`
	GlobalDeps        *builddef.VersionMap        `mapstructure:"global_deps"`
	ConfigFiles       builddef.PathsMap           `mapstructure:"config_files"`
	ComposerDumpFlags *ComposerDumpFlags          `mapstructure:"composer_dump"`
	Sources           []string                    `mapstructure:"sources"`
	Integrations      []string                    `mapstructure:"integrations"`
	StatefulDirs      []string                    `mapstructure:"stateful_dirs"`
	Healthcheck       *builddef.HealthcheckConfig `mapstructure:"healthcheck"`
	PostInstall       []string                    `mapstructure:"post_install"`
}

Stage holds all the properties from the base stage that could also be overriden by derived stages.

func (Stage) Copy

func (s Stage) Copy() Stage

func (Stage) Merge

func (s Stage) Merge(overriding Stage) Stage

type StageDefinition

type StageDefinition struct {
	Stage
	Name          string
	Version       string
	MajMinVersion string
	Infer         bool
	Dev           bool
	// PlatformReqs is the list of extension requirements extracted from
	// composer.lock. See LoadComposerLock.
	PlatformReqs *builddef.VersionMap
	DefLocks     DefinitionLocks
	StageLocks   StageLocks
}

StageDefinition represents the config of stage once it got merged with all its ancestors.

func (StageDefinition) IsValid

func (stageDef StageDefinition) IsValid() error

type StageLocks

type StageLocks struct {
	SystemPackages map[string]string `mapstructure:"system_packages"`
	Extensions     map[string]string `mapstructure:"extensions"`
}

StageLocks represents the version locks for a single stage. @TODO: use builddef.VersionMap

func (StageLocks) RawLocks

func (l StageLocks) RawLocks() map[string]interface{}

Jump to

Keyboard shortcuts

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