GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Why Go
  • Case Studies
  • Use Cases
  • Security
  • Learn
  • Effective Go
  • Go User Manual
  • Standard library
  • Release Notes
  • API
  • Packages
  • Recorded Talks
  • Meetups
  • Conferences

This view

  • Original page
  • New address

GeezerVison is showing pkg.go.dev — envbuilder package - github.com/coder/envbuilder - Go Packages

Details

  • checked Valid go.mod file

    The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.

  • checked Redistributable license

    Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.

  • checked Tagged version

    Modules with tagged versions give importers more predictable builds.

  • checked Stable version

    When a project reaches major version v1 it is considered stable.

  • Learn more about best practices

Repository

github.com/coder/envbuilder

Links

  • Open Source Insights Logo Open Source Insights

README ¶

Envbuilder

envbuilder

(Video created using asciinema and agg)

Build development environments from a Dockerfile on Docker, Kubernetes, and OpenShift. Allow developers to modify their environment in a tight feedback loop.

  • Supports devcontainer.json and Dockerfile
  • Cache image layers with registries for speedy builds
  • Runs on Kubernetes, Docker, and OpenShift

Getting Started

The easiest way to get started is by running the envbuilder Docker container that clones a repository specified by ENVBUILDER_GIT_URL, builds the image from a Dockerfile or devcontainer.json, and runs the $ENVBUILDER_INIT_SCRIPT in the freshly built container.

Tips:

  • The /tmp/envbuilder directory persists demo data between commands. You can choose a different directory if needed.
  • To clone a different branch, you append it to ENVBUILDER_GIT_URL in the form #refs/heads/my-branch. For example: https://github.com/coder/envbuilder-starter-devcontainer#refs/heads/boring-prompt.
docker run -it --rm \
    -v /tmp/envbuilder:/workspaces \
    -e ENVBUILDER_GIT_URL=https://github.com/coder/envbuilder-starter-devcontainer \
    -e ENVBUILDER_INIT_SCRIPT=bash \
    ghcr.io/coder/envbuilder

Edit .devcontainer/Dockerfile to add htop:

vim .devcontainer/Dockerfile
- RUN apt-get install vim sudo -y
+ RUN apt-get install vim sudo htop -y

Exit the container and re-run the docker run command. After the build completes, htop should be available in the container! 🥳

To explore more examples, tips, and advanced usage, check out the following guides:

  • Using Local Files
  • Usage with Coder
  • Container Registry Authentication
  • Git Authentication
  • Caching
  • Custom Certificates & Proxies
  • Users

Setup Script

The ENVBUILDER_SETUP_SCRIPT environment variable dynamically configures the user and init command (PID 1) after the container build process.

Note: TARGET_USER is passed to the setup script to specify who will execute ENVBUILDER_INIT_COMMAND (e.g., code).

Write the following to $ENVBUILDER_ENV to shape the container's init process:

  • TARGET_USER: Identifies the ENVBUILDER_INIT_COMMAND executor (e.g., root).
  • ENVBUILDER_INIT_COMMAND: Defines the command executed by TARGET_USER (e.g. /bin/bash).
  • ENVBUILDER_INIT_ARGS: Arguments provided to ENVBUILDER_INIT_COMMAND (e.g., -c 'sleep infinity').
# init.sh - Change the init if systemd exists
if command -v systemd >/dev/null; then
  echo "Hey 👋 $TARGET_USER"
  echo ENVBUILDER_INIT_COMMAND=systemd >> $ENVBUILDER_ENV
else
  echo ENVBUILDER_INIT_COMMAND=bash >> $ENVBUILDER_ENV
fi

# Run envbuilder with the setup script
docker run -it --rm \
  -v ./:/some-dir \
  -e ENVBUILDER_SETUP_SCRIPT=/some-dir/init.sh \
  ...

Environment Variables

You can see all the supported environment variables in this document.

Development Containers

This document keeps track of what parts of the Dev Container specification Envbuilder currently supports.

Feel free to create a new issue if you'd like Envbuilder to support a particular feature.

Devfile

Devfiles automate and simplify development by adopting existing devfiles available in the public community registry.

Issue: #113

Contributing

See Development for build instructions, dependency management notes, and common troubleshooting.

Documentation ¶

Index ¶

  • Variables
  • func Run(ctx context.Context, opts options.Options, preExec ...func()) error
  • func RunCacheProbe(ctx context.Context, opts options.Options) (v1.Image, error)
  • type DockerConfig

Constants ¶

This section is empty.

Variables ¶

View Source
var ErrNoFallbackImage = errors.New("no fallback image has been specified")

ErrNoFallbackImage is returned when no fallback image has been specified.

Functions ¶

func Run ¶

func Run(ctx context.Context, opts options.Options, preExec ...func()) error

Run runs the envbuilder. Logger is the logf to use for all operations. Filesystem is the filesystem to use for all operations. Defaults to the host filesystem. preExec are any functions that should be called before exec'ing the init command. This is useful for ensuring that defers get run.

func RunCacheProbe ¶ added in v1.0.0

func RunCacheProbe(ctx context.Context, opts options.Options) (v1.Image, error)

RunCacheProbe performs a 'dry-run' build of the image and checks that all of the resulting layers are present in options.CacheRepo.

Types ¶

type DockerConfig ¶ added in v0.0.3

type DockerConfig = configfile.ConfigFile

DockerConfig represents the Docker configuration file.

Source Files ¶

View all Source files
  • envbuilder.go

Directories ¶

Path Synopsis
buildinfo
cmd
envbuilder command
devcontainer
features
git
internal
chmodfs
ebutil
workingdir
log
options
scripts
docsgen command
testutil
gittest
mwtest
registrytest
Click to show internal directories.
Click to hide internal directories.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.