2023-03-15 12:00:52 -04:00
# Copyright (c) HashiCorp, Inc.
2023-08-10 21:14:03 -04:00
# SPDX-License-Identifier: BUSL-1.1
2023-03-15 12:00:52 -04:00
2022-05-13 11:21:15 -04:00
## DOCKERHUB DOCKERFILE ##
2024-10-07 12:16:22 -04:00
FROM alpine:3 AS default
2021-12-06 11:06:22 -05:00
ARG BIN_NAME
2022-03-10 07:59:30 -05:00
# NAME and PRODUCT_VERSION are the name of the software in releases.hashicorp.com
# and the version to download. Example: NAME=vault PRODUCT_VERSION=1.2.3.
2021-12-06 11:06:22 -05:00
ARG NAME = vault
2022-03-10 07:59:30 -05:00
ARG PRODUCT_VERSION
2022-05-13 11:21:15 -04:00
ARG PRODUCT_REVISION
2021-12-06 11:06:22 -05:00
# TARGETARCH and TARGETOS are set automatically when --platform is provided.
ARG TARGETOS TARGETARCH
2022-05-13 11:21:15 -04:00
# Additional metadata labels used by container registries, platforms
# and certification scanners.
LABEL name = "Vault" \
maintainer = "Vault Team <vault@hashicorp.com>" \
vendor = "HashiCorp" \
version = ${ PRODUCT_VERSION } \
release = ${ PRODUCT_REVISION } \
revision = ${ PRODUCT_REVISION } \
summary = "Vault is a tool for securely accessing secrets." \
description = "Vault is a tool for securely accessing secrets. A secret is anything that you want to tightly control access to, such as API keys, passwords, certificates, and more. Vault provides a unified interface to any secret, while providing tight access control and recording a detailed audit log."
2024-05-22 04:58:08 -04:00
# Copy the license file as per Legal requirement
2024-08-15 08:19:55 -04:00
COPY LICENSE /usr/share/doc/$NAME /LICENSE.txt
2021-12-06 11:06:22 -05:00
# Set ARGs as ENV so that they can be used in ENTRYPOINT/CMD
ENV NAME = $NAME
ENV VERSION = $VERSION
# Create a non-root user to run the software.
RUN addgroup ${ NAME } && adduser -S -G ${ NAME } ${ NAME }
2024-10-07 12:16:22 -04:00
RUN apk add --no-cache libcap su-exec dumb-init tzdata curl && \
mkdir -p /usr/share/doc/vault && \
curl -o /usr/share/doc/vault/EULA.txt https://eula.hashicorp.com/EULA.txt && \
curl -o /usr/share/doc/vault/TermsOfEvaluation.txt https://eula.hashicorp.com/TermsOfEvaluation.txt && \
apk del curl
2021-12-06 11:06:22 -05:00
COPY dist/$TARGETOS /$TARGETARCH /$BIN_NAME /bin/
# /vault/logs is made available to use as a location to store audit logs, if
# desired; /vault/file is made available to use as a location with the file
# storage backend, if desired; the server will be started with /vault/config as
# the configuration directory so you can add additional config files in that
# location.
RUN mkdir -p /vault/logs && \
mkdir -p /vault/file && \
mkdir -p /vault/config && \
chown -R ${ NAME } :${ NAME } /vault
# Expose the logs directory as a volume since there's potentially long-running
# state in there
VOLUME /vault/logs
# Expose the file directory as a volume since there's potentially long-running
# state in there
VOLUME /vault/file
# 8200/tcp is the primary interface that applications use to interact with
# Vault.
EXPOSE 8200
# The entry point script uses dumb-init as the top-level process to reap any
# zombie processes created by Vault sub-processes.
#
2023-08-17 19:47:32 -04:00
# For production derivatives of this container, you should add the IPC_LOCK
2021-12-06 11:06:22 -05:00
# capability so that Vault can mlock memory.
COPY .release/docker/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
ENTRYPOINT [ "docker-entrypoint.sh" ]
# # By default you'll get a single-node development server that stores everything
# # in RAM and bootstraps itself. Don't use this configuration for production.
CMD [ "server" , "-dev" ]
2022-05-13 11:21:15 -04:00
## UBI DOCKERFILE ##
2024-10-07 12:16:22 -04:00
FROM registry.access.redhat.com/ubi8/ubi-minimal AS ubi
2022-05-13 11:21:15 -04:00
ARG BIN_NAME
2024-08-21 13:33:48 -04:00
# NAME and PRODUCT_VERSION are the name of the software in releases.hashicorp.com
# and the version to download. Example: NAME=vault PRODUCT_VERSION=1.2.3.
ARG NAME = vault
2022-05-13 11:21:15 -04:00
ARG PRODUCT_VERSION
ARG PRODUCT_REVISION
# TARGETARCH and TARGETOS are set automatically when --platform is provided.
ARG TARGETOS TARGETARCH
# Additional metadata labels used by container registries, platforms
# and certification scanners.
LABEL name = "Vault" \
maintainer = "Vault Team <vault@hashicorp.com>" \
vendor = "HashiCorp" \
version = ${ PRODUCT_VERSION } \
release = ${ PRODUCT_REVISION } \
revision = ${ PRODUCT_REVISION } \
summary = "Vault is a tool for securely accessing secrets." \
description = "Vault is a tool for securely accessing secrets. A secret is anything that you want to tightly control access to, such as API keys, passwords, certificates, and more. Vault provides a unified interface to any secret, while providing tight access control and recording a detailed audit log."
# Set ARGs as ENV so that they can be used in ENTRYPOINT/CMD
ENV NAME = $NAME
ENV VERSION = $VERSION
2024-08-21 13:33:48 -04:00
# Copy the license file as per Legal requirement
COPY LICENSE /usr/share/doc/$NAME /LICENSE.txt
2024-08-29 11:14:09 -04:00
# We must have a copy of the license in this directory to comply with the HasLicense Redhat requirement
COPY LICENSE /licenses/LICENSE.txt
2022-05-13 11:21:15 -04:00
# Set up certificates, our base tools, and Vault. Unlike the other version of
# this (https://github.com/hashicorp/docker-vault/blob/master/ubi/Dockerfile),
# we copy in the Vault binary from CRT.
RUN set -eux; \
2024-10-07 12:16:22 -04:00
microdnf install -y ca-certificates gnupg openssl libcap tzdata procps shadow-utils util-linux tar
2022-05-13 11:21:15 -04:00
# Create a non-root user to run the software.
RUN groupadd --gid 1000 vault && \
adduser --uid 100 --system -g vault vault && \
usermod -a -G root vault
# Copy in the new Vault from CRT pipeline, rather than fetching it from our
# public releases.
COPY dist/$TARGETOS /$TARGETARCH /$BIN_NAME /bin/
# /vault/logs is made available to use as a location to store audit logs, if
# desired; /vault/file is made available to use as a location with the file
# storage backend, if desired; the server will be started with /vault/config as
# the configuration directory so you can add additional config files in that
# location.
2024-10-07 12:16:22 -04:00
ENV HOME = /home/vault
2022-05-13 11:21:15 -04:00
RUN mkdir -p /vault/logs && \
mkdir -p /vault/file && \
mkdir -p /vault/config && \
mkdir -p $HOME && \
chown -R vault /vault && chown -R vault $HOME && \
chgrp -R 0 $HOME && chmod -R g+rwX $HOME && \
chgrp -R 0 /vault && chmod -R g+rwX /vault
2024-10-07 12:16:22 -04:00
# Include EULA and Terms of Eval
RUN mkdir -p /usr/share/doc/vault && \
curl -o /usr/share/doc/vault/EULA.txt https://eula.hashicorp.com/EULA.txt && \
curl -o /usr/share/doc/vault/TermsOfEvaluation.txt https://eula.hashicorp.com/TermsOfEvaluation.txt
2022-05-13 11:21:15 -04:00
# Expose the logs directory as a volume since there's potentially long-running
# state in there
VOLUME /vault/logs
# Expose the file directory as a volume since there's potentially long-running
# state in there
VOLUME /vault/file
# 8200/tcp is the primary interface that applications use to interact with
# Vault.
EXPOSE 8200
# The entry point script uses dumb-init as the top-level process to reap any
# zombie processes created by Vault sub-processes.
#
2023-08-17 19:47:32 -04:00
# For production derivatives of this container, you should add the IPC_LOCK
2022-05-13 11:21:15 -04:00
# capability so that Vault can mlock memory.
2022-05-16 13:12:38 -04:00
COPY .release/docker/ubi-docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
ENTRYPOINT [ "docker-entrypoint.sh" ]
2022-05-13 11:21:15 -04:00
# Use the Vault user as the default user for starting this container.
USER vault
# # By default you'll get a single-node development server that stores everything
# # in RAM and bootstraps itself. Don't use this configuration for production.
CMD [ "server" , "-dev" ]
2024-10-07 12:16:22 -04:00
FROM ubi AS ubi-fips
FROM ubi AS ubi-hsm
FROM ubi AS ubi-hsm-fips