feat: restructure ht-docker-tools repository with enhanced Deno support and NVM integration

- Removed Dockerfile and added multiple Dockerfiles for various tools (ClickHouse, MongoDB, MinIO, Caddy, Redis) with Deno runtime.
- Updated package.json to reflect new repository structure and versioning.
- Added comprehensive README and technical notes for architecture overview and usage.
- Implemented build and test scripts for streamlined image creation and validation.
- Introduced bash scripts for NVM functionality in Docker images.
This commit is contained in:
2025-11-27 13:10:00 +00:00
parent 7356e07410
commit a15dc3f672
19 changed files with 1006 additions and 21 deletions

View File

@@ -1,11 +0,0 @@
FROM clickhouse/clickhouse-server
# Install Node.js and ClickHouse
RUN apt-get update \
&& apt-get install -y curl gnupg2 \
&& curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
&& apt-get update \
&& apt-get install -y nodejs
# Verify Node.js and npm installation
RUN node -v && npm -v

8
Dockerfile_caddy Normal file
View File

@@ -0,0 +1,8 @@
FROM caddy:latest
LABEL author="Task Venture Capital GmbH <hello@task.vc>"
# Caddy uses Alpine base, install Deno from Alpine edge
RUN apk add --no-cache --repository=https://dl-cdn.alpinelinux.org/alpine/edge/community deno
# Verify Deno installation
RUN deno --version

59
Dockerfile_caddy_alpine Normal file
View File

@@ -0,0 +1,59 @@
FROM alpine:edge
LABEL author="Task Venture Capital GmbH <hello@task.vc>"
WORKDIR /workspace
# Environment variables for NVM and Node.js
ENV NODE_VERSION_LTS="20.18.2" \
NVM_DIR="/usr/local/nvm" \
NVM_NODEJS_ORG_MIRROR="https://unofficial-builds.nodejs.org/download/release"
# Install required packages including Caddy and Deno
RUN apk add --no-cache \
bash \
curl \
git \
ca-certificates \
unzip \
libstdc++ \
deno \
caddy
# Create Caddy directories
RUN mkdir -p /etc/caddy /data /config
# Install NVM (latest version for better Alpine/musl support)
RUN mkdir -p $NVM_DIR && curl https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
# Make nvm available globally in all bash shells (interactive + non-interactive)
RUN printf '%s\n%s\n%s\n' \
'export NVM_DIR="/usr/local/nvm"' \
'[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"' \
'[ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion"' \
> /etc/bash.bashrc
# Copy nvm wrapper scripts
COPY image_support_files/bash-with-nvm /usr/local/bin/bash-with-nvm
COPY image_support_files/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod +x /usr/local/bin/bash-with-nvm /usr/local/bin/docker-entrypoint.sh
# Use wrapper for RUN commands to enable nvm
SHELL ["/usr/local/bin/bash-with-nvm"]
# Enable nvm for runtime bash commands (CI/CD workflows)
ENV BASH_ENV=/etc/bash.bashrc
# Install Node.js LTS via NVM
RUN nvm install $NODE_VERSION_LTS \
&& nvm alias default $NODE_VERSION_LTS \
&& nvm use default
ENV PATH="$NVM_DIR/versions/node/v$NODE_VERSION_LTS/bin:$PATH"
ENV NODE_PATH=$NVM_DIR/v$NODE_VERSION_LTS/lib/node_modules
# Expose Caddy ports
EXPOSE 80 443 2019
# Set entrypoint to make nvm available in all runtime contexts
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
CMD ["caddy", "run", "--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile"]

15
Dockerfile_clickhouse Normal file
View File

@@ -0,0 +1,15 @@
FROM clickhouse/clickhouse-server
LABEL author="Task Venture Capital GmbH <hello@task.vc>"
# Install Deno runtime for scripting/automation
RUN apt-get update \
&& apt-get install -y curl unzip ca-certificates \
&& curl -fsSL https://deno.land/install.sh | sh \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
ENV DENO_INSTALL="/root/.deno"
ENV PATH="$DENO_INSTALL/bin:$PATH"
# Verify Deno installation
RUN deno --version

View File

