railpack

Configure and troubleshoot Railpack builds, with emphasis on RAILPACK_* environment variables, railpack.json overlays, build-plan inspection, local CLI installation and usage, and local BuildKit containers. Use for Railpack provider configuration, custom install/build/start commands, Mise or Apt packages, build or runtime variables and secrets, generated-plan debugging, BUILDKIT_HOST errors, or running Railpack from a release or source checkout.

Install
npx skills add 'https://github.com/railwayapp/railpack/tree/main/.'
Incomplete bundle · no download
main · 21a254fScanned 2026-09-17

Contributors

GitHub-linked commit authors for this SKILL.md at the saved revision. Co-authors and history before file renames are not included.

File history ↗

core/app/environment.go

core/app/environment.goBrowse 1970 files
View on GitHub
← Back to SKILL.md
package app import (	"fmt"	"os"	"regexp"	"strings") type Environment struct {	Variables map[string]string} func NewEnvironment(variables *map[string]string) *Environment {	if variables == nil {		variables = &map[string]string{}	} 	return &Environment{Variables: *variables}} // FromEnvs collects variables from the given environment variable namesfunc FromEnvs(envs []string) (*Environment, error) {	env := NewEnvironment(nil)	re := regexp.MustCompile(`(?s)([A-Za-z0-9_+\-]*)(?:=?)(.*)`) 	for _, e := range envs {		matches := re.FindStringSubmatch(e)		if len(matches) < 3 {			continue		} 		name := matches[1]		value := matches[2] 		if value == "" {			// A bare NAME inherits from the process env; NAME= is skipped.			if !strings.Contains(e, "=") {				if v, ok := os.LookupEnv(name); ok {					env.SetVariable(name, v)				}			}		} else {			env.SetVariable(name, value)		}	} 	return env, nil} // GetVariable returns the value of the given variable namefunc (e *Environment) GetVariable(name string) string {	return e.Variables[name]} // SetVariable stores a variable in the Environmentfunc (e *Environment) SetVariable(name, value string) {	e.Variables[name] = value} // ConfigVariable returns the RAILPACK_ prefixed version of a variable namefunc (e *Environment) ConfigVariable(name string) string {	return fmt.Sprintf("RAILPACK_%s", name)} // returns the value of a RAILPACK_ prefixed variable with newlines removed// Returns both the value and the name of the config variablefunc (e *Environment) GetConfigVariable(name string) (string, string) {	configVar := e.ConfigVariable(name) 	if val, exists := e.Variables[configVar]; exists {		return strings.TrimSpace(val), configVar	}	return "", ""} // GetConfigVariableList returns a space-separated config variable as a list// Returns both the list and the name of the config variablefunc (e *Environment) GetConfigVariableList(name string) ([]string, string) {	val, configVar := e.GetConfigVariable(name)	if val == "" {		return nil, ""	}	return strings.Split(val, " "), configVar} // checks if a RAILPACK_ prefixed variable is set to "1" or "true"func (e *Environment) IsConfigVariableTruthy(name string) bool {	if val, _ := e.GetConfigVariable(name); val != "" {		lowerVal := strings.ToLower(val)		return lowerVal == "1" || lowerVal == "true"	}	return false} // GetSecretsWithPrefix returns all secrets that have the given prefixfunc (e *Environment) GetSecretsWithPrefix(prefix string) []string {	secrets := []string{}	for secretName := range e.Variables {		if strings.HasPrefix(secretName, prefix) {			secrets = append(secrets, secretName)		}	}	return secrets}