|
| 1 | +--- |
| 2 | +description: |- |
| 3 | + Packaging OpenBao for distribution |
| 4 | +displayed_sidebar: docs |
| 5 | +--- |
| 6 | + |
| 7 | +# Packaging guide |
| 8 | + |
| 9 | +The ultimate reference for packaging is our |
| 10 | +[`.goreleaser-template.yaml`](https://github.com/openbao/openbao/blob/main/.goreleaser-template.yaml). |
| 11 | + |
| 12 | +This document serves as a reference to some options available there. |
| 13 | + |
| 14 | +:::warning |
| 15 | + |
| 16 | +The scripts in the `Makefile` are for development only. They do not constitute |
| 17 | +a stable or supported interface for release builds. They often make |
| 18 | +assumptions true in development environments (such as having a full Git tree |
| 19 | +available) that may not be true in release build environments. |
| 20 | + |
| 21 | +If you use those interfaces for release builds, you do so at your own risk. |
| 22 | + |
| 23 | +::: |
| 24 | + |
| 25 | +:::info |
| 26 | + |
| 27 | +While `goreleaser` is used for our upstream release binaries, it may not be a |
| 28 | +suitable tool for your builds. This document does not contain instructions on |
| 29 | +invoking `goreleaser` as performed upstream, but serves as a reference for |
| 30 | +building a stable downstream release build process for packaging environments. |
| 31 | + |
| 32 | +It may not be complete; feel free to extend it via GitHub pull request. |
| 33 | + |
| 34 | +::: |
| 35 | + |
| 36 | +## Suggested dependencies |
| 37 | + |
| 38 | + - NodeJS, npm, and Yarn for building the UI. |
| 39 | + - Go toolchain for building. |
| 40 | + |
| 41 | +For version information, refer to our release process. The Go toolchain |
| 42 | +version used by this project is documented in the `/.go-version` file. |
| 43 | + |
| 44 | +## UI Release |
| 45 | + |
| 46 | +To build a release version of the UI: |
| 47 | + |
| 48 | +``` |
| 49 | +# UI must be built from the UI directory. |
| 50 | +cd ui/ |
| 51 | +
|
| 52 | +# Install dependencies via yarn. |
| 53 | +yarn |
| 54 | +
|
| 55 | +# Rebuild the node-sass dependency. |
| 56 | +npm rebuild node-sass |
| 57 | +
|
| 58 | +# Perform the release build via yarn. |
| 59 | +yarn run build |
| 60 | +``` |
| 61 | + |
| 62 | +This creates a directory, `/http/web_ui`, which contains the output of the |
| 63 | +build. |
| 64 | + |
| 65 | +## Go binary |
| 66 | + |
| 67 | +### Required ldflags |
| 68 | + |
| 69 | +To build a release binary, define the following variables via [linker flag variable |
| 70 | +definitions](https://pkg.go.dev/cmd/link) as appropriate: |
| 71 | + |
| 72 | +| Parameter | Value | |
| 73 | +| :-------- | :---- | |
| 74 | +| `github.com/openbao/openbao/version.fullVersion` | Version number of OpenBao; typically this matches the upstream version. Must be semver (`<major>.<minor>.<patch>`). Required. | |
| 75 | +| `github.com/openbao/openbao/version.GitCommit` | Git commit for reference; string. Required. | |
| 76 | +| `github.com/openbao/openbao/version.BuildDate` | Build timestamp string in the format `%Y-%m-%dT%H:%M:%SZ` (UTC). Usually this is the date of the commit. Required. | |
| 77 | +| `github.com/openbao/openbao/version.VersionMetadata` | Custom version information; string. Optional. | |
| 78 | + |
| 79 | +### Known tags |
| 80 | + |
| 81 | +The following tags are known: |
| 82 | + |
| 83 | +| Tag | Effect | |
| 84 | +| :---- | :----- | |
| 85 | +| `ui` | Enables bundling of the WebUI into the release. | |
| 86 | +| `hsm` | Enables PKCS#11 HSM support. Requires [CGo](#cgo) to be enabled. | |
| 87 | + |
| 88 | +:::warning |
| 89 | + |
| 90 | +The following flags **SHOULD NOT** be used in a release version: |
| 91 | + |
| 92 | +| Tag | Effect | |
| 93 | +| :-- | :----- | |
| 94 | +| `memprofiler` | Includes a memory profiler in the release binary for debugging purposes only. | |
| 95 | +| `testonly` | Includes insecure custom hooks only for testing purposes. | |
| 96 | +| `deadlock` | Includes deadlock detection during testing. | |
| 97 | +| `race` | Enabled for race testing. | |
| 98 | + |
| 99 | +::: |
| 100 | + |
| 101 | +### CGo |
| 102 | + |
| 103 | +CGo can be enabled on any platform but has no effect on most as OpenBao is |
| 104 | +generally built as a static library. Occasionally, the Go toolchain will |
| 105 | +change its behavior on various platforms if CGo is enabled. |
| 106 | + |
| 107 | +The exception to this is PKCS#11 HSM support. This only works on glibc-based |
| 108 | +distributions and does not support musl or other alternative stdlib |
| 109 | +implementations. To enable CGo support (and thus, PKCS#11 HSM support), set |
| 110 | +`CGO_ENABLED=1` in the release binary and assert the `hsm` tag. |
| 111 | + |
| 112 | +### Building |
| 113 | + |
| 114 | +For instance, our upstream release invokes Go as follows: |
| 115 | + |
| 116 | +``` |
| 117 | +CGO_ENABLED=0 go build \ |
| 118 | + -ldflags "-X github.com/openbao/openbao/version.fullVersion=v2.1.0 -X github.com/openbao/openbao/version.GitCommit=93609bf0c73a18dd81ac8c7d21b95cbde1e4887c -X github.com/openbao/openbao/version.BuildDate=2024-11-29T15:34:50Z" |
| 119 | + . |
| 120 | +``` |
| 121 | + |
| 122 | +### Linux package scripts |
| 123 | + |
| 124 | +Other scripts for Linux packaging are available under the `.release/linux` |
| 125 | +directory. |
| 126 | + |
| 127 | +### Container images |
| 128 | + |
| 129 | +Our container images use the binary directly with the containerfile at |
| 130 | +`/Dockerfile`. The entrypoint used is available under `.release/docker/`. |
0 commit comments