@@ -0,0 +1,53 @@
FROM alpine:edge
LABEL author="Task Venture Capital GmbH <hello@task.vc>"
WORKDIR /workspace
# Environment variables for NVM and Node.js
ENV NODE_VERSION_LTS="20.18.2" \
NVM_DIR="/usr/local/nvm" \
NVM_NODEJS_ORG_MIRROR="https://unofficial-builds.nodejs.org/download/release"
# Install required packages including ClickHouse and Deno
RUN apk add --no-cache \
bash \
curl \
git \
ca-certificates \
unzip \
libstdc++ \
deno \
clickhouse
# Install NVM (latest version for better Alpine/musl support)
RUN mkdir -p $NVM_DIR && curl https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
# Make nvm available globally in all bash shells (interactive + non-interactive)
RUN printf '%s\n%s\n%s\n' \
'export NVM_DIR="/usr/local/nvm"' \
'[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"' \
'[ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion"' \
> /etc/bash.bashrc
# Copy nvm wrapper scripts
COPY image_support_files/bash-with-nvm /usr/local/bin/bash-with-nvm
COPY image_support_files/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod +x /usr/local/bin/bash-with-nvm /usr/local/bin/docker-entrypoint.sh
# Use wrapper for RUN commands to enable nvm
SHELL ["/usr/local/bin/bash-with-nvm"]
# Enable nvm for runtime bash commands (CI/CD workflows)
ENV BASH_ENV=/etc/bash.bashrc
# Install Node.js LTS via NVM
RUN nvm install $NODE_VERSION_LTS \
&& nvm alias default $NODE_VERSION_LTS \
&& nvm use default
ENV PATH="$NVM_DIR/versions/node/v$NODE_VERSION_LTS/bin:$PATH"
ENV NODE_PATH=$NVM_DIR/v$NODE_VERSION_LTS/lib/node_modules
# Set entrypoint to make nvm available in all runtime contexts
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
CMD ["clickhouse-server"]

17
Dockerfile_minio Normal file
View File

@@ -0,0 +1,17 @@
FROM minio/minio:latest
LABEL author="Task Venture Capital GmbH <hello@task.vc>"
USER root
# MinIO uses a minimal base, install required packages
RUN microdnf install -y curl unzip ca-certificates \
&& curl -fsSL https://deno.land/install.sh | sh \
&& microdnf clean all
ENV DENO_INSTALL="/root/.deno"
ENV PATH="$DENO_INSTALL/bin:$PATH"
# Verify Deno installation
RUN deno --version
USER minio

56
Dockerfile_minio_alpine Normal file
View File

@@ -0,0 +1,56 @@
FROM alpine:edge
LABEL author="Task Venture Capital GmbH <hello@task.vc>"
WORKDIR /workspace
# Environment variables for NVM and Node.js
ENV NODE_VERSION_LTS="20.18.2" \
NVM_DIR="/usr/local/nvm" \
NVM_NODEJS_ORG_MIRROR="https://unofficial-builds.nodejs.org/download/release"
# Install required packages including MinIO and Deno
RUN apk add --no-cache \
bash \
curl \
git \
ca-certificates \
unzip \
libstdc++ \
deno \
minio
# Create MinIO data directory
RUN mkdir -p /data && chmod 777 /data
# Install NVM (latest version for better Alpine/musl support)
RUN mkdir -p $NVM_DIR && curl https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
# Make nvm available globally in all bash shells (interactive + non-interactive)
RUN printf '%s\n%s\n%s\n' \
'export NVM_DIR="/usr/local/nvm"' \
'[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"' \
'[ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion"' \
> /etc/bash.bashrc
# Copy nvm wrapper scripts
COPY image_support_files/bash-with-nvm /usr/local/bin/bash-with-nvm
COPY image_support_files/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod +x /usr/local/bin/bash-with-nvm /usr/local/bin/docker-entrypoint.sh
# Use wrapper for RUN commands to enable nvm
SHELL ["/usr/local/bin/bash-with-nvm"]
# Enable nvm for runtime bash commands (CI/CD workflows)
ENV BASH_ENV=/etc/bash.bashrc
# Install Node.js LTS via NVM
RUN nvm install $NODE_VERSION_LTS \
&& nvm alias default $NODE_VERSION_LTS \
&& nvm use default
ENV PATH="$NVM_DIR/versions/node/v$NODE_VERSION_LTS/bin:$PATH"
ENV NODE_PATH=$NVM_DIR/v$NODE_VERSION_LTS/lib/node_modules
# Set entrypoint to make nvm available in all runtime contexts
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
CMD ["minio", "server", "/data"]

