This documentation provides a step-by-step guide on the configuration options for the chainguard-dev/apko development environment. It assumes the environment is already set up and focuses on the configuration aspects only.
Go Build Configuration
The chainguard.dev/apko
Go module is essential for building your application. Here’s how to configure it effectively while ensuring your build output maintains the expected structure.
Setting GO111MODULE
It is important to ensure that Go modules are correctly utilized. To explicitly enable Go modules, set the GO111MODULE
environment variable:
export GO111MODULE=on
Building the Project
When building the project, avoid using the -mod=vendor
flag as specified. Instead, use the following command to compile the apko application:
go build -o apko ./...
Make sure to run this command in the root directory of the repository where the Go module is defined.
Makefile Configuration
You can streamline your build process and configuration by editing the Makefile included in the project. Below are key sections you might consider modifying:
Custom Build Targets
To add custom build targets, edit the Makefile to define additional commands. Here’s an example of how you could add a target for running tests:
.PHONY: test
test:
go test ./...
Invoke this target by running:
make test
Environment Variables
Consider configuring environment variables that affect the build process. For instance, if you need to set the GOOS
and GOARCH
variables for cross-compilation, you can do so either in your shell or within the Makefile:
export GOOS=linux
export GOARCH=amd64
Or add to your Makefile:
.PHONY: build-linux
build-linux:
GOOS=linux GOARCH=amd64 go build -o apko-linux ./...
Dependency Management
Ensure that dependencies are properly managed by referring to the go.mod
file. When adding new dependencies, use the standard Go command for module management:
go get <dependency>
This updates your go.mod
file automatically to reflect any new dependencies.
Summary
In your configuration of the chainguard-dev/apko development environment, focus on:
- Setting the
GO111MODULE
environment variable to enable Go modules. - Using the
go build
command without the-mod=vendor
flag. - Modifying the Makefile for ease of use and custom targets.
- Setting necessary environment variables for your build process.
- Managing dependencies through the
go.mod
file.
By adhering to these guidelines, the configuration of your development environment will be efficient and effective.
Sources:
chainguard.dev/apko