2026-04-06 15:48:37 +05:30
# Copyright IBM Corp. 2020, 2026
2022-02-01 07:41:27 -08:00
# SPDX-License-Identifier: BUSL-1.1
2023-02-02 17:15:17 -08:00
2022-02-01 07:41:27 -08:00
# This Dockerfile contains multiple targets.
# Use 'docker build --target=<name> .' to build one.
# e.g. `docker build --target=dev .`
#
# All non-dev targets have a VERSION argument that must be provided
# via --build-arg=VERSION=<version> when building.
# e.g. --build-arg=0.7.4
#
# `default` is the production docker image which cannot be built locally.
# For local dev and testing purposes, please build and use the `dev` docker image.
2026-10-12 09:53:13 -07:00
# Development docker image (built from the locally built ./bin/threshold)
FROM alpine:3.21 as dev
2022-02-01 07:41:27 -08:00
RUN set -eux && \
2026-10-12 09:53:13 -07:00
addgroup threshold && \
adduser -s /bin/sh -S -G threshold threshold && \
2022-02-01 07:41:27 -08:00
apk add --no-cache wget ca-certificates dumb-init gnupg libcap openssl su-exec iputils libc6-compat iptables
2026-10-12 09:53:13 -07:00
ADD bin/threshold /bin/threshold
RUN setcap cap_ipc_lock = +ep /bin/threshold
2022-02-01 07:41:27 -08:00
2026-10-12 09:53:13 -07:00
RUN mkdir /threshold/
ADD .release/docker/config.hcl /threshold/config.hcl
RUN chown -R threshold:threshold /threshold/
RUN chmod -R 640 /threshold/*
2022-02-01 07:41:27 -08:00
2026-10-12 11:12:29 -07:00
# Legacy HashiCorp Boundary compatibility: /boundary -> /threshold and a
# "boundary" command alias (prints a deprecation notice on stderr).
RUN mkdir -p /usr/share/threshold && \
cp /threshold/config.hcl /usr/share/threshold/config.hcl.default && \
ln -s /threshold /boundary && \
ln -s threshold /bin/boundary
2022-02-01 07:41:27 -08:00
EXPOSE 9200 9201 9202
2026-10-12 09:53:13 -07:00
VOLUME /threshold /
2022-02-01 07:41:27 -08:00
2024-04-17 09:04:40 -07:00
LABEL org.opencontainers.image.licenses= "BUSL-1.1"
2022-02-01 07:41:27 -08:00
COPY .release/docker/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
2026-10-12 09:53:13 -07:00
COPY bin/LICENSE.txt /usr/share/doc/threshold/LICENSE.txt
2024-04-17 09:04:40 -07:00
2026-10-12 09:53:13 -07:00
USER threshold
2022-02-01 07:41:27 -08:00
ENTRYPOINT [ "docker-entrypoint.sh" ]
2026-10-12 09:53:13 -07:00
CMD [ "server" , "-config" , "/threshold/config.hcl" ]
2022-02-01 07:41:27 -08:00
# Production docker image
# Remember, this cannot be built locally
2026-10-12 09:53:13 -07:00
FROM alpine:3.21 as default
2022-02-01 07:41:27 -08:00
ARG BIN_NAME
2026-10-12 09:53:13 -07:00
# NAME is the name of the software (and of the user/group created in the image);
# PRODUCT_VERSION is the version. Example: NAME=threshold PRODUCT_VERSION=1.2.3.
ARG NAME = threshold
2022-08-17 13:02:29 -07:00
ARG PRODUCT_VERSION
2022-02-01 07:41:27 -08:00
# TARGETARCH and TARGETOS are set automatically when --platform is provided.
ARG TARGETOS TARGETARCH
2026-10-12 09:53:13 -07:00
LABEL name = "Threshold" \
vendor = "Threshold (fork of HashiCorp Boundary CE)" \
2022-08-17 13:02:29 -07:00
version = $PRODUCT_VERSION \
release = $PRODUCT_VERSION \
2026-10-12 09:53:13 -07:00
summary = "Threshold provides simple and secure access to hosts and services" \
description = "The Threshold Docker image is designed to enable practitioners to run Threshold, a community fork of HashiCorp Boundary Community Edition, in server mode on a container scheduler. Not affiliated with or endorsed by HashiCorp or IBM." \
2024-04-17 09:04:40 -07:00
org.opencontainers.image.licenses= "BUSL-1.1"
2022-02-01 07:41:27 -08:00
# Set ARGs as ENV so that they can be used in ENTRYPOINT/CMD
ENV NAME = $NAME
2022-08-17 13:02:29 -07:00
ENV VERSION = $PRODUCT_VERSION
2022-02-01 07:41:27 -08:00
# Create a non-root user to run the software.
RUN addgroup ${ NAME } && adduser -s /bin/sh -S -G ${ NAME } ${ NAME }
RUN apk add --no-cache wget ca-certificates dumb-init gnupg libcap openssl su-exec iputils libc6-compat iptables
2026-10-12 09:53:13 -07:00
COPY .release/docker/config.hcl /threshold/config.hcl
2022-02-01 07:41:27 -08:00
COPY dist/$TARGETOS /$TARGETARCH /$BIN_NAME /bin/
2026-10-12 09:53:13 -07:00
COPY dist/$TARGETOS /$TARGETARCH /LICENSE.txt /usr/share/doc/threshold/LICENSE.txt
2026-03-23 15:01:47 +05:30
RUN setcap cap_ipc_lock = +ep /bin/$BIN_NAME
2022-02-01 07:41:27 -08:00
2026-10-12 09:53:13 -07:00
RUN chown -R ${ NAME } :${ NAME } /threshold
RUN chmod -R 640 /threshold/*
2022-02-01 07:41:27 -08:00
2026-10-12 11:12:29 -07:00
# Legacy HashiCorp Boundary compatibility: /boundary -> /threshold and a
# "boundary" command alias (prints a deprecation notice on stderr).
RUN mkdir -p /usr/share/threshold && \
cp /threshold/config.hcl /usr/share/threshold/config.hcl.default && \
ln -s /threshold /boundary && \
ln -s ${ BIN_NAME } /bin/boundary
2022-02-01 07:41:27 -08:00
EXPOSE 9200 9201 9202
2026-10-12 09:53:13 -07:00
VOLUME /threshold /
2022-02-01 07:41:27 -08:00
COPY .release/docker/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
2026-03-23 15:01:47 +05:30
USER ${NAME }
2022-02-01 07:41:27 -08:00
ENTRYPOINT [ "docker-entrypoint.sh" ]
2026-10-12 09:53:13 -07:00
CMD [ "server" , "-config" , "/threshold/config.hcl" ]