15
Dockerfile_mongodb Normal file
View File

@@ -0,0 +1,15 @@
FROM mongo:latest
LABEL author="Task Venture Capital GmbH <hello@task.vc>"
# Install Deno runtime for scripting/automation
RUN apt-get update \
&& apt-get install -y curl unzip ca-certificates \
&& curl -fsSL https://deno.land/install.sh | sh \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
ENV DENO_INSTALL="/root/.deno"
ENV PATH="$DENO_INSTALL/bin:$PATH"
# Verify Deno installation
RUN deno --version

57
Dockerfile_mongodb_alpine Normal file
View File

@@ -0,0 +1,57 @@
FROM alpine:edge
LABEL author="Task Venture Capital GmbH <hello@task.vc>"
WORKDIR /workspace
# Environment variables for NVM and Node.js
ENV NODE_VERSION_LTS="20.18.2" \
NVM_DIR="/usr/local/nvm" \
NVM_NODEJS_ORG_MIRROR="https://unofficial-builds.nodejs.org/download/release"
# Install required packages including MongoDB and Deno
RUN apk add --no-cache \
bash \
curl \
git \
ca-certificates \
unzip \
libstdc++ \
deno \
mongodb \
mongodb-tools
# Create MongoDB data directory
RUN mkdir -p /data/db && chmod 777 /data/db
# Install NVM (latest version for better Alpine/musl support)
RUN mkdir -p $NVM_DIR && curl https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
# Make nvm available globally in all bash shells (interactive + non-interactive)
RUN printf '%s\n%s\n%s\n' \
'export NVM_DIR="/usr/local/nvm"' \
'[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"' \
'[ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion"' \
> /etc/bash.bashrc
# Copy nvm wrapper scripts
COPY image_support_files/bash-with-nvm /usr/local/bin/bash-with-nvm
COPY image_support_files/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod +x /usr/local/bin/bash-with-nvm /usr/local/bin/docker-entrypoint.sh
# Use wrapper for RUN commands to enable nvm
SHELL ["/usr/local/bin/bash-with-nvm"]
# Enable nvm for runtime bash commands (CI/CD workflows)
ENV BASH_ENV=/etc/bash.bashrc
# Install Node.js LTS via NVM
RUN nvm install $NODE_VERSION_LTS \
&& nvm alias default $NODE_VERSION_LTS \
&& nvm use default
ENV PATH="$NVM_DIR/versions/node/v$NODE_VERSION_LTS/bin:$PATH"
ENV NODE_PATH=$NVM_DIR/v$NODE_VERSION_LTS/lib/node_modules
# Set entrypoint to make nvm available in all runtime contexts
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
CMD ["mongod"]

15
Dockerfile_redis Normal file
View File

@@ -0,0 +1,15 @@
FROM redis:latest
LABEL author="Task Venture Capital GmbH <hello@task.vc>"
# Install Deno runtime for scripting/automation
RUN apt-get update \
&& apt-get install -y curl unzip ca-certificates \
&& curl -fsSL https://deno.land/install.sh | sh \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
ENV DENO_INSTALL="/root/.deno"
ENV PATH="$DENO_INSTALL/bin:$PATH"
# Verify Deno installation
RUN deno --version

59
Dockerfile_redis_alpine Normal file
View File

