Go is a statically typed, compiled high-level programming language designed at Google by Robert Griesemer, Rob Pike, and Ken Thompson. It is syntactically similar to C, but with memory safety, garbage collection, structural typing, and CSP-style concurrency. It is often referred to as Golang because of its former domain name, golang.org, but its proper name is Go.
wikipedia.org/wiki/Go_(programming_language)
The most straightforward way to use this image is to use a Go container as both the build and runtime environment. In your Containerfile, writing something along the lines of the following will compile and run your project (assuming it uses go.mod for dependency management):
FROM ghcr.io/appjail-makejails/go
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN go build -v -o /usr/local/bin/app ./...
CMD ["app"]You can then build and run the OCI image:
$ buildah build --network=host -t my-golang-app .
$ appjail oci run \
-o overwrite=force \
-o ephemeral \
-o alias \
-o ip4_inherit \
localhost/my-golang-app my-golang-appThere may be occasions where it is not appropriate to run your app inside a container. To compile, but not run your app inside the container instance, you can write something like:
$ appjail oci run \
-o overwrite=force \
-o ephemeral \
-o alias \
-o ip4_inherit \
-o fstab="$PWD /myapp" \
-w /myapp \
ghcr.io/appjail-makejails/go my-golang-app \
go build -v
$ ls ./myapp
./myappThis repository includes a small Makejail that ultimately uses the OCI image, in case you prefer to use appjail-makejail(5).
$ appjail makejail \
-j golang \
-f gh+AppJail-makejails/go \
-o alias \
-o ip4_inherit \
-o ephemeral \
-o container="args:--pull"
...
$ appjail cmd jexec golang go version
go version go1.25.11 freebsd/amd64go_from(default:ghcr.io/appjail-makejails/go): Location of OCI image. See also OCI Configuration.go_tag(default:latest): OCI image tag. See also OCI Configuration.
PGID(default:1000): Equivalent toPUIDbut for the Process Group ID.PUID(default:1000): Process User ID for the container's main process, allowing you to match the owner of files written to mounted host volumes to your host system's user. Writable volumes are changed based on this environment variable.
build:
variants:
- tag: 15.1
containerfile: Containerfile
aliases: ["latest"]
default: true
args:
FREEBSD_RELEASE: "15.1"
NO_PKGCLEAN: "1"
cache_dirs: ["pkgcache0:/var/cache/pkg"]
- tag: 15.1-125
containerfile: Containerfile
args:
FREEBSD_RELEASE: "15.1"
GOVER: "125"
NO_PKGCLEAN: "1"
cache_dirs: ["pkgcache0:/var/cache/pkg"]
- tag: 15.1-126
containerfile: Containerfile
args:
FREEBSD_RELEASE: "15.1"
GOVER: "126"
NO_PKGCLEAN: "1"
cache_dirs: ["pkgcache0:/var/cache/pkg"]/gois world-writable to allow flexibility in the user which runs the container (for example, in a container started with--user 1000:1000, runninggo get github.com/example/...into the default$GOPATHwill succeed). While the777directory would be insecure on a regular host setup, there are not typically other processes or users inside the container, so this is equivalent to700for Podman usage, but allowing for--userflexibility.- The ideas present in the Docker image of Go are taken into account for users who are familiar with it.