Lightweight, immutable bootstrap container that downloads, verifies, and executes encrypted scripts
215
A lightweight, secure, and immutable runtime bootstrap designed for modern Container-as-a-Service (CaaS) and cloud-native deployments.
Rather than embedding application logic, runtime binaries, or service configurations into Docker images, Secure Docker Bootstrap Loader dynamically provisions the execution environment by securely retrieving an encrypted payload from S3-compatible object storage or HTTPS, verifying its integrity, decrypting it locally, and executing it.
This architecture enables immutable infrastructure, allowing runtime behavior to evolve without rebuilding or republishing Docker images. The image itself remains static, while all deployment logic, provisioning scripts, and service initialization are managed externally through encrypted payloads.
Traditional Docker images typically package application binaries, runtime dependencies, configuration files, and startup logic directly into the image.
Any application update generally requires rebuilding and republishing the image.
This project follows a different philosophy.
The Docker image remains completely static and acts only as a secure runtime bootstrap loader.
At runtime it:
Everything elseβincluding application installation, runtime provisioning, configuration generation, package installation, and service startupβis delegated to the external payload.
This provides several advantages:
s3cmd integration for Cloudflare R2 and any S3-compatible storage provider./root/.s3cfg, allowing downstream scripts to reuse the same authenticated S3 session.exec for correct signal propagation and graceful container shutdown.debian:bookworm-slim with only essential runtime dependencies. Secure Docker Bootstrap Loader
βββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Immutable Docker Image β
βββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
Validate Runtime Environment
β
βΌ
Generate Global S3 Configuration (/root/.s3cfg)
β
βΌ
Fetch Encrypted Payload
ββββββββββββββββββ¬βββββββββββββββββββββββ
β β β
βΌ βΌ βΌ
Native S3 API Cloudflare R2 HTTPS Fallback
β
βΌ
script.enc (Encrypted)
β
βΌ
SHA-256 Integrity Verification
β
βΌ
AES-256-CBC Decryption (PBKDF2)
β
βΌ
CRLF Sanitization (Windows Safe)
β
βΌ
/tmp/script.sh (Runtime)
β
βΌ
Replace PID 1 via exec()
β
βΌ
External Runtime Provisioning
βββ Install packages
βββ Download additional assets
βββ Configure services
βββ Generate runtime configuration
βββ Initialize applications
βββ Start custom services
| Variable | Required | Description |
|---|---|---|
S3_ENDPOINT | Yes | S3-compatible endpoint (Cloudflare R2, MinIO, AWS S3, etc.). |
S3_BUCKET | Yes | Bucket Name |
S3_BASE_KEY | Yes | S3 Base Key (folder of project in s3) |
S3_ACCESS_KEY | Yes | S3 Access Key ID |
S3_SECRET_KEY | Yes | S3 Secret Access Key |
| Variable | Required | Description |
|---|---|---|
DECRYPT_KEY | Yes | Password used to decrypt the payload. |
SCRIPT_FILE | Optional | Script file name for run in the start (if not set, default = script.enc ). |
SCRIPT_HASH | Optional | SHA-256 checksum used for integrity verification. |
SCRIPT_URL | Alternative | HTTPS URL used only when S3 configuration is not provided. |
DEBUG | Optional | Set to true to enable verbose shell tracing (set -x). |
Container Starts
β
βΌ
Validate Environment Variables
β
βΌ
Configure S3 (Optional)
β
βΌ
Download Encrypted Payload
β
βΌ
Verify SHA-256 Integrity
β
βΌ
Decrypt Payload
β
βΌ
Normalize Line Endings
β
βΌ
Execute Runtime Script
β
βΌ
Provision Runtime Environment
docker run --rm \
-e S3_ENDPOINT="your_account_id.r2.cloudflarestorage.com" \
-e S3_BUCKET="your-bucket" \
-e S3_BASE_KEY="bootstrap" \
-e S3_ACCESS_KEY="your_access_key" \
-e S3_SECRET_KEY="your_secret_key" \
-e DECRYPT_KEY="your_strong_password" \
-e SCRIPT_HASH="your_sha256_checksum" \
yourusername/secure-docker-bootstrap:1.0.0
docker run --rm \
-e SCRIPT_URL="[https://example.com/script.enc](https://example.com/script.enc)" \
-e DECRYPT_KEY="your_strong_password" \
-e SCRIPT_HASH="your_sha256_checksum" \
yourusername/secure-docker-bootstrap:1.0.0
Generate an encrypted deployment script using OpenSSL:
openssl enc \
-aes-256-cbc \
-pbkdf2 \
-iter 10000 \
-in script.sh \
-out script.enc \
-k "your_strong_password"
Generate the SHA-256 checksum:
Linux:
sha256sum script.enc
Windows PowerShell:
Get-FileHash script.enc -Algorithm SHA256
Use the generated checksum as the value of the SCRIPT_HASH environment variable.
1.0.0) in production.DECRYPT_KEY securely using your CaaS secret management system.The Docker image should know as little as possible.
Its only responsibility is to securely bootstrap the runtime environment.
All application logic, deployment scripts, package installation, service initialization, and runtime configuration belong outside the image in encrypted payloads.
This keeps the image immutable, minimizes maintenance overhead, improves portability, and allows deployment behavior to evolve without rebuilding or republishing Docker images.
Content type
Image
Digest
sha256:1d7b02b40β¦
Size
45.1 MB
Last updated
about 1 month ago
docker pull javidi/secure-docker-bootstrap