@@ -0,0 +1,59 @@
FROM alpine:edge
LABEL author="Task Venture Capital GmbH <hello@task.vc>"
WORKDIR /workspace
# Environment variables for NVM and Node.js
ENV NODE_VERSION_LTS="20.18.2" \
NVM_DIR="/usr/local/nvm" \
NVM_NODEJS_ORG_MIRROR="https://unofficial-builds.nodejs.org/download/release"
# Install required packages including Redis and Deno
RUN apk add --no-cache \
bash \
curl \
git \
ca-certificates \
unzip \
libstdc++ \
deno \
redis
# Create Redis data directory
RUN mkdir -p /data && chmod 777 /data
# Install NVM (latest version for better Alpine/musl support)
RUN mkdir -p $NVM_DIR && curl https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
# Make nvm available globally in all bash shells (interactive + non-interactive)
RUN printf '%s\n%s\n%s\n' \
'export NVM_DIR="/usr/local/nvm"' \
'[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"' \
'[ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion"' \
> /etc/bash.bashrc
# Copy nvm wrapper scripts
COPY image_support_files/bash-with-nvm /usr/local/bin/bash-with-nvm
COPY image_support_files/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod +x /usr/local/bin/bash-with-nvm /usr/local/bin/docker-entrypoint.sh
# Use wrapper for RUN commands to enable nvm
SHELL ["/usr/local/bin/bash-with-nvm"]
# Enable nvm for runtime bash commands (CI/CD workflows)
ENV BASH_ENV=/etc/bash.bashrc
# Install Node.js LTS via NVM
RUN nvm install $NODE_VERSION_LTS \
&& nvm alias default $NODE_VERSION_LTS \
&& nvm use default
ENV PATH="$NVM_DIR/versions/node/v$NODE_VERSION_LTS/bin:$PATH"
ENV NODE_PATH=$NVM_DIR/v$NODE_VERSION_LTS/lib/node_modules
# Expose Redis port
EXPOSE 6379
# Set entrypoint to make nvm available in all runtime contexts
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
CMD ["redis-server"]

130
build-images.sh Normal file
View File

@@ -0,0 +1,130 @@
#!/bin/bash
set -e
echo "Building ht-docker-tools Images"
echo "================================"
echo ""
# Color codes
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m' # No Color
# Check if buildx is available
if ! docker buildx version &> /dev/null; then
echo -e "${YELLOW}Warning: docker buildx not found. Installing...${NC}"
docker buildx create --use
fi
# Ensure buildx builder is running
echo -e "${BLUE}Setting up buildx builder...${NC}"
if ! docker buildx inspect default-builder &> /dev/null; then
docker buildx create --name default-builder --use
else
docker buildx use default-builder
fi
echo -e "${GREEN}Buildx ready${NC}"
echo ""
# Build function for single platform (for local testing)
build_native_image() {
local dockerfile=$1
local tag=$2
local description=$3
local platform=$(uname -m)
# Convert platform name
if [ "$platform" = "x86_64" ]; then
platform="linux/amd64"
elif [ "$platform" = "aarch64" ] || [ "$platform" = "arm64" ]; then
platform="linux/arm64"
fi
echo -e "${BLUE}Building: ${NC}${description}"
echo -e "${YELLOW} Dockerfile: ${NC}${dockerfile}"
echo -e "${YELLOW} Tag: ${NC}${tag}"
echo -e "${YELLOW} Platform: ${NC}${platform} (native)"
if docker buildx build \
--platform "${platform}" \
-f "${dockerfile}" \
-t "${tag}" \
--load \
.; then
echo -e "${GREEN}Success: ${NC}${tag} (${platform})"
echo ""
else
echo -e "${RED}Failed: ${NC}${tag}"
exit 1
fi
}
echo -e "${BLUE}======================================${NC}"
echo -e "${BLUE}Building Official Base Images${NC}"
echo -e "${BLUE}======================================${NC}"
echo ""
echo -e "${YELLOW}Note: Building for native platform only (for local testing)${NC}"
echo -e "${YELLOW}For multi-arch builds, use: docker buildx build --platform linux/amd64,linux/arm64 --push ...${NC}"
echo ""
# Official base images
build_native_image "Dockerfile_clickhouse" \
"ht-docker-tools:clickhouse" \
"ClickHouse (official base) + Deno"
build_native_image "Dockerfile_mongodb" \
"ht-docker-tools:mongodb" \
"MongoDB (official base) + Deno"
build_native_image "Dockerfile_minio" \
"ht-docker-tools:minio" \
"MinIO (official base) + Deno"
build_native_image "Dockerfile_caddy" \
"ht-docker-tools:caddy" \
"Caddy (official base) + Deno"
build_native_image "Dockerfile_redis" \
"ht-docker-tools:redis" \
"Redis (official base) + Deno"
echo -e "${BLUE}======================================${NC}"
echo -e "${BLUE}Building Alpine Images${NC}"
echo -e "${BLUE}======================================${NC}"
echo ""
# Alpine images
build_native_image "Dockerfile_clickhouse_alpine" \
"ht-docker-tools:clickhouse-alpine" \
"ClickHouse Alpine + NVM + Deno"
build_native_image "Dockerfile_mongodb_alpine" \
"ht-docker-tools:mongodb-alpine" \
"MongoDB Alpine + NVM + Deno"
build_native_image "Dockerfile_minio_alpine" \
"ht-docker-tools:minio-alpine" \
"MinIO Alpine + NVM + Deno"
build_native_image "Dockerfile_caddy_alpine" \
"ht-docker-tools:caddy-alpine" \
"Caddy Alpine + NVM + Deno"
build_native_image "Dockerfile_redis_alpine" \
"ht-docker-tools:redis-alpine" \
"Redis Alpine + NVM + Deno"
# Summary
echo -e "${GREEN}======================================${NC}"
echo -e "${GREEN}All Images Built Successfully!${NC}"
echo -e "${GREEN}======================================${NC}"
echo ""
echo "Built Images:"
echo ""
docker images | grep "ht-docker-tools:" | awk '{printf " %-40s %10s\n", $1":"$2, $7" "$8}'
echo ""
echo -e "${YELLOW}These images are built for your native architecture for local testing.${NC}"
echo -e "${YELLOW}In CI/CD, build with: docker buildx build --platform linux/amd64,linux/arm64 --push${NC}"
echo ""

