diff --git a/bitnami/couchdb/3/debian-12/Dockerfile b/bitnami/couchdb/3/debian-12/Dockerfile index b54d87819299..203d0e99d653 100644 --- a/bitnami/couchdb/3/debian-12/Dockerfile +++ b/bitnami/couchdb/3/debian-12/Dockerfile @@ -7,7 +7,7 @@ ARG DOWNLOADS_URL="downloads.bitnami.com/files/stacksmith" ARG TARGETARCH LABEL org.opencontainers.image.base.name="docker.io/bitnami/minideb:bookworm" \ - org.opencontainers.image.created="2026-04-29T00:29:57Z" \ + org.opencontainers.image.created="2026-05-05T07:12:11Z" \ org.opencontainers.image.description="Application packaged by Broadcom, Inc." \ org.opencontainers.image.documentation="https://github.com/bitnami/containers/tree/main/bitnami/couchdb/README.md" \ org.opencontainers.image.source="https://github.com/bitnami/containers/tree/main/bitnami/couchdb" \ @@ -51,7 +51,7 @@ COPY rootfs / RUN /opt/bitnami/scripts/couchdb/postunpack.sh ENV APP_VERSION="3.5.1" \ BITNAMI_APP_NAME="couchdb" \ - IMAGE_REVISION="21" \ + IMAGE_REVISION="22" \ LD_LIBRARY_PATH="/opt/bitnami/common/lib:$LD_LIBRARY_PATH" \ PATH="/opt/bitnami/common/bin:/opt/bitnami/erlang/bin:/opt/bitnami/couchdb/bin:$PATH" diff --git a/bitnami/couchdb/3/debian-12/rootfs/opt/bitnami/scripts/couchdb-env.sh b/bitnami/couchdb/3/debian-12/rootfs/opt/bitnami/scripts/couchdb-env.sh index e3f675d77ebb..e87cc21a6833 100644 --- a/bitnami/couchdb/3/debian-12/rootfs/opt/bitnami/scripts/couchdb-env.sh +++ b/bitnami/couchdb/3/debian-12/rootfs/opt/bitnami/scripts/couchdb-env.sh @@ -29,6 +29,7 @@ couchdb_env_vars=( COUCHDB_CLUSTER_PORT_NUMBER COUCHDB_BIND_ADDRESS COUCHDB_CREATE_DATABASES + COUCHDB_IGNORE_INITDB_SCRIPTS COUCHDB_USER COUCHDB_PASSWORD COUCHDB_SECRET @@ -53,6 +54,7 @@ export COUCHDB_BIN_DIR="${COUCHDB_BASE_DIR}/bin" export COUCHDB_CONF_DIR="${COUCHDB_BASE_DIR}/etc" export COUCHDB_CONF_FILE="${COUCHDB_CONF_DIR}/default.d/10-bitnami.ini" export COUCHDB_DATA_DIR="${COUCHDB_VOLUME_DIR}/data" +export COUCHDB_INITSCRIPTS_DIR="/docker-entrypoint-initdb.d" # System users (when running with a privileged user) export COUCHDB_DAEMON_USER="couchdb" @@ -65,6 +67,7 @@ export COUCHDB_PORT_NUMBER="${COUCHDB_PORT_NUMBER:-}" export COUCHDB_CLUSTER_PORT_NUMBER="${COUCHDB_CLUSTER_PORT_NUMBER:-}" export COUCHDB_BIND_ADDRESS="${COUCHDB_BIND_ADDRESS:-}" export COUCHDB_CREATE_DATABASES="${COUCHDB_CREATE_DATABASES:-yes}" +export COUCHDB_IGNORE_INITDB_SCRIPTS="${COUCHDB_IGNORE_INITDB_SCRIPTS:-no}" export COUCHDB_USER="${COUCHDB_USER:-admin}" export COUCHDB_PASSWORD="${COUCHDB_PASSWORD:-couchdb}" export COUCHDB_SECRET="${COUCHDB_SECRET:-bitnami}" diff --git a/bitnami/couchdb/3/debian-12/rootfs/opt/bitnami/scripts/libcouchdb.sh b/bitnami/couchdb/3/debian-12/rootfs/opt/bitnami/scripts/libcouchdb.sh index 89b082a9f78f..266684d69992 100644 --- a/bitnami/couchdb/3/debian-12/rootfs/opt/bitnami/scripts/libcouchdb.sh +++ b/bitnami/couchdb/3/debian-12/rootfs/opt/bitnami/scripts/libcouchdb.sh @@ -96,8 +96,9 @@ couchdb_initialize() { if is_boolean_yes "$COUCHDB_CREATE_DATABASES"; then couchdb_start_bg couchdb_create_initial_databases - couchdb_stop fi + couchdb_run_init_scripts + is_couchdb_running && couchdb_stop else info "Deploying CouchDB with persisted data" fi @@ -236,6 +237,55 @@ couchdb_create_initial_databases() { done } +######################## +# Run custom init scripts from COUCHDB_INITSCRIPTS_DIR on first boot +# Globals: +# COUCHDB_INITSCRIPTS_DIR +# COUCHDB_IGNORE_INITDB_SCRIPTS +# COUCHDB_DATA_DIR +# Arguments: +# None +# Returns: +# None +######################### +couchdb_run_init_scripts() { + local -r semaphore="${COUCHDB_DATA_DIR}/.user_scripts_initialized" + + if is_boolean_yes "${COUCHDB_IGNORE_INITDB_SCRIPTS:-no}"; then + info "Skipping init scripts (COUCHDB_IGNORE_INITDB_SCRIPTS=yes)" + return + fi + + if [[ -f "$semaphore" ]]; then + info "Init scripts already executed, skipping..." + return + fi + + local -a scripts + readarray -d '' scripts < <(find "${COUCHDB_INITSCRIPTS_DIR}/" -type f -name "*.sh" -print0 2>/dev/null | sort -z) + if [[ "${#scripts[@]}" -eq 0 ]]; then + return + fi + + info "Loading user's custom files from ${COUCHDB_INITSCRIPTS_DIR} ..." + if ! is_couchdb_running; then + couchdb_start_bg + fi + + for f in "${scripts[@]}"; do + if [[ -x "$f" ]]; then + debug "Executing $f" + "$f" + else + debug "Sourcing $f" + # shellcheck disable=SC1090 + . "$f" + fi + done + + touch "$semaphore" +} + ######################## # Check if CouchDB is running # Globals: diff --git a/bitnami/couchdb/README.md b/bitnami/couchdb/README.md index e1f8bbbf9da5..bee6df745e6e 100644 --- a/bitnami/couchdb/README.md +++ b/bitnami/couchdb/README.md @@ -76,29 +76,31 @@ The following tables list the main variables you can set. #### Customizable environment variables -| Name | Description | Default Value | -|-------------------------------|------------------------------------------------------------------------------------------|---------------| -| `COUCHDB_NODENAME` | Name of the CouchDB node. | `nil` | -| `COUCHDB_PORT_NUMBER` | Port number used by CouchDB. | `nil` | -| `COUCHDB_CLUSTER_PORT_NUMBER` | Port number used by CouchDB for clustering. | `nil` | -| `COUCHDB_BIND_ADDRESS` | Address to which the CouchDB process will bind to. | `nil` | -| `COUCHDB_CREATE_DATABASES` | Whether to create CouchDB system databases during initialization. Useful for clustering. | `yes` | -| `COUCHDB_USER` | CouchDB admin username. | `admin` | -| `COUCHDB_PASSWORD` | Password for the CouchDB admin user. | `couchdb` | -| `COUCHDB_SECRET` | CouchDB secret/token used for proxy and cookie authentication. | `bitnami` | +| Name | Description | Default Value | +|---------------------------------|-------------------------------------------------------------------------------------------------------|---------------| +| `COUCHDB_NODENAME` | Name of the CouchDB node. | `nil` | +| `COUCHDB_PORT_NUMBER` | Port number used by CouchDB. | `nil` | +| `COUCHDB_CLUSTER_PORT_NUMBER` | Port number used by CouchDB for clustering. | `nil` | +| `COUCHDB_BIND_ADDRESS` | Address to which the CouchDB process will bind to. | `nil` | +| `COUCHDB_CREATE_DATABASES` | Whether to create CouchDB system databases during initialization. Useful for clustering. | `yes` | +| `COUCHDB_IGNORE_INITDB_SCRIPTS` | Skip execution of init scripts from COUCHDB_INITSCRIPTS_DIR. Set to yes on non-primary cluster nodes. | `no` | +| `COUCHDB_USER` | CouchDB admin username. | `admin` | +| `COUCHDB_PASSWORD` | Password for the CouchDB admin user. | `couchdb` | +| `COUCHDB_SECRET` | CouchDB secret/token used for proxy and cookie authentication. | `bitnami` | #### Read-only environment variables -| Name | Description | Value | -|------------------------|-------------------------------------------|------------------------------------------------| -| `COUCHDB_BASE_DIR` | CouchDB installation directory. | `${BITNAMI_ROOT_DIR}/couchdb` | -| `COUCHDB_VOLUME_DIR` | CouchDB persistence directory. | `/bitnami/couchdb` | -| `COUCHDB_BIN_DIR` | CouchDB directory for binary executables. | `${COUCHDB_BASE_DIR}/bin` | -| `COUCHDB_CONF_DIR` | CouchDB configuration directory. | `${COUCHDB_BASE_DIR}/etc` | -| `COUCHDB_CONF_FILE` | CouchDB configuration file. | `${COUCHDB_CONF_DIR}/default.d/10-bitnami.ini` | -| `COUCHDB_DATA_DIR` | CouchDB directory where data is stored. | `${COUCHDB_VOLUME_DIR}/data` | -| `COUCHDB_DAEMON_USER` | CouchDB system user. | `couchdb` | -| `COUCHDB_DAEMON_GROUP` | CouchDB system group. | `couchdb` | +| Name | Description | Value | +|---------------------------|--------------------------------------------------------------------------|------------------------------------------------| +| `COUCHDB_BASE_DIR` | CouchDB installation directory. | `${BITNAMI_ROOT_DIR}/couchdb` | +| `COUCHDB_VOLUME_DIR` | CouchDB persistence directory. | `/bitnami/couchdb` | +| `COUCHDB_BIN_DIR` | CouchDB directory for binary executables. | `${COUCHDB_BASE_DIR}/bin` | +| `COUCHDB_CONF_DIR` | CouchDB configuration directory. | `${COUCHDB_BASE_DIR}/etc` | +| `COUCHDB_CONF_FILE` | CouchDB configuration file. | `${COUCHDB_CONF_DIR}/default.d/10-bitnami.ini` | +| `COUCHDB_DATA_DIR` | CouchDB directory where data is stored. | `${COUCHDB_VOLUME_DIR}/data` | +| `COUCHDB_INITSCRIPTS_DIR` | Path to directory containing custom init scripts executed on first boot. | `/docker-entrypoint-initdb.d` | +| `COUCHDB_DAEMON_USER` | CouchDB system user. | `couchdb` | +| `COUCHDB_DAEMON_GROUP` | CouchDB system group. | `couchdb` | ### Mounting your own configuration files