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:
52
image_support_files/README.md
Normal file
52
image_support_files/README.md
Normal 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
|
||||
9
image_support_files/bash-with-nvm
Normal file
9
image_support_files/bash-with-nvm
Normal 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 "$@"
|
||||
14
image_support_files/docker-entrypoint.sh
Normal file
14
image_support_files/docker-entrypoint.sh
Normal 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
|
||||
Reference in New Issue
Block a user