View File

@@ -0,0 +1,52 @@
# Image Support Files
This directory contains helper scripts that enable NVM (Node Version Manager) functionality in Docker images.
## Files
### bash-with-nvm
A wrapper script used as the SHELL directive in Dockerfiles. It loads NVM before executing any RUN command, enabling commands like:
```dockerfile
SHELL ["/usr/local/bin/bash-with-nvm"]
RUN nvm install 18
RUN node --version
```
### docker-entrypoint.sh
An entrypoint script that ensures NVM is available at runtime. It handles:
1. Loading NVM environment on container start
2. Special handling for `bash -c` commands (common in CI/CD) to inject bashrc sourcing
## Usage
These files are copied into Alpine-based Docker images:
```dockerfile
COPY image_support_files/bash-with-nvm /usr/local/bin/bash-with-nvm
COPY image_support_files/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod +x /usr/local/bin/bash-with-nvm /usr/local/bin/docker-entrypoint.sh
SHELL ["/usr/local/bin/bash-with-nvm"]
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
```
## Why These Scripts Are Needed
NVM is a bash function, not a binary. This creates challenges in Docker:
1. **Build time**: Each RUN command starts a fresh shell without NVM loaded
2. **Runtime**: Container commands don't automatically have NVM available
3. **CI/CD**: Non-interactive shells (bash -c) need special handling
These scripts solve all three contexts.
## Maintenance
When updating NVM version, ensure compatibility with both scripts. The NVM_DIR path (`/usr/local/nvm`) must match across:
- These scripts
- Dockerfile ENV declarations
- /etc/bash.bashrc configuration

View File

@@ -0,0 +1,9 @@
#!/bin/bash
set -e
# Load nvm before executing Dockerfile RUN commands
export NVM_DIR="/usr/local/nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
# Execute the command passed to this wrapper
eval "$@"

View File

@@ -0,0 +1,14 @@
#!/bin/bash
set -e
# Load nvm in the entrypoint environment
export NVM_DIR="/usr/local/nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
# If command is bash -c, inject bashrc sourcing to make nvm available
if [ "$1" = "bash" ] && [ "$2" = "-c" ]; then
shift 2
exec bash -c "source /etc/bash.bashrc && $*"
else
exec "$@"
fi

View File

@@ -1,22 +1,23 @@
{
"name": "ht-docker-clickhouse",
"name": "ht-docker-tools",
"private": true,
"version": "1.0.17",
"description": "chrome for docker",
"version": "2.0.0",
"description": "Docker images for various tools (MongoDB, MinIO, ClickHouse, Caddy, Redis) with Deno runtime",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\"",
"testBuild": "docker build -t yandex . && docker rmi yandex",
"build": "echo 'not needed.'"
"build": "echo 'not needed.'",
"build:images": "chmod +x build-images.sh && ./build-images.sh",
"test:images": "chmod +x test-images.sh && ./test-images.sh"
},
"repository": {
"type": "git",
"url": "git+ssh://git@gitlab.com/hosttoday/ht-docker-clickhouse.git"
"url": "git+ssh://git@code.foss.global/host.today/ht-docker-tools.git"
},
"author": "",
"author": "Task Venture Capital GmbH <hello@task.vc>",
"license": "MIT",
"bugs": {
"url": "https://gitlab.com/hosttoday/ht-docker-clickhouse/issues"
"url": "https://code.foss.global/host.today/ht-docker-tools/issues"
},
"homepage": "https://gitlab.com/hosttoday/ht-docker-clickhouse#README"
"homepage": "https://code.foss.global/host.today/ht-docker-tools#readme"
}

