Docker: automatic SSL with a self-signed certificate, reused if present

docker-entrypoint.sh uses the given SSL_CERTFILE/SSL_KEYFILE, or the
certificate in the electrumx-ssl volume, and generates a self-signed one
(10 years) only when none exists, never overwriting it, as clients pin it.
It also sets SERVICES (tcp 50001 + ssl 50002). SSL is on by default.

Documented in README.md and DEPLOY.md.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
davideandClaude Sonnet 5.5 committed 2026-10-22 15:23:29 +02:00
1 parent 3e5d005efe
commit c2dcff5cc8
7 files changed
+173 -29

No files matched your search

+11 -7
View File
@@ -24,14 +24,14 @@ RUN python -m venv venv \
FROM python:3.14-slim-trixie
# the libs needed by rocksdb (no development headers or statics)
RUN apt-get update && apt-get -y --no-install-recommends install librocksdb9.10 && rm -rf /var/lib/apt/lists/*
# the libs needed by rocksdb (no development headers or statics), and openssl to generate the SSL certificate
RUN apt-get update && apt-get -y --no-install-recommends install librocksdb9.10 openssl && rm -rf /var/lib/apt/lists/*
ENV COIN=Palladium
ENV NET=mainnet
ENV DB_ENGINE=rocksdb
ENV DB_DIRECTORY=/var/lib/electrumx
ENV SERVICES="tcp://:50001"
# SERVICES is set by docker-entrypoint.sh (tcp://:50001 and, with SSL, ssl://:50002), see there for the SSL settings.
# set at run time, see docker-compose.yml:
#ENV DAEMON_URL="http://user:password@palladiumd:2332/"
#ENV CACHE_MB=2000
@@ -39,14 +39,18 @@ ENV SERVICES="tcp://:50001"
WORKDIR /usr/src/app
COPY --from=builder /usr/src/app/venv ./venv
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
# the data directory is created here so that an empty volume is owned by the electrumx user
# the data directories are created here so that empty volumes are owned by the electrumx user
RUN useradd --create-home --uid 1000 electrumx \
&& mkdir -p "$DB_DIRECTORY" && chown electrumx:electrumx "$DB_DIRECTORY"
&& mkdir -p "$DB_DIRECTORY" /var/lib/electrumx-ssl \
&& chown electrumx:electrumx "$DB_DIRECTORY" /var/lib/electrumx-ssl
USER electrumx
VOLUME /var/lib/electrumx
VOLUME /var/lib/electrumx-ssl
# 50001: Electrum protocol over TCP.
EXPOSE 50001
# 50001: Electrum protocol over TCP, 50002: over SSL.
EXPOSE 50001 50002
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
CMD ["/usr/src/app/venv/bin/electrumx_server"]