This commit is contained in:
Cem Aydin committed 2026-10-21 15:21:20 +02:00
commit b9f975dc03
6 files changed
+256

No files matched your search

+38
View File
@@ -0,0 +1,38 @@
# GNU Taler merchant backend
#
# Installation follows the Merchant Backend Operator Manual:
# https://docs.taler.net/taler-merchant-manual.html#installing-the-gnu-taler-binary-packages-on-debian
#
# The packages are built for Debian trixie, so that is the base image.
FROM debian:trixie-slim
ENV DEBIAN_FRONTEND=noninteractive
# Tools needed to import the Taler Systems SA signing key
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
wget \
&& rm -rf /var/lib/apt/lists/*
# Import the Taler Systems SA public package signing key
RUN mkdir -p /etc/apt/keyrings \
&& wget -O /etc/apt/keyrings/taler-systems.gpg \
https://taler.net/taler-systems.gpg
# Add the GNU Taler package repository and install the merchant backend
RUN echo "deb [signed-by=/etc/apt/keyrings/taler-systems.gpg] https://deb.taler.net/apt/debian trixie main" \
> /etc/apt/sources.list.d/taler.list \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
postgresql-client \
taler-merchant \
&& rm -rf /var/lib/apt/lists/*
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod 0755 /usr/local/bin/entrypoint.sh
# Default TCP port of taler-merchant-httpd (see [merchant]/PORT)
EXPOSE 9966
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
+68
View File
@@ -0,0 +1,68 @@
#!/bin/sh
# Entrypoint for the GNU Taler merchant backend container.
#
# Renders the configuration from environment variables, initializes the
# PostgreSQL database schema, and starts the backend HTTP service plus the
# auxiliary daemons that the systemd taler-merchant.target would normally
# run (see Merchant Backend Operator Manual, section "Launching the backend"):
# https://docs.taler.net/taler-merchant-manual.html#launching-the-backend
set -eu
MAIN_CONFIG="/etc/taler-merchant/taler-merchant.conf"
OVERRIDES="/etc/taler-merchant/merchant-overrides.conf"
MERCHANT_PORT="${TALER_MERCHANT_PORT:-9966}"
MERCHANT_CURRENCY="${TALER_MERCHANT_CURRENCY:-KUDOS}"
DB_CONFIG="${TALER_MERCHANT_DB:-postgres:///taler-merchant}"
# The Debian package runs the backend as a dedicated user.
RUN_USER="$(getent passwd | awk -F: '$1 ~ /^taler-merchant/ {print $1; exit}')"
RUN_USER="${RUN_USER:-taler-merchant-httpd}"
RUN_GROUP="$(id -gn "$RUN_USER")"
# Render the package overrides: service address, currency and database.
cat > "$OVERRIDES" <<EOF
# Generated by the container entrypoint - do not edit.
# Configure via the TALER_MERCHANT_* environment variables instead.
[merchant]
SERVE = tcp
PORT = ${MERCHANT_PORT}
CURRENCY = ${MERCHANT_CURRENCY}
DATABASE = postgres
[merchantdb-postgres]
CONFIG = ${DB_CONFIG}
EOF
# Make sure the shipped main configuration includes the overrides.
if ! grep -q "merchant-overrides.conf" "$MAIN_CONFIG"; then
printf '@INLINE@ %s\n' "$OVERRIDES" >> "$MAIN_CONFIG"
fi
# Initialize the database schema. Safe to re-run: existing databases are
# preserved unless the tool is invoked with -r (which we never do).
# Retries because the postgres container may still be starting up.
echo "Initializing the merchant database schema..."
try=0
until setpriv --reuid="$RUN_USER" --regid="$RUN_GROUP" --init-groups \
taler-merchant-dbinit -c "$MAIN_CONFIG"; do
try=$((try + 1))
if [ "$try" -ge 30 ]; then
echo "ERROR: could not initialize the merchant database" >&2
exit 1
fi
echo " attempt ${try} failed, retrying in 2 s ..."
sleep 2
done
# Start the auxiliary daemons (background; normally systemd units).
for daemon in webhook wirewatch depositcheck exchangekeyupdate reconciliation kyccheck; do
if command -v "taler-merchant-${daemon}" > /dev/null 2>&1; then
setpriv --reuid="$RUN_USER" --regid="$RUN_GROUP" --init-groups \
"taler-merchant-${daemon}" -c "$MAIN_CONFIG" &
fi
done
echo "Starting taler-merchant-httpd on port ${MERCHANT_PORT} ..."
exec setpriv --reuid="$RUN_USER" --regid="$RUN_GROUP" --init-groups \
taler-merchant-httpd -c "$MAIN_CONFIG" "$@"