View File

@@ -1 +1,108 @@
# Technical Notes - ht-docker-tools
## Architecture Overview
This repository provides Docker images in two variants:
1. **Official Base Images**: Extend official images with Deno runtime
2. **Alpine Images**: Standalone Alpine-based with full NVM + Node.js + Deno stack
## NVM Implementation (Alpine Images)
NVM is a bash function, not a binary. This creates challenges in Docker contexts:
### Three Context Solutions
1. **Build-time (Dockerfile RUN commands)**
- Uses `bash-with-nvm` wrapper script as SHELL directive
- Loads NVM before executing each RUN command
2. **Runtime (CI/CD bash -c commands)**
- `docker-entrypoint.sh` handles `bash -c` commands
- Injects bashrc sourcing automatically
- `ENV BASH_ENV=/etc/bash.bashrc` enables non-interactive shell support
3. **Interactive shells**
- `/etc/bash.bashrc` configured with NVM initialization
- Works in interactive terminal sessions
### Key Files
- `image_support_files/bash-with-nvm` - Build-time NVM wrapper
- `image_support_files/docker-entrypoint.sh` - Runtime NVM support
- `/etc/bash.bashrc` - Created during build with NVM init
## Official Base Image Considerations
### ClickHouse (Debian-based)
- Base: `clickhouse/clickhouse-server`
- Deno installed via curl installer
- Preserves original entrypoint
### MongoDB (Debian-based)
- Base: `mongo:latest`
- Deno installed via curl installer
- Preserves original entrypoint
### MinIO (RHEL-based minimal)
- Base: `minio/minio:latest`
- Uses `microdnf` for package management
- Requires USER switch (root for install, minio for runtime)
### Caddy (Alpine-based)
- Base: `caddy:latest`
- Deno installed from Alpine edge repository
- Already Alpine, so minimal modification needed
### Redis (Debian-based)
- Base: `redis:latest`
- Deno installed via curl installer
- Preserves original entrypoint
## Alpine Package Availability
| Tool | Package | Repository |
|------|---------|------------|
| MongoDB | `mongodb`, `mongodb-tools` | edge/community |
| MinIO | `minio` | edge/community |
| ClickHouse | `clickhouse` | edge/community |
| Caddy | `caddy` | edge/community |
| Redis | `redis` | main |
| Deno | `deno` | edge/community |
All Alpine images use `alpine:edge` to access community packages.
## Version Information
- NVM: v0.40.1
- Node.js LTS: 20.18.2
- Uses unofficial-builds.nodejs.org for musl (Alpine) compatibility
## Multi-Architecture
Alpine images support:
- `linux/amd64` (x86_64)
- `linux/arm64` (aarch64/Apple Silicon)
Build with buildx:
```bash
docker buildx build --platform linux/amd64,linux/arm64 -f Dockerfile_xxx --push .
```
## CI/CD Integration
The images work with npmci for automated building:
```bash
npmci docker login
npmci docker build
npmci docker test
npmci docker push code.foss.global
```
## Testing
Run the test script to verify:
- Deno availability in all images
- NVM availability in Alpine images
- Node.js version in Alpine images
- NVM version switching capability

183
readme.md
View File

