This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This repository provides a Docker image that combines Apache Tomcat with Let's Encrypt HTTPS certificates. It automates the conversion of Let's Encrypt PEM certificates to Java keystores (JKS) and dynamically configures Tomcat's server.xml using XSLT transformations.
The entrypoint script (entrypoint.sh) performs certificate conversion on container startup:
- Validates required environment variables (
LETSENCRYPT_CERT_DIR,PKCS12_PASSWORD,JKS_KEY_PASSWORD,JKS_STORE_PASSWORD) - Converts Let's Encrypt PEM certificates to PKCS12 format using OpenSSL
- Imports PKCS12 into Java Keystore (JKS) format using keytool
- Transforms Tomcat's
server.xmlconfiguration using XSLT - Starts Tomcat with
catalina.sh run
The letsencrypt-tomcat.xsl stylesheet dynamically modifies Tomcat's server.xml based on environment variables:
- HTTP Connector: Conditionally enabled/disabled, with proxy settings and compression
- HTTPS Connector: Adds SSL/TLS configuration with keystore settings when enabled
- RemoteIpValve: Optional configuration for X-Forwarded headers when behind a proxy
The XSLT transformation is executed by xsltproc with environment variables passed as string parameters.
docker build -t atomgraph/letsencrypt-tomcat .docker run \
-v /etc/letsencrypt:/etc/letsencrypt \
-e LETSENCRYPT_CERT_DIR=/etc/letsencrypt \
-e PKCS12_PASSWORD=<password> \
-e JKS_KEY_PASSWORD=<password> \
-e JKS_STORE_PASSWORD=<password> \
atomgraph/letsencrypt-tomcatTo test XSLT changes without building the full image:
xsltproc \
--stringparam http true \
--stringparam http.port 8080 \
--stringparam https true \
--stringparam https.port 8443 \
--stringparam https.keystoreFile letsencrypt.jks \
--stringparam https.keystorePass <password> \
--stringparam https.keyAlias letsencrypt \
--stringparam https.keyPass <password> \
letsencrypt-tomcat.xsl /path/to/server.xmlGitHub Actions workflow (.github/workflows/image.yml) triggers on git tags:
- Builds multi-platform images (linux/amd64, linux/arm64)
- Pushes to Docker Hub with tags:
latest,MAJOR.MINOR.PATCH,MAJOR.MINOR,MAJOR - Uses QEMU for cross-platform builds
- Dockerfile: Base image from
tomcat:10.1.34-jdk17, installs xsltproc - entrypoint.sh: Certificate conversion and Tomcat configuration script
- letsencrypt-tomcat.xsl: XSLT stylesheet for server.xml transformation
All configuration is done through environment variables. See README.md for the full list of supported variables for HTTP/HTTPS connectors.
Required variables:
LETSENCRYPT_CERT_DIR: Path to Let's Encrypt certificatesPKCS12_PASSWORD: Password for PKCS12 keystoreJKS_KEY_PASSWORD: Password for JKS keyJKS_STORE_PASSWORD: Password for JKS store
Parameters in the XSLT stylesheet use dot notation (e.g., Connector.port.http, Connector.keystoreFile.https), while the entrypoint script converts environment variables with underscores (e.g., HTTP_PORT, HTTPS_PORT) to the corresponding XSLT parameter names with dots and prefixes.