Onboard Boundary to CRT (#1786)
Onboard Boundary to Common Release Tooling Co-authored-by: mdrake <mdrake@hashicorp.com> Co-authored-by: jeanneryan <jeanneryan@hashicorp.com>
This commit is contained in:
34 files changed
+1016
-5047
No files matched your search
@@ -0,0 +1,89 @@
|
||||
# Boundary Docker Image
|
||||
|
||||
The root of this repository contains the officially supported HashiCorp Dockerfile to build the hashicorp/boundary docker image. The dev docker image should be built for local dev and testing, while the production docker image is built in CI and makes use of CI-built binaries. The official docker image is built using the official binaries from releases.hashicorp.com.
|
||||
|
||||
## Build
|
||||
|
||||
See the Makefile targets in the root of this repository for building Boundary images in either
|
||||
development or release modes:
|
||||
|
||||
- `make docker-build-dev`
|
||||
- `make docker-multiarch-build`
|
||||
- `make docker-build`
|
||||
- `make docker`
|
||||
|
||||
## Usage
|
||||
|
||||
### Dev Mode
|
||||
|
||||
Due to the limitations of `boundary dev` running and maintaining a postgres docker container, it's not recommended
|
||||
to run `dev` mode inside docker. To do so will require knowledge of running [docker-in-docker](https://hub.docker.com/_/docker), and the caveats
|
||||
associated with it.
|
||||
|
||||
### Default Configuration
|
||||
|
||||
The default behavior of the Boundary docker image is to run `boundary server -config /boundary/config.hcl`. The default
|
||||
configuration can be found in this directory and it's highly recommended that end users replace this configuration
|
||||
with one that suites their environment.
|
||||
|
||||
### Postgres
|
||||
|
||||
The usage instructions in this README assume you have an external postgres database (version 11 or greater) to run
|
||||
boundary server with. If you want to get started quickly, you can start a local postgres in docker:
|
||||
|
||||
```bash
|
||||
docker run -it -p 5432:5432 -e POSTGRES_PASSWORD=postgres -e POSTGRES_USER=postgres postgres
|
||||
```
|
||||
|
||||
The postgres URL setting is defined with `env://BOUNDARY_POSTGRES_URL` so it can be easily overidden with `-e`
|
||||
during docker run:
|
||||
|
||||
```bash
|
||||
docker run <truncated> -e 'BOUNDARY_POSTGRES_URL=postgresql://postgres:postgres@0.0.0.0:5432/postgres?sslmode=disable' <truncated>
|
||||
```
|
||||
### Database Init
|
||||
|
||||
If you're starting with a new, unused postgres instance, initialize the database using the default config.hcl:
|
||||
|
||||
```bash
|
||||
docker run \
|
||||
--network host \
|
||||
-e 'BOUNDARY_POSTGRES_URL=postgresql://postgres:postgres@0.0.0.0:5432/postgres?sslmode=disable' \
|
||||
boundary database init -config /boundary/config.hcl
|
||||
```
|
||||
|
||||
If you want to run this with your own config.hcl (assuming config.hcl is located at `$(pwd)/config.hcl`):
|
||||
|
||||
```bash
|
||||
docker run \
|
||||
--network host \
|
||||
-e 'BOUNDARY_POSTGRES_URL=postgresql://postgres:postgres@0.0.0.0:5432/postgres?sslmode=disable' \
|
||||
-v "$(pwd)":/boundary/ \
|
||||
boundary database init -config /boundary/config.hcl
|
||||
```
|
||||
|
||||
### Server
|
||||
Start a Boundary server using the default `config.hcl`:
|
||||
|
||||
```bash
|
||||
docker run \
|
||||
--network host \
|
||||
-p 9200:9200 \
|
||||
-p 9201:9201 \
|
||||
-p 9202:9202 \
|
||||
-e 'BOUNDARY_POSTGRES_URL=postgresql://postgres:postgres@0.0.0.0:5432/postgres?sslmode=disable' \
|
||||
boundary
|
||||
```
|
||||
|
||||
Start a Boundary server using your own `config.hcl`, assuming it's located at `$(pwd)/config.hcl`:
|
||||
|
||||
```bash
|
||||
docker run \
|
||||
--network host \
|
||||
-p 9200:9200 \
|
||||
-p 9201:9201 \
|
||||
-p 9202:9202 \
|
||||
-v "$(pwd)":/boundary/ \
|
||||
-e 'BOUNDARY_POSTGRES_URL=postgresql://postgres:postgres@0.0.0.0:5432/postgres?sslmode=disable' \
|
||||
boundary
|
||||
```
|
||||
@@ -0,0 +1,74 @@
|
||||
# This is a default configuration provided for our Docker image. It's meant to
|
||||
# be a starting point and to help new users get started. It's strongly
|
||||
# recommended that this configuration is not used outside of demonstrations
|
||||
# because it uses hard coded AEAD keys.
|
||||
|
||||
disable_mlock = true
|
||||
|
||||
controller {
|
||||
name = "demo-controller"
|
||||
description = "A default controller created for demonstration"
|
||||
|
||||
database {
|
||||
# This configuration setting requires the user to execute the container with the URL as an env var
|
||||
# to connect to the Boundary postgres DB. An example of how this can be done assuming the postgres
|
||||
# database is running as a container and you're using Docker for Mac (replace host.docker.internal with
|
||||
# localhost if you're on Linux):
|
||||
#
|
||||
# $ docker run -e 'BOUNDARY_POSTGRES_URL=postgresql://postgres:postgres@host.docker.internal:5432/postgres?sslmode=disable' [other options] boundary:[version]
|
||||
url = "env://BOUNDARY_POSTGRES_URL"
|
||||
}
|
||||
|
||||
public_cluster_addr = "env://HOSTNAME"
|
||||
}
|
||||
|
||||
worker {
|
||||
name = "demo-worker"
|
||||
description = "A default worker created for demonstration"
|
||||
}
|
||||
|
||||
listener "tcp" {
|
||||
address = "0.0.0.0"
|
||||
purpose = "api"
|
||||
tls_disable = true
|
||||
}
|
||||
|
||||
listener "tcp" {
|
||||
address = "0.0.0.0"
|
||||
purpose = "cluster"
|
||||
tls_disable = true
|
||||
}
|
||||
|
||||
listener "tcp" {
|
||||
address = "0.0.0.0"
|
||||
purpose = "proxy"
|
||||
tls_disable = true
|
||||
}
|
||||
|
||||
# Root KMS configuration block: this is the root key for Boundary
|
||||
# Use a production KMS such as AWS KMS in production installs
|
||||
kms "aead" {
|
||||
purpose = "root"
|
||||
aead_type = "aes-gcm"
|
||||
key = "uC8zAQ3sLJ9o0ZlH5lWIgxNZrNn0FiFqYj4802VKLKQ="
|
||||
key_id = "global_root"
|
||||
}
|
||||
|
||||
# Worker authorization KMS
|
||||
# Use a production KMS such as AWS KMS for production installs
|
||||
# This key is the same key used in the worker configuration
|
||||
kms "aead" {
|
||||
purpose = "worker-auth"
|
||||
aead_type = "aes-gcm"
|
||||
key = "cOQ9fiszFoxu/c20HbxRQ5E9dyDM6PqMY1GwqVLihsI="
|
||||
key_id = "global_worker-auth"
|
||||
}
|
||||
|
||||
# Recovery KMS block: configures the recovery key for Boundary
|
||||
# Use a production KMS such as AWS KMS for production installs
|
||||
kms "aead" {
|
||||
purpose = "recovery"
|
||||
aead_type = "aes-gcm"
|
||||
key = "nIRSASgoP91KmaEcg/EAaM4iAkksyB+Lkes0gzrLIRM="
|
||||
key_id = "global_recovery"
|
||||
}
|
||||
Executable
+53
@@ -0,0 +1,53 @@
|
||||
#!/usr/bin/dumb-init /bin/sh
|
||||
set -e
|
||||
|
||||
# Note above that we run dumb-init as PID 1 in order to reap zombie processes
|
||||
# as well as forward signals to all processes in its session. Normally, sh
|
||||
# wouldn't do either of these functions so we'd leak zombies as well as do
|
||||
# unclean termination of all our sub-processes.
|
||||
|
||||
# Prevent core dumps
|
||||
ulimit -c 0
|
||||
|
||||
# If the user is trying to run Boundary directly with some arguments, then
|
||||
# pass them to Boundary.
|
||||
if [ "${1:0:1}" = '-' ]; then
|
||||
set -- boundary "$@"
|
||||
fi
|
||||
|
||||
if [ "$1" = 'server' ]; then
|
||||
shift
|
||||
set -- boundary server \
|
||||
"$@"
|
||||
elif boundary --help "$1" 2>&1 | grep -q "boundary $1"; then
|
||||
# We can't use the return code to check for the existence of a subcommand, so
|
||||
# we have to use grep to look for a pattern in the help output.
|
||||
set -- boundary "$@"
|
||||
fi
|
||||
|
||||
# If we are running Boundary, make sure it executes as the proper user.
|
||||
if [ "$1" = 'boundary' ]; then
|
||||
if [ -z "$SKIP_CHOWN" ]; then
|
||||
# If the config dir is bind mounted then chown it
|
||||
if [ "$(stat -c %u /boundary)" != "$(id -u boundary)" ]; then
|
||||
chown -R boundary:boundary /boundary || echo "Could not chown /boundary (may not have appropriate permissions)"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$SKIP_SETCAP" ]; then
|
||||
# Allow mlock to avoid swapping Boundary memory to disk
|
||||
setcap cap_ipc_lock=+ep $(readlink -f $(which boundary))
|
||||
|
||||
# In the case Boundary has been started in a container without IPC_LOCK privileges
|
||||
if ! boundary -version 1>/dev/null 2>/dev/null; then
|
||||
>&2 echo "Couldn't start Boundary with IPC_LOCK. Disabling IPC_LOCK, please use --privileged or --cap-add IPC_LOCK"
|
||||
setcap cap_ipc_lock=-ep $(readlink -f $(which boundary))
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$(id -u)" = '0' ]; then
|
||||
set -- su-exec boundary "$@"
|
||||
fi
|
||||
fi
|
||||
|
||||
exec "$@"
|
||||
Reference in new issue
Block a user