@@ -0,0 +1,183 @@
# ht-docker-tools
Docker images for various tools (MongoDB, MinIO, ClickHouse, Caddy, Redis) enhanced with Deno runtime support.
## Available Images
### Official Base Images
These images extend official Docker images with Deno runtime:
| Image | Base | Description |
|-------|------|-------------|
| `ht-docker-tools:clickhouse` | clickhouse/clickhouse-server | ClickHouse + Deno |
| `ht-docker-tools:mongodb` | mongo:latest | MongoDB + Deno |
| `ht-docker-tools:minio` | minio/minio:latest | MinIO + Deno |
| `ht-docker-tools:caddy` | caddy:latest | Caddy + Deno |
| `ht-docker-tools:redis` | redis:latest | Redis + Deno |
### Alpine Images
Lightweight Alpine-based images with full NVM + Node.js + Deno support:
| Image | Description | Size |
|-------|-------------|------|
| `ht-docker-tools:clickhouse-alpine` | ClickHouse + NVM + Node.js + Deno | ~250MB |
| `ht-docker-tools:mongodb-alpine` | MongoDB + NVM + Node.js + Deno | ~200MB |
| `ht-docker-tools:minio-alpine` | MinIO + NVM + Node.js + Deno | ~200MB |
| `ht-docker-tools:caddy-alpine` | Caddy + NVM + Node.js + Deno | ~200MB |
| `ht-docker-tools:redis-alpine` | Redis + NVM + Node.js + Deno | ~200MB |
## Quick Start
### Using Official Base Images
```bash
# MongoDB with Deno scripting
docker run -d --name mongo ht-docker-tools:mongodb
# Execute Deno script inside container
docker exec mongo deno run --allow-net script.ts
# Redis with Deno
docker run -d --name redis ht-docker-tools:redis
```
### Using Alpine Images
```bash
# MongoDB Alpine with Node.js and Deno
docker run -d --name mongo-alpine ht-docker-tools:mongodb-alpine
# Use Node.js
docker exec mongo-alpine bash -c "node --version"
# Use Deno
docker exec mongo-alpine bash -c "deno --version"
# Switch Node versions with NVM
docker exec mongo-alpine bash -c "nvm install 18 && nvm use 18 && node --version"
```
## Features
### Official Base Images
- Extend official Docker images (MongoDB, MinIO, ClickHouse, Caddy, Redis)
- Add Deno runtime for scripting and automation
- Preserve original image entrypoints and configurations
- Ideal for production use with existing configurations
### Alpine Images
- Lightweight Alpine-based (significantly smaller than official images)
- Full NVM support for Node.js version switching
- Node.js LTS (20.18.2) pre-installed
- Deno runtime included
- Multi-architecture support (amd64/arm64)
- Ideal for CI/CD and development environments
## Docker Compose Example
```yaml
version: '3.8'
services:
mongodb:
image: code.foss.global/host.today/ht-docker-tools:mongodb-alpine
ports:
- "27017:27017"
volumes:
- mongodb_data:/data/db
command: mongod
redis:
image: code.foss.global/host.today/ht-docker-tools:redis-alpine
ports:
- "6379:6379"
volumes:
- redis_data:/data
command: redis-server
minio:
image: code.foss.global/host.today/ht-docker-tools:minio-alpine
ports:
- "9000:9000"
- "9001:9001"
environment:
MINIO_ROOT_USER: minioadmin
MINIO_ROOT_PASSWORD: minioadmin
volumes:
- minio_data:/data
command: minio server /data --console-address ":9001"
caddy:
image: code.foss.global/host.today/ht-docker-tools:caddy-alpine
ports:
- "80:80"
- "443:443"
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile
- caddy_data:/data
- caddy_config:/config
volumes:
mongodb_data:
redis_data:
minio_data:
caddy_data:
caddy_config:
```
## Building Images Locally
```bash
# Clone the repository
git clone https://code.foss.global/host.today/ht-docker-tools.git
cd ht-docker-tools
# Build all images
chmod +x build-images.sh
./build-images.sh
# Test all images
chmod +x test-images.sh
./test-images.sh
```
## Multi-Architecture Support
All Alpine images support both `linux/amd64` and `linux/arm64` architectures.
For CI/CD multi-arch builds:
```bash
docker buildx build \
--platform linux/amd64,linux/arm64 \
-f Dockerfile_mongodb_alpine \
-t code.foss.global/host.today/ht-docker-tools:mongodb-alpine \
--push .
```
## NVM Usage (Alpine Images)
Alpine images include NVM for Node.js version management:
```bash
# Check NVM version
docker run --rm ht-docker-tools:redis-alpine bash -c "nvm --version"
# Install specific Node.js version
docker run --rm ht-docker-tools:redis-alpine bash -c "nvm install 18 && node --version"
# Use in Dockerfile
FROM code.foss.global/host.today/ht-docker-tools:mongodb-alpine
RUN nvm install 18 && nvm use 18 && npm install -g typescript
```
## Registry
Images are available at:
- `code.foss.global/host.today/ht-docker-tools`
## License
MIT - Task Venture Capital GmbH

146
test-images.sh Normal file
View File

@@ -0,0 +1,146 @@
#!/bin/bash
set -e
echo "Testing ht-docker-tools Images"
echo "=============================="
echo ""
# Color codes
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m' # No Color
FAILED_TESTS=0
# Test function
test_image() {
local tag=$1
local description=$2
local command=$3
echo -e "${BLUE}Testing: ${NC}${description}"
echo -e "${YELLOW} Image: ${NC}${tag}"
echo -e "${YELLOW} Command: ${NC}${command}"
if output=$(docker run --rm "${tag}" bash -c "${command}" 2>&1); then
echo -e "${GREEN} Result: ${NC}${output}"
echo -e "${GREEN} PASSED${NC}"
else
echo -e "${RED} FAILED: ${NC}${output}"
((FAILED_TESTS++))
fi
echo ""
}
echo -e "${BLUE}======================================${NC}"
echo -e "${BLUE}Testing Official Base Images${NC}"
echo -e "${BLUE}======================================${NC}"
echo ""
# Test official base images (Deno only)
test_image "ht-docker-tools:clickhouse" \
"ClickHouse + Deno" \
"deno --version | head -1"
test_image "ht-docker-tools:mongodb" \
"MongoDB + Deno" \
"deno --version | head -1"
test_image "ht-docker-tools:minio" \
"MinIO + Deno" \
"deno --version | head -1"
test_image "ht-docker-tools:caddy" \
"Caddy + Deno" \
"deno --version | head -1"
test_image "ht-docker-tools:redis" \
"Redis + Deno" \
"deno --version | head -1"
echo -e "${BLUE}======================================${NC}"
echo -e "${BLUE}Testing Alpine Images${NC}"
echo -e "${BLUE}======================================${NC}"
echo ""
# Test Alpine images (NVM + Node.js + Deno + Service)
test_image "ht-docker-tools:clickhouse-alpine" \
"ClickHouse Alpine - NVM" \
"nvm --version"
test_image "ht-docker-tools:clickhouse-alpine" \
"ClickHouse Alpine - Node.js" \
"node --version"
test_image "ht-docker-tools:clickhouse-alpine" \
"ClickHouse Alpine - Deno" \
"deno --version | head -1"
test_image "ht-docker-tools:mongodb-alpine" \
"MongoDB Alpine - NVM" \
"nvm --version"
test_image "ht-docker-tools:mongodb-alpine" \
"MongoDB Alpine - Node.js" \
"node --version"
test_image "ht-docker-tools:mongodb-alpine" \
"MongoDB Alpine - Deno" \
"deno --version | head -1"
test_image "ht-docker-tools:minio-alpine" \
"MinIO Alpine - NVM" \
"nvm --version"
test_image "ht-docker-tools:minio-alpine" \
"MinIO Alpine - Node.js" \
"node --version"
test_image "ht-docker-tools:minio-alpine" \
"MinIO Alpine - Deno" \
"deno --version | head -1"
test_image "ht-docker-tools:caddy-alpine" \
"Caddy Alpine - NVM" \
"nvm --version"
test_image "ht-docker-tools:caddy-alpine" \
"Caddy Alpine - Node.js" \
"node --version"
test_image "ht-docker-tools:caddy-alpine" \
"Caddy Alpine - Deno" \
"deno --version | head -1"
test_image "ht-docker-tools:redis-alpine" \
"Redis Alpine - NVM" \
"nvm --version"
test_image "ht-docker-tools:redis-alpine" \
"Redis Alpine - Node.js" \
"node --version"
test_image "ht-docker-tools:redis-alpine" \
"Redis Alpine - Deno" \
"deno --version | head -1"
echo -e "${BLUE}======================================${NC}"
echo -e "${BLUE}Testing NVM Version Switching${NC}"
echo -e "${BLUE}======================================${NC}"
echo ""
test_image "ht-docker-tools:redis-alpine" \
"NVM - Install Node 18" \
"nvm install 18 && nvm use 18 && node --version"
# Summary
echo -e "${BLUE}======================================${NC}"
if [ $FAILED_TESTS -eq 0 ]; then
echo -e "${GREEN}All tests passed!${NC}"
else
echo -e "${RED}${FAILED_TESTS} test(s) failed${NC}"
exit 1
fi
echo -e "${BLUE}======================================${NC}"