Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5743898ba7 |
@@ -6,7 +6,7 @@ on:
|
|||||||
- '**'
|
- '**'
|
||||||
|
|
||||||
env:
|
env:
|
||||||
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:szci
|
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
|
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
|
||||||
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
|
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
|
||||||
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
|
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
|
||||||
@@ -24,22 +24,22 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Install pnpm and szci
|
- name: Install pnpm and npmci
|
||||||
run: |
|
run: |
|
||||||
pnpm install -g pnpm
|
pnpm install -g pnpm
|
||||||
pnpm install -g @ship.zone/szci
|
pnpm install -g @ship.zone/npmci
|
||||||
szci npm prepare
|
npmci npm prepare
|
||||||
|
|
||||||
- name: Audit production dependencies
|
- name: Audit production dependencies
|
||||||
run: |
|
run: |
|
||||||
szci command npm config set registry https://registry.npmjs.org
|
npmci command npm config set registry https://registry.npmjs.org
|
||||||
szci command pnpm audit --audit-level=high --prod
|
npmci command pnpm audit --audit-level=high --prod
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
|
||||||
- name: Audit development dependencies
|
- name: Audit development dependencies
|
||||||
run: |
|
run: |
|
||||||
szci command npm config set registry https://registry.npmjs.org
|
npmci command npm config set registry https://registry.npmjs.org
|
||||||
szci command pnpm audit --audit-level=high --dev
|
npmci command pnpm audit --audit-level=high --dev
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
|
||||||
test:
|
test:
|
||||||
@@ -54,18 +54,18 @@ jobs:
|
|||||||
- name: Prepare
|
- name: Prepare
|
||||||
run: |
|
run: |
|
||||||
pnpm install -g pnpm
|
pnpm install -g pnpm
|
||||||
pnpm install -g @ship.zone/szci
|
pnpm install -g @ship.zone/npmci
|
||||||
szci npm prepare
|
npmci npm prepare
|
||||||
|
|
||||||
- name: Test stable
|
- name: Test stable
|
||||||
run: |
|
run: |
|
||||||
szci node install stable
|
npmci node install stable
|
||||||
szci npm install
|
npmci npm install
|
||||||
szci npm test
|
npmci npm test
|
||||||
|
|
||||||
- name: Test build
|
- name: Test build
|
||||||
run: |
|
run: |
|
||||||
szci npm prepare
|
npmci npm prepare
|
||||||
szci node install stable
|
npmci node install stable
|
||||||
szci npm install
|
npmci npm install
|
||||||
szci command npm run build
|
npmci command npm run build
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ on:
|
|||||||
- '*'
|
- '*'
|
||||||
|
|
||||||
env:
|
env:
|
||||||
IMAGE: code.foss.global/host.today/ht-docker-node:szci
|
IMAGE: code.foss.global/host.today/ht-docker-node:npmci
|
||||||
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
|
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
|
||||||
# NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
|
# NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
|
||||||
# NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
|
# NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
|
||||||
@@ -27,19 +27,19 @@ jobs:
|
|||||||
- name: Prepare
|
- name: Prepare
|
||||||
run: |
|
run: |
|
||||||
pnpm install -g pnpm
|
pnpm install -g pnpm
|
||||||
pnpm install -g @ship.zone/szci
|
pnpm install -g @ship.zone/npmci
|
||||||
szci npm prepare
|
npmci npm prepare
|
||||||
|
|
||||||
- name: Audit production dependencies
|
- name: Audit production dependencies
|
||||||
run: |
|
run: |
|
||||||
szci command npm config set registry https://registry.npmjs.org
|
npmci command npm config set registry https://registry.npmjs.org
|
||||||
szci command pnpm audit --audit-level=high --prod
|
npmci command pnpm audit --audit-level=high --prod
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
|
||||||
- name: Audit development dependencies
|
- name: Audit development dependencies
|
||||||
run: |
|
run: |
|
||||||
szci command npm config set registry https://registry.npmjs.org
|
npmci command npm config set registry https://registry.npmjs.org
|
||||||
szci command pnpm audit --audit-level=high --dev
|
npmci command pnpm audit --audit-level=high --dev
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
|
||||||
test:
|
test:
|
||||||
@@ -54,27 +54,27 @@ jobs:
|
|||||||
- name: Prepare
|
- name: Prepare
|
||||||
run: |
|
run: |
|
||||||
pnpm install -g pnpm
|
pnpm install -g pnpm
|
||||||
pnpm install -g @ship.zone/szci
|
pnpm install -g @ship.zone/npmci
|
||||||
szci npm prepare
|
npmci npm prepare
|
||||||
|
|
||||||
- name: Test stable
|
- name: Test stable
|
||||||
run: |
|
run: |
|
||||||
szci node install stable
|
npmci node install stable
|
||||||
szci npm install
|
npmci npm install
|
||||||
szci npm test
|
npmci npm test
|
||||||
|
|
||||||
- name: Test build
|
- name: Test build
|
||||||
run: |
|
run: |
|
||||||
szci node install stable
|
npmci node install stable
|
||||||
szci npm install
|
npmci npm install
|
||||||
szci command npm run build
|
npmci command npm run build
|
||||||
|
|
||||||
release:
|
release:
|
||||||
needs: test
|
needs: test
|
||||||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container:
|
container:
|
||||||
image: code.foss.global/host.today/ht-docker-dbase:szci
|
image: code.foss.global/host.today/ht-docker-dbase:npmci
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
@@ -110,4 +110,4 @@ jobs:
|
|||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Trigger
|
- name: Trigger
|
||||||
run: szci trigger
|
run: npmci trigger
|
||||||
|
|||||||
30
Dockerfile
30
Dockerfile
@@ -9,11 +9,12 @@ ENV NODE_VERSION_LTS="24.13.0" NODE_VERSION_STABLE="24.13.0" NVM_DIR="/usr/local
|
|||||||
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser
|
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser
|
||||||
ENV CHROME_BIN=/usr/bin/chromium-browser
|
ENV CHROME_BIN=/usr/bin/chromium-browser
|
||||||
|
|
||||||
# Layer 1: Base system + dev tools
|
# Set debconf to run non-interactively and install packages
|
||||||
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections \
|
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections \
|
||||||
&& apt-get update \
|
&& apt-get update \
|
||||||
&& apt-get upgrade --no-install-recommends -y \
|
&& apt-get upgrade --no-install-recommends -y \
|
||||||
&& apt-get install -y -q --no-install-recommends \
|
&& apt-get install -y -q --no-install-recommends \
|
||||||
|
# base libs
|
||||||
software-properties-common \
|
software-properties-common \
|
||||||
apt-transport-https \
|
apt-transport-https \
|
||||||
build-essential \
|
build-essential \
|
||||||
@@ -30,13 +31,7 @@ RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selectio
|
|||||||
ssh \
|
ssh \
|
||||||
wget \
|
wget \
|
||||||
unzip \
|
unzip \
|
||||||
iputils-ping \
|
# puppeteer
|
||||||
dnsutils \
|
|
||||||
tini
|
|
||||||
|
|
||||||
# Layer 2: Chromium + Puppeteer/Playwright browser deps
|
|
||||||
RUN apt-get install -y -q --no-install-recommends \
|
|
||||||
chromium-browser \
|
|
||||||
libasound2t64 \
|
libasound2t64 \
|
||||||
libatk1.0-0 \
|
libatk1.0-0 \
|
||||||
libatk-bridge2.0-0 \
|
libatk-bridge2.0-0 \
|
||||||
@@ -68,21 +63,28 @@ RUN apt-get install -y -q --no-install-recommends \
|
|||||||
libxrender1 \
|
libxrender1 \
|
||||||
libxss1 \
|
libxss1 \
|
||||||
libxtst6 \
|
libxtst6 \
|
||||||
|
ca-certificates \
|
||||||
fonts-liberation \
|
fonts-liberation \
|
||||||
libayatana-appindicator3-1 \
|
libayatana-appindicator3-1 \
|
||||||
libnss3 \
|
libnss3 \
|
||||||
lsb-release \
|
lsb-release \
|
||||||
xdg-utils
|
xdg-utils \
|
||||||
|
# network
|
||||||
# Layer 3: MongoDB 8.0
|
iputils-ping \
|
||||||
RUN curl -fsSL https://www.mongodb.org/static/pgp/server-8.0.asc | \
|
dnsutils \
|
||||||
|
|
||||||
|
# chromium (multi-arch compatible - works on both amd64 and arm64)
|
||||||
|
&& apt-get install -y -q --no-install-recommends chromium-browser \
|
||||||
|
|
||||||
|
# mongodb 8.0
|
||||||
|
&& curl -fsSL https://www.mongodb.org/static/pgp/server-8.0.asc | \
|
||||||
gpg --dearmor -o /usr/share/keyrings/mongodb-server-8.0.gpg \
|
gpg --dearmor -o /usr/share/keyrings/mongodb-server-8.0.gpg \
|
||||||
&& echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-8.0.gpg ] https://repo.mongodb.org/apt/ubuntu noble/mongodb-org/8.0 multiverse" | \
|
&& echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-8.0.gpg ] https://repo.mongodb.org/apt/ubuntu noble/mongodb-org/8.0 multiverse" | \
|
||||||
tee /etc/apt/sources.list.d/mongodb-org-8.0.list \
|
tee /etc/apt/sources.list.d/mongodb-org-8.0.list \
|
||||||
&& apt-get update \
|
&& apt-get update \
|
||||||
&& apt-get install -y -q --no-install-recommends mongodb-org \
|
&& apt-get install -y -q --no-install-recommends mongodb-org \
|
||||||
&& apt-get clean \
|
&& apt-get clean \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -r /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Install nvm with node and npm
|
# Install nvm with node and npm
|
||||||
RUN mkdir -p $NVM_DIR && curl https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
|
RUN mkdir -p $NVM_DIR && curl https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
|
||||||
@@ -133,5 +135,5 @@ ENV DENO_INSTALL="/root/.deno"
|
|||||||
ENV PATH="$DENO_INSTALL/bin:$PATH"
|
ENV PATH="$DENO_INSTALL/bin:$PATH"
|
||||||
|
|
||||||
# Set entrypoint to make nvm available in all runtime contexts
|
# Set entrypoint to make nvm available in all runtime contexts
|
||||||
ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/docker-entrypoint.sh"]
|
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
|
||||||
CMD ["bash"]
|
CMD ["bash"]
|
||||||
|
|||||||
@@ -16,8 +16,7 @@ RUN apk add --no-cache \
|
|||||||
git \
|
git \
|
||||||
ca-certificates \
|
ca-certificates \
|
||||||
unzip \
|
unzip \
|
||||||
libstdc++ \
|
libstdc++
|
||||||
tini
|
|
||||||
|
|
||||||
# Install NVM (latest version for better Alpine/musl support)
|
# 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
|
RUN mkdir -p $NVM_DIR && curl https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
|
||||||
@@ -42,11 +41,7 @@ SHELL ["/usr/local/bin/bash-with-nvm"]
|
|||||||
ENV BASH_ENV=/etc/bash.bashrc
|
ENV BASH_ENV=/etc/bash.bashrc
|
||||||
|
|
||||||
# Install Node.js LTS via NVM and Bun
|
# Install Node.js LTS via NVM and Bun
|
||||||
# TARGETARCH fix: QEMU buildx can report wrong arch via uname -m
|
RUN nvm install $NODE_VERSION_LTS \
|
||||||
ARG TARGETARCH
|
|
||||||
RUN NVM_MUSL_ARCH=$([ "$TARGETARCH" = "arm64" ] && echo "arm64-musl" || echo "x64-musl") \
|
|
||||||
&& nvm_get_arch() { echo "$NVM_MUSL_ARCH"; } \
|
|
||||||
&& nvm install $NODE_VERSION_LTS \
|
|
||||||
&& nvm alias default $NODE_VERSION_LTS \
|
&& nvm alias default $NODE_VERSION_LTS \
|
||||||
&& nvm use default \
|
&& nvm use default \
|
||||||
&& curl -fsSL https://bun.sh/install | bash
|
&& curl -fsSL https://bun.sh/install | bash
|
||||||
@@ -55,5 +50,5 @@ ENV PATH="$BUN_INSTALL/bin:$NVM_DIR/versions/node/v$NODE_VERSION_LTS/bin:$PATH"
|
|||||||
ENV NODE_PATH=$NVM_DIR/v$NODE_VERSION_LTS/lib/node_modules
|
ENV NODE_PATH=$NVM_DIR/v$NODE_VERSION_LTS/lib/node_modules
|
||||||
|
|
||||||
# Set entrypoint to make nvm available in all runtime contexts
|
# Set entrypoint to make nvm available in all runtime contexts
|
||||||
ENTRYPOINT ["/sbin/tini", "--", "/usr/local/bin/docker-entrypoint.sh"]
|
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
|
||||||
CMD ["bash"]
|
CMD ["bash"]
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ RUN apk add --no-cache \
|
|||||||
ca-certificates \
|
ca-certificates \
|
||||||
unzip \
|
unzip \
|
||||||
libstdc++ \
|
libstdc++ \
|
||||||
tini \
|
|
||||||
deno
|
deno
|
||||||
|
|
||||||
# Install NVM (latest version for better Alpine/musl support)
|
# Install NVM (latest version for better Alpine/musl support)
|
||||||
@@ -43,11 +42,7 @@ SHELL ["/usr/local/bin/bash-with-nvm"]
|
|||||||
ENV BASH_ENV=/etc/bash.bashrc
|
ENV BASH_ENV=/etc/bash.bashrc
|
||||||
|
|
||||||
# Install Node.js LTS via NVM (Deno already installed from Alpine repos)
|
# Install Node.js LTS via NVM (Deno already installed from Alpine repos)
|
||||||
# TARGETARCH fix: QEMU buildx can report wrong arch via uname -m
|
RUN nvm install $NODE_VERSION_LTS \
|
||||||
ARG TARGETARCH
|
|
||||||
RUN NVM_MUSL_ARCH=$([ "$TARGETARCH" = "arm64" ] && echo "arm64-musl" || echo "x64-musl") \
|
|
||||||
&& nvm_get_arch() { echo "$NVM_MUSL_ARCH"; } \
|
|
||||||
&& nvm install $NODE_VERSION_LTS \
|
|
||||||
&& nvm alias default $NODE_VERSION_LTS \
|
&& nvm alias default $NODE_VERSION_LTS \
|
||||||
&& nvm use default
|
&& nvm use default
|
||||||
|
|
||||||
@@ -55,5 +50,5 @@ ENV PATH="$NVM_DIR/versions/node/v$NODE_VERSION_LTS/bin:$PATH"
|
|||||||
ENV NODE_PATH=$NVM_DIR/v$NODE_VERSION_LTS/lib/node_modules
|
ENV NODE_PATH=$NVM_DIR/v$NODE_VERSION_LTS/lib/node_modules
|
||||||
|
|
||||||
# Set entrypoint to make nvm available in all runtime contexts
|
# Set entrypoint to make nvm available in all runtime contexts
|
||||||
ENTRYPOINT ["/sbin/tini", "--", "/usr/local/bin/docker-entrypoint.sh"]
|
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
|
||||||
CMD ["bash"]
|
CMD ["bash"]
|
||||||
|
|||||||
@@ -22,8 +22,7 @@ RUN apk add --no-cache \
|
|||||||
unzip \
|
unzip \
|
||||||
iputils \
|
iputils \
|
||||||
bind-tools \
|
bind-tools \
|
||||||
libstdc++ \
|
libstdc++
|
||||||
tini
|
|
||||||
|
|
||||||
# Install NVM (latest version for better Alpine/musl support)
|
# 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
|
RUN mkdir -p $NVM_DIR && curl https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
|
||||||
@@ -53,13 +52,7 @@ ENV PATH="$PNPM_HOME:$PATH"
|
|||||||
|
|
||||||
# Install Node.js LTS via NVM and pnpm
|
# Install Node.js LTS via NVM and pnpm
|
||||||
# Use musl-specific builds from unofficial-builds for Alpine compatibility
|
# Use musl-specific builds from unofficial-builds for Alpine compatibility
|
||||||
# TARGETARCH fix: QEMU buildx can report wrong arch via uname -m, causing NVM
|
RUN nvm install $NODE_VERSION_LTS \
|
||||||
# to download x64 binaries on arm64. We create a temporary uname wrapper to
|
|
||||||
# ensure the correct architecture binary is downloaded.
|
|
||||||
ARG TARGETARCH
|
|
||||||
RUN NVM_MUSL_ARCH=$([ "$TARGETARCH" = "arm64" ] && echo "arm64-musl" || echo "x64-musl") \
|
|
||||||
&& nvm_get_arch() { echo "$NVM_MUSL_ARCH"; } \
|
|
||||||
&& nvm install $NODE_VERSION_LTS \
|
|
||||||
&& nvm alias default $NODE_VERSION_LTS \
|
&& nvm alias default $NODE_VERSION_LTS \
|
||||||
&& nvm use default \
|
&& nvm use default \
|
||||||
&& npm install -g pnpm \
|
&& npm install -g pnpm \
|
||||||
@@ -70,5 +63,5 @@ ENV NODE_PATH=$NVM_DIR/v$NODE_VERSION_LTS/lib/node_modules
|
|||||||
ENV PATH=$NVM_DIR/versions/node/v$NODE_VERSION_LTS/bin:$PATH
|
ENV PATH=$NVM_DIR/versions/node/v$NODE_VERSION_LTS/bin:$PATH
|
||||||
|
|
||||||
# Set entrypoint to make nvm available in all runtime contexts
|
# Set entrypoint to make nvm available in all runtime contexts
|
||||||
ENTRYPOINT ["/sbin/tini", "--", "/usr/local/bin/docker-entrypoint.sh"]
|
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
|
||||||
CMD ["bash"]
|
CMD ["bash"]
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
FROM host.today/ht-docker-node:alpine-node
|
FROM host.today/ht-docker-node:alpine-node
|
||||||
RUN apk update && apk add bash libc6-compat alpine-sdk
|
RUN apk update && apk add bash libc6-compat alpine-sdk
|
||||||
ENV PYTHONUNBUFFERED=1
|
ENV PYTHONUNBUFFERED=1
|
||||||
RUN apk add --update --no-cache python3 py3-pip && ln -sf python3 /usr/bin/python
|
RUN apk add --update --no-cache python3 && ln -sf python3 /usr/bin/python
|
||||||
|
RUN python3 -m ensurepip
|
||||||
|
RUN pip3 install --no-cache --upgrade pip setuptools
|
||||||
RUN apk add --update alpine-sdk && \
|
RUN apk add --update alpine-sdk && \
|
||||||
apk add libffi-dev openssl-dev && \
|
apk add libffi-dev openssl-dev && \
|
||||||
apk add python3-dev && \
|
apk add python3-dev && \
|
||||||
pnpm install -g @ship.zone/szci node-gyp
|
pnpm install -g @ship.zone/npmci node-gyp
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
FROM host.today/ht-docker-node:szci
|
FROM host.today/ht-docker-node:npmci
|
||||||
RUN npm install -g \
|
RUN npm install -g \
|
||||||
@git.zone/tsrun \
|
@git.zone/tsrun \
|
||||||
@git.zone/tstest \
|
@git.zone/tstest \
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
FROM host.today/ht-docker-node:latest
|
FROM host.today/ht-docker-node:latest
|
||||||
LABEL author="Task Venture Capital GmbH <hello@task.vc>"
|
LABEL author="Task Venture Capital GmbH <hello@task.vc>"
|
||||||
|
|
||||||
RUN pnpm install -g @ship.zone/szci
|
RUN pnpm install -g @ship.zone/npmci
|
||||||
6
Dockerfile_stableinit
Normal file
6
Dockerfile_stableinit
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
FROM host.today/ht-docker-node:latest
|
||||||
|
# Add Tini
|
||||||
|
ENV TINI_VERSION v0.19.0
|
||||||
|
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
|
||||||
|
RUN chmod +x /tini
|
||||||
|
ENTRYPOINT ["/tini", "--"]
|
||||||
18
changelog.md
18
changelog.md
@@ -1,23 +1,5 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
## 2026-02-07 - 5.5.0 - feat(docker)
|
|
||||||
Rework Dockerfile into layered installs and add tooling (tini, chromium, MongoDB); simplify Alpine CI image Python/pip setup; add tsdocker devDependency; remove npmextra push flag; update README and registry links
|
|
||||||
|
|
||||||
- Dockerfile: split apt installs into logical layers, added tini, iputils-ping and dnsutils, moved chromium-browser into its own layer, and fixed apt cache cleanup (rm -rf)
|
|
||||||
- Dockerfile: add MongoDB 8.0 apt repository and install in a dedicated layer
|
|
||||||
- Alpine image (Dockerfile_alpine-szci): consolidated python3 and py3-pip install (removed ensurepip + manual pip upgrade)
|
|
||||||
- package.json: add devDependency @git.zone/tsdocker@^1.15.1
|
|
||||||
- npmextra.json: removed "push": false flag (affects CI/publish behavior)
|
|
||||||
- README: update registry URLs to code.foss.global, document tini and NVM behavior, refresh image descriptions and links
|
|
||||||
|
|
||||||
## 2026-02-06 - 5.4.0 - feat(ci)
|
|
||||||
replace npmci with szci across CI and images; add szci preinstalled images and make tini the PID 1 init in Docker images
|
|
||||||
|
|
||||||
- Replace @ship.zone/npmci with @ship.zone/szci in Gitea CI workflows (.gitea/workflows/docker_nottags.yaml, docker_tags.yaml) and update commands to use szci
|
|
||||||
- Add szci-specific Dockerfiles (Dockerfile_szci, Dockerfile_alpine-szci) and tests (test/test_szci.sh); remove npmci-specific files
|
|
||||||
- Install and use tini as PID 1 in multiple Dockerfiles and switch ENTRYPOINT to run tini for proper signal forwarding and zombie reaping
|
|
||||||
- Update metadata/manifest files (package.json, npmextra.json, readme.*, Dockerfile base tags) to reference szci and document the inclusion of tini
|
|
||||||
|
|
||||||
## 2026-02-06 - 5.3.0 - feat(docker)
|
## 2026-02-06 - 5.3.0 - feat(docker)
|
||||||
add Chromium support for Puppeteer/Playwright and npm build/release scripts
|
add Chromium support for Puppeteer/Playwright and npm build/release scripts
|
||||||
|
|
||||||
|
|||||||
@@ -16,13 +16,13 @@
|
|||||||
"CI",
|
"CI",
|
||||||
"git",
|
"git",
|
||||||
"ssh",
|
"ssh",
|
||||||
"szci",
|
"npmci",
|
||||||
"node version management",
|
"node version management",
|
||||||
"typescript"
|
"typescript"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"szci": {
|
"npmci": {
|
||||||
"dockerRegistries": [
|
"dockerRegistries": [
|
||||||
"docker.io",
|
"docker.io",
|
||||||
"registry.gitlab.com"
|
"registry.gitlab.com"
|
||||||
@@ -40,6 +40,7 @@
|
|||||||
"docker.io": "hosttoday/ht-docker-node"
|
"docker.io": "hosttoday/ht-docker-node"
|
||||||
},
|
},
|
||||||
"platforms": ["linux/amd64", "linux/arm64"],
|
"platforms": ["linux/amd64", "linux/arm64"],
|
||||||
|
"push": false,
|
||||||
"testDir": "./test"
|
"testDir": "./test"
|
||||||
},
|
},
|
||||||
"tsdoc": {
|
"tsdoc": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ht-docker-node",
|
"name": "ht-docker-node",
|
||||||
"version": "5.5.0",
|
"version": "5.3.0",
|
||||||
"description": "A Docker image that integrates Node.js with shipzone.io support.",
|
"description": "A Docker image that integrates Node.js with shipzone.io support.",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -30,11 +30,8 @@
|
|||||||
"CI",
|
"CI",
|
||||||
"git",
|
"git",
|
||||||
"ssh",
|
"ssh",
|
||||||
"szci",
|
"npmci",
|
||||||
"node version management",
|
"node version management",
|
||||||
"typescript"
|
"typescript"
|
||||||
],
|
]
|
||||||
"devDependencies": {
|
|
||||||
"@git.zone/tsdocker": "^1.15.1"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
3177
pnpm-lock.yaml
generated
3177
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -68,7 +68,7 @@ RUN node --version # Now shows v18.x.x
|
|||||||
- ✅ Dockerfile RUN: `nvm install`, `nvm use`, version switching
|
- ✅ Dockerfile RUN: `nvm install`, `nvm use`, version switching
|
||||||
- ✅ Runtime bash -c: All nvm commands work
|
- ✅ Runtime bash -c: All nvm commands work
|
||||||
- ✅ CI/CD workflows: Tested in .gitea/workflows context
|
- ✅ CI/CD workflows: Tested in .gitea/workflows context
|
||||||
- ✅ Backward compat: pnpm, szci, ENV PATH fallback
|
- ✅ Backward compat: pnpm, npmci, ENV PATH fallback
|
||||||
- ✅ Multi-stage builds: nvm available in all stages
|
- ✅ Multi-stage builds: nvm available in all stages
|
||||||
- ✅ Interactive shells: Full nvm access
|
- ✅ Interactive shells: Full nvm access
|
||||||
|
|
||||||
|
|||||||
522
readme.md
522
readme.md
@@ -1,163 +1,121 @@
|
|||||||
# 🐳 ht-docker-node
|
# 🐳 ht-docker-node
|
||||||
|
|
||||||
> Production-ready Docker images for Node.js with NVM built in, multi-arch support, and modern runtimes (Bun, Deno). Every image ships with **tini** as PID 1 and full **NVM** integration — switch Node versions on the fly, no sourcing required.
|
> Production-ready Docker images for Node.js development with multi-architecture support, modern runtimes, and intelligent version management.
|
||||||
|
|
||||||
**Multi-arch** • **Alpine & Ubuntu** • **NVM built-in** • **Bun, Deno & pnpm** • **tini init** • **CI/CD optimized**
|
**Multi-arch ready** • **Alpine & Ubuntu** • **NVM built-in** • **Bun, Deno & pnpm** • **CI/CD optimized**
|
||||||
|
|
||||||
## Issue Reporting and Security
|
|
||||||
|
|
||||||
For reporting bugs, issues, or security vulnerabilities, please visit [community.foss.global/](https://community.foss.global/). This is the central community hub for all issue reporting. Developers who sign and comply with our contribution agreement and go through identification can also get a [code.foss.global/](https://code.foss.global/) account to submit Pull Requests directly.
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 🚀 Quick Start
|
## 🚀 Quick Start
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Pull and run the full-featured Ubuntu image
|
# Pull and run the latest Node.js LTS image
|
||||||
docker pull code.foss.global/host.today/ht-docker-node:latest
|
docker pull registry.gitlab.com/hosttoday/ht-docker-node:latest
|
||||||
docker run -it code.foss.global/host.today/ht-docker-node:latest
|
docker run -it registry.gitlab.com/hosttoday/ht-docker-node:latest
|
||||||
|
|
||||||
# Or go lean with Alpine (~200 MB vs ~900 MB)
|
# Or use Alpine for smaller images (200MB vs 800MB+)
|
||||||
docker pull code.foss.global/host.today/ht-docker-node:alpine-node
|
docker pull registry.gitlab.com/hosttoday/ht-docker-node:alpine-node
|
||||||
docker run -it code.foss.global/host.today/ht-docker-node:alpine-node
|
|
||||||
```
|
```
|
||||||
|
|
||||||
NVM is ready the moment you enter the container — no manual sourcing, no `.bashrc` hacks:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ nvm install 22
|
|
||||||
$ nvm use 22
|
|
||||||
$ node -v # v22.x.x ✅
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 📦 Available Images
|
## 📦 Available Images
|
||||||
|
|
||||||
### Ubuntu-Based (Full-Featured)
|
### Ubuntu-Based Images (Full-Featured)
|
||||||
|
|
||||||
Built on **Ubuntu 24.04**. Maximum compatibility, all build tools included, plus Chromium for Puppeteer/Playwright, and MongoDB 8.0.
|
Perfect for complex builds requiring native dependencies and maximum compatibility.
|
||||||
|
|
||||||
| Tag | Description | Key Contents |
|
| Tag | Description | Use Case |
|
||||||
|-----|-------------|--------------|
|
|-----|-------------|----------|
|
||||||
| `:latest` | Kitchen-sink Node.js image | Node LTS + NVM + pnpm + Bun + Deno + Chromium + MongoDB 8.0 |
|
| `:latest` | Node.js LTS with NVM (Ubuntu 24.04) | General purpose, production builds |
|
||||||
| `:lts` | Alias of `:latest` | Same — explicit LTS naming for clarity |
|
| `:lts` | Based on latest | Explicit LTS naming |
|
||||||
| `:szci` | CI/CD workhorse | `:latest` + `@ship.zone/szci` preinstalled |
|
| `:npmci` | With npmci preinstalled | CI/CD pipelines |
|
||||||
| `:fossglobal_preinstalled_<ver>` | Preloaded tooling image | `:szci` + tsrun, tstest, tapbundle, smartfile, and more |
|
| `:stableinit` | Stable initialization base | Init scripts |
|
||||||
|
|
||||||
### Alpine-Based (Lightweight & Multi-Arch) ⚡
|
### Alpine-Based Images (Lightweight & Multi-Arch) ⚡
|
||||||
|
|
||||||
**40–75 % smaller** than Ubuntu. Native performance on **both amd64 and arm64** (Apple Silicon, Graviton, Ampere).
|
**40-60% smaller** than Ubuntu images. Native performance on **both x64 and ARM64** (Apple Silicon, ARM servers).
|
||||||
|
|
||||||
| Tag | Description | Size | Architectures |
|
| Tag | Description | Size | Architectures |
|
||||||
|-----|-------------|------|---------------|
|
|-----|-------------|------|---------------|
|
||||||
| `:alpine-node` | Node.js LTS + NVM + pnpm | ~200 MB | amd64, arm64 |
|
| `:alpine-node` | Node.js LTS + NVM + pnpm | ~200MB | amd64, arm64 |
|
||||||
| `:alpine-bun` | Node.js LTS + NVM + Bun | ~150 MB | amd64, arm64 |
|
| `:alpine-deno` | Node.js LTS + NVM + Deno | ~180MB | amd64, arm64 |
|
||||||
| `:alpine-deno` | Node.js LTS + NVM + Deno | ~180 MB | amd64, arm64 |
|
| `:alpine-bun` | Node.js LTS + NVM + Bun | ~150MB | amd64, arm64 |
|
||||||
| `:alpine-szci` | Alpine Node + szci + build tools | ~250 MB | amd64, arm64 |
|
| `:alpine-npmci` | Alpine Node + npmci + build tools | ~250MB | amd64, arm64 |
|
||||||
|
|
||||||
> 💡 Docker automatically pulls the right arch for your platform. Build on a Mac, deploy on an ARM server — same tag, native speed everywhere.
|
**✨ Multi-architecture magic:** Docker automatically selects the right image for your platform. Build on Mac, deploy on Linux servers—same Dockerfile, native speed everywhere.
|
||||||
|
|
||||||
> **Note:** The Deno Alpine image uses `alpine:edge` to get the official musl-compiled Deno from the community repository.
|
> **Note:** The Deno image uses Alpine edge to access the official musl-compiled Deno package from Alpine's community repository.
|
||||||
|
|
||||||
### What every image includes
|
|
||||||
|
|
||||||
| Feature | Detail |
|
|
||||||
|---------|--------|
|
|
||||||
| **tini** | PID 1 init — proper signal forwarding & zombie reaping |
|
|
||||||
| **NVM** | v0.40.1 — works in `RUN`, `docker exec`, CI scripts, interactive shells |
|
|
||||||
| **Node.js** | LTS v24.13.0 (default, switchable) |
|
|
||||||
| **docker-entrypoint.sh** | Loads NVM at runtime so `docker run … bash -c "nvm use 22"` just works |
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 💡 Key Features
|
## 💡 Key Features
|
||||||
|
|
||||||
### 🔄 NVM — Zero-Config Node Version Management
|
### 🔄 NVM (Node Version Manager) Built-In
|
||||||
|
|
||||||
NVM is pre-wired into every shell context. No manual sourcing required in any of these scenarios:
|
Switch Node.js versions **instantly** without rebuilding images:
|
||||||
|
|
||||||
**Dockerfile RUN commands** (via the `bash-with-nvm` SHELL wrapper):
|
|
||||||
|
|
||||||
```dockerfile
|
```dockerfile
|
||||||
FROM code.foss.global/host.today/ht-docker-node:latest
|
FROM registry.gitlab.com/hosttoday/ht-docker-node:latest
|
||||||
|
|
||||||
# Works directly — no sourcing needed!
|
# Works directly in RUN commands - no sourcing needed!
|
||||||
RUN nvm install 22 && nvm use 22 && npm ci
|
RUN nvm install 18.20.0
|
||||||
RUN nvm alias default 22 # persists for later RUN steps
|
RUN nvm use 18 && npm install
|
||||||
|
RUN nvm install 20 && nvm use 20 && npm test
|
||||||
|
|
||||||
|
# Set default for subsequent commands
|
||||||
|
RUN nvm install 19 && nvm alias default 19
|
||||||
```
|
```
|
||||||
|
|
||||||
**CI/CD scripts** (via `BASH_ENV=/etc/bash.bashrc`):
|
### 🎯 CI/CD Workflow Ready
|
||||||
|
|
||||||
|
NVM works seamlessly in GitHub Actions, GitLab CI, and other automation:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
# Gitea / GitLab CI
|
# .gitlab-ci.yml
|
||||||
test:
|
test:
|
||||||
image: code.foss.global/host.today/ht-docker-node:latest
|
image: registry.gitlab.com/hosttoday/ht-docker-node:latest
|
||||||
script:
|
script:
|
||||||
- nvm install 22 && nvm use 22
|
- nvm install 18
|
||||||
- pnpm ci && pnpm test
|
- nvm use 18
|
||||||
|
- npm ci
|
||||||
|
- npm test
|
||||||
|
|
||||||
|
# Test on multiple Node versions
|
||||||
|
- nvm install 20
|
||||||
|
- nvm use 20
|
||||||
|
- npm test
|
||||||
```
|
```
|
||||||
|
|
||||||
**Interactive shells** and **`docker exec`**:
|
### 🏔️ Alpine: Production-Optimized
|
||||||
|
|
||||||
```bash
|
|
||||||
docker exec -it mycontainer bash
|
|
||||||
$ nvm ls # lists installed versions
|
|
||||||
$ nvm install 20 # installs Node 20
|
|
||||||
$ nvm use 20 # switches immediately
|
|
||||||
```
|
|
||||||
|
|
||||||
> ⚠️ **Note on version persistence across RUN steps:** Each Dockerfile `RUN` starts a new shell. Use `nvm alias default <version>` to persist your choice, or chain commands in a single `RUN`.
|
|
||||||
|
|
||||||
### 🛡️ tini — Proper Init for Containers
|
|
||||||
|
|
||||||
All images use [tini](https://github.com/krallin/tini) as PID 1:
|
|
||||||
|
|
||||||
```
|
|
||||||
tini → docker-entrypoint.sh → your command
|
|
||||||
```
|
|
||||||
|
|
||||||
This means:
|
|
||||||
- ✅ Signals (SIGTERM, SIGINT) are forwarded correctly to your app
|
|
||||||
- ✅ Zombie processes are reaped automatically
|
|
||||||
- ✅ Clean container shutdown — no orphaned processes
|
|
||||||
|
|
||||||
### 🌐 Chromium (Ubuntu `:latest` only)
|
|
||||||
|
|
||||||
Puppeteer and Playwright work out of the box:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
const browser = await puppeteer.launch(); // uses /usr/bin/chromium-browser
|
|
||||||
```
|
|
||||||
|
|
||||||
Environment variables `PUPPETEER_EXECUTABLE_PATH` and `CHROME_BIN` are pre-set. Multi-arch compatible (amd64 + arm64).
|
|
||||||
|
|
||||||
### 🏔️ Alpine — Production Optimized
|
|
||||||
|
|
||||||
```dockerfile
|
```dockerfile
|
||||||
FROM code.foss.global/host.today/ht-docker-node:alpine-node
|
FROM registry.gitlab.com/hosttoday/ht-docker-node:alpine-node
|
||||||
|
|
||||||
RUN nvm install 22 && nvm use 22
|
# Same NVM commands as Ubuntu
|
||||||
RUN pnpm install && pnpm build
|
RUN nvm install 20 && nvm use 20
|
||||||
# Result: ~200 MB image
|
RUN pnpm install
|
||||||
|
RUN pnpm build
|
||||||
|
|
||||||
|
# Result: 200MB image vs 800MB+ Ubuntu
|
||||||
```
|
```
|
||||||
|
|
||||||
Why Alpine?
|
**Why Alpine?**
|
||||||
- ✅ **60–75 % smaller** → Faster pulls, faster deploys
|
- ✅ **60-75% smaller images** → Faster deployments
|
||||||
- ✅ **Reduced attack surface** → Fewer packages = fewer CVEs
|
- ✅ **Reduced attack surface** → Better security
|
||||||
- ✅ **Native musl builds** → No glibc compatibility layer
|
- ✅ **Native musl builds** → No glibc compatibility issues
|
||||||
- ✅ **Multi-arch** → Same tag works on x64 and ARM64
|
- ✅ **Multi-arch support** → One image, all platforms
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 🛠️ Usage Examples
|
## 🛠️ Usage Examples
|
||||||
|
|
||||||
### Basic Node.js App
|
### Basic Node.js Application
|
||||||
|
|
||||||
```dockerfile
|
```dockerfile
|
||||||
FROM code.foss.global/host.today/ht-docker-node:alpine-node
|
FROM registry.gitlab.com/hosttoday/ht-docker-node:alpine-node
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
# NVM is already configured, Node.js LTS is ready
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
RUN pnpm install
|
RUN pnpm install
|
||||||
|
|
||||||
@@ -171,113 +129,135 @@ CMD ["node", "dist/index.js"]
|
|||||||
### Multi-Version Testing
|
### Multi-Version Testing
|
||||||
|
|
||||||
```dockerfile
|
```dockerfile
|
||||||
FROM code.foss.global/host.today/ht-docker-node:latest
|
FROM registry.gitlab.com/hosttoday/ht-docker-node:latest
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
|
|
||||||
RUN nvm install 20 && nvm use 20 && npm ci && npm test
|
# Test on Node 18
|
||||||
RUN nvm install 22 && nvm use 22 && npm ci && npm test
|
RUN nvm install 18 && nvm use 18 && npm ci && npm test
|
||||||
|
|
||||||
# Ship with Node 22
|
# Test on Node 20
|
||||||
RUN nvm alias default 22 && npm run build
|
RUN nvm install 20 && nvm use 20 && npm ci && npm test
|
||||||
|
|
||||||
|
# Use Node 20 for production build
|
||||||
|
RUN nvm alias default 20 && npm run build
|
||||||
```
|
```
|
||||||
|
|
||||||
### Deno Application
|
### Deno Application
|
||||||
|
|
||||||
```dockerfile
|
```dockerfile
|
||||||
FROM code.foss.global/host.today/ht-docker-node:alpine-deno
|
FROM registry.gitlab.com/hosttoday/ht-docker-node:alpine-deno
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Both Deno and Node.js are available
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Deno and Node.js are both available
|
# Use Deno for the app
|
||||||
CMD ["deno", "run", "--allow-net", "main.ts"]
|
CMD ["deno", "run", "--allow-net", "main.ts"]
|
||||||
|
|
||||||
|
# Or switch to Node.js if needed
|
||||||
|
# RUN nvm use default && npm install
|
||||||
```
|
```
|
||||||
|
|
||||||
### Bun for Ultra-Fast Installs
|
### Bun for Ultra-Fast Builds
|
||||||
|
|
||||||
```dockerfile
|
```dockerfile
|
||||||
FROM code.foss.global/host.today/ht-docker-node:alpine-bun
|
FROM registry.gitlab.com/hosttoday/ht-docker-node:alpine-bun
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Bun is 10-20x faster for package installation
|
||||||
COPY package.json bun.lockb ./
|
COPY package.json bun.lockb ./
|
||||||
RUN bun install
|
RUN bun install
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN bun run build
|
RUN bun run build
|
||||||
|
|
||||||
|
# Node.js also available via NVM
|
||||||
CMD ["bun", "run", "start"]
|
CMD ["bun", "run", "start"]
|
||||||
```
|
```
|
||||||
|
|
||||||
### TypeScript Multi-Stage Build
|
### TypeScript Project with Multi-Stage Build
|
||||||
|
|
||||||
```dockerfile
|
```dockerfile
|
||||||
# Build stage
|
# Build stage
|
||||||
FROM code.foss.global/host.today/ht-docker-node:alpine-node AS builder
|
FROM registry.gitlab.com/hosttoday/ht-docker-node:alpine-node AS builder
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
RUN pnpm install
|
RUN pnpm install
|
||||||
|
|
||||||
COPY tsconfig.json ./
|
COPY tsconfig.json ./
|
||||||
COPY src ./src
|
COPY src ./src
|
||||||
RUN pnpm build
|
RUN pnpm build
|
||||||
|
|
||||||
# Production stage — only runtime deps
|
# Production stage
|
||||||
FROM code.foss.global/host.today/ht-docker-node:alpine-node
|
FROM registry.gitlab.com/hosttoday/ht-docker-node:alpine-node
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
RUN pnpm install --prod
|
RUN pnpm install --prod
|
||||||
|
|
||||||
COPY --from=builder /app/dist ./dist
|
COPY --from=builder /app/dist ./dist
|
||||||
EXPOSE 3000
|
|
||||||
CMD ["node", "dist/index.js"]
|
|
||||||
```
|
|
||||||
|
|
||||||
### Production-Hardened Setup
|
|
||||||
|
|
||||||
```dockerfile
|
|
||||||
FROM code.foss.global/host.today/ht-docker-node:alpine-node
|
|
||||||
|
|
||||||
# Non-root user
|
|
||||||
RUN addgroup -g 1001 -S nodejs && adduser -S nodejs -u 1001
|
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
COPY package*.json ./
|
|
||||||
RUN pnpm install --frozen-lockfile && pnpm cache clean
|
|
||||||
|
|
||||||
COPY --chown=nodejs:nodejs . .
|
|
||||||
RUN pnpm build
|
|
||||||
|
|
||||||
USER nodejs
|
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
CMD ["node", "dist/index.js"]
|
CMD ["node", "dist/index.js"]
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 🔧 NVM Cheat Sheet
|
## 🔧 NVM Usage Patterns
|
||||||
|
|
||||||
|
### In Dockerfiles
|
||||||
|
|
||||||
|
```dockerfile
|
||||||
|
# Install specific version
|
||||||
|
RUN nvm install 18.20.0
|
||||||
|
|
||||||
|
# Use version
|
||||||
|
RUN nvm use 18
|
||||||
|
|
||||||
|
# Set default (persists across RUN commands)
|
||||||
|
RUN nvm alias default 18
|
||||||
|
|
||||||
|
# Chain commands in single RUN
|
||||||
|
RUN nvm install 19 && nvm use 19 && npm install
|
||||||
|
```
|
||||||
|
|
||||||
|
### In CI/CD Scripts
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Install a specific version
|
#!/bin/bash
|
||||||
nvm install 22.5.0
|
# NVM is automatically available in bash scripts
|
||||||
|
|
||||||
# Use a version (current shell)
|
nvm install 20
|
||||||
nvm use 22
|
nvm use 20
|
||||||
|
npm ci
|
||||||
|
npm test
|
||||||
|
```
|
||||||
|
|
||||||
# Set default (persists across shells / RUN steps)
|
### Version Switching
|
||||||
nvm alias default 22
|
|
||||||
|
|
||||||
# Install and switch to latest LTS
|
|
||||||
nvm install --lts && nvm use --lts
|
|
||||||
|
|
||||||
|
```bash
|
||||||
# List installed versions
|
# List installed versions
|
||||||
nvm ls
|
nvm ls
|
||||||
|
|
||||||
# Chain in a single Dockerfile RUN
|
# Install and switch to latest LTS
|
||||||
RUN nvm install 22 && nvm use 22 && npm ci && npm test
|
nvm install --lts
|
||||||
|
nvm use --lts
|
||||||
|
|
||||||
|
# Install specific version
|
||||||
|
nvm install 18.20.0
|
||||||
|
|
||||||
|
# Use installed version
|
||||||
|
nvm use 18
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 🏗️ Building the Images
|
## 🏗️ Building Multi-Architecture Images
|
||||||
|
|
||||||
This project uses [@git.zone/tsdocker](https://code.foss.global/git.zone/tsdocker) for Docker image management.
|
This project uses [@git.zone/tsdocker](https://code.foss.global/git.zone/tsdocker) for Docker image management.
|
||||||
|
|
||||||
@@ -285,59 +265,163 @@ This project uses [@git.zone/tsdocker](https://code.foss.global/git.zone/tsdocke
|
|||||||
# Install tsdocker
|
# Install tsdocker
|
||||||
pnpm install -g @git.zone/tsdocker@latest
|
pnpm install -g @git.zone/tsdocker@latest
|
||||||
|
|
||||||
# Discover all Dockerfiles and their tags
|
# List all discovered Dockerfiles and their tags
|
||||||
tsdocker list
|
tsdocker list
|
||||||
|
|
||||||
# Build all images (multi-arch: amd64 + arm64)
|
# Build all images (multi-arch: amd64 + arm64)
|
||||||
tsdocker build
|
tsdocker build
|
||||||
|
|
||||||
# Run all test scripts
|
# Test all images
|
||||||
tsdocker test
|
tsdocker test
|
||||||
|
|
||||||
# Push to a specific registry
|
# Push to a specific registry
|
||||||
tsdocker push code.foss.global
|
tsdocker push code.foss.global
|
||||||
```
|
```
|
||||||
|
|
||||||
### Manual Build (single image)
|
### Manual Builds
|
||||||
|
|
||||||
|
For building individual images manually:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
# Build for both amd64 and arm64, push to registry
|
||||||
docker buildx build \
|
docker buildx build \
|
||||||
--platform linux/amd64,linux/arm64 \
|
--platform linux/amd64,linux/arm64 \
|
||||||
-f Dockerfile_alpine-node \
|
-f Dockerfile_alpine-node \
|
||||||
-t your-registry/your-image:alpine-node \
|
-t your-registry/your-image:alpine-node \
|
||||||
--push .
|
--push \
|
||||||
|
.
|
||||||
```
|
```
|
||||||
|
|
||||||
### Image Dependency Chain
|
|
||||||
|
|
||||||
Some images depend on others being in the registry first:
|
|
||||||
|
|
||||||
```
|
|
||||||
Dockerfile (:latest) ──► Dockerfile_lts (:lts)
|
|
||||||
──► Dockerfile_szci (:szci)
|
|
||||||
──► Dockerfile_fossglobal_preinstalled_* (:fossglobal_preinstalled_<ver>)
|
|
||||||
|
|
||||||
Dockerfile_alpine-node (:alpine-node)
|
|
||||||
──► Dockerfile_alpine-szci (:alpine-szci)
|
|
||||||
```
|
|
||||||
|
|
||||||
The standalone Alpine images (`:alpine-bun`, `:alpine-deno`) have no registry dependencies.
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 📊 Image Comparison
|
## 📚 Advanced Examples
|
||||||
|
|
||||||
| Feature | Ubuntu `:latest` | Alpine `:alpine-node` |
|
### Docker Compose Setup
|
||||||
|---------|------------------|----------------------|
|
|
||||||
| Base Size | ~900 MB | ~200 MB |
|
```yaml
|
||||||
| Build Tools | ✅ Full (gcc, g++, make, python3) | ⚠️ Install separately (`apk add build-base`) |
|
version: '3.8'
|
||||||
| Chromium | ✅ Pre-installed | ❌ |
|
|
||||||
| MongoDB | ✅ 8.0 | ❌ |
|
services:
|
||||||
| Runtimes | Node + Bun + Deno + pnpm | Node + pnpm |
|
app:
|
||||||
| Compatibility | ✅ Maximum (glibc) | ✅ Good (musl) |
|
image: registry.gitlab.com/hosttoday/ht-docker-node:alpine-node
|
||||||
| Multi-arch | ✅ amd64, arm64 | ✅ amd64, arm64 |
|
working_dir: /app
|
||||||
| tini init | ✅ | ✅ |
|
volumes:
|
||||||
| Best for | Complex builds, E2E tests, full-stack dev | Production, CI/CD, microservices |
|
- .:/app
|
||||||
|
- /app/node_modules
|
||||||
|
ports:
|
||||||
|
- "3000:3000"
|
||||||
|
environment:
|
||||||
|
- NODE_ENV=development
|
||||||
|
command: sh -c "pnpm install && pnpm dev"
|
||||||
|
|
||||||
|
mongo:
|
||||||
|
image: mongo:latest
|
||||||
|
ports:
|
||||||
|
- "27017:27017"
|
||||||
|
```
|
||||||
|
|
||||||
|
### GitHub Actions Workflow
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
name: CI
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: registry.gitlab.com/hosttoday/ht-docker-node:alpine-node
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: pnpm install
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: pnpm test
|
||||||
|
|
||||||
|
- name: Test on multiple Node versions
|
||||||
|
run: |
|
||||||
|
for version in 18 20; do
|
||||||
|
echo "Testing on Node $version"
|
||||||
|
nvm install $version
|
||||||
|
nvm use $version
|
||||||
|
pnpm test
|
||||||
|
done
|
||||||
|
```
|
||||||
|
|
||||||
|
### Custom Base Image
|
||||||
|
|
||||||
|
```dockerfile
|
||||||
|
FROM registry.gitlab.com/hosttoday/ht-docker-node:alpine-node
|
||||||
|
|
||||||
|
# Add your custom tools
|
||||||
|
RUN apk add --no-cache \
|
||||||
|
python3 \
|
||||||
|
make \
|
||||||
|
g++ \
|
||||||
|
postgresql-client
|
||||||
|
|
||||||
|
# Configure your environment
|
||||||
|
ENV DATABASE_URL="postgresql://localhost/mydb"
|
||||||
|
|
||||||
|
# Your app setup
|
||||||
|
WORKDIR /app
|
||||||
|
COPY package.json pnpm-lock.yaml ./
|
||||||
|
RUN pnpm install
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
CMD ["pnpm", "start"]
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🎓 Best Practices
|
||||||
|
|
||||||
|
### ✅ DO
|
||||||
|
|
||||||
|
- **Use Alpine images for production** (smaller, more secure)
|
||||||
|
- **Pin Node versions in production** (`nvm alias default 20.11.0`)
|
||||||
|
- **Use multi-stage builds** to reduce final image size
|
||||||
|
- **Leverage build cache** with proper COPY order
|
||||||
|
- **Run as non-root user** in production
|
||||||
|
|
||||||
|
### ❌ DON'T
|
||||||
|
|
||||||
|
- Don't use `:latest` tag in production (be explicit)
|
||||||
|
- Don't install packages globally if local works
|
||||||
|
- Don't copy `node_modules` (let the build install them)
|
||||||
|
- Don't skip `.dockerignore` (keeps builds fast)
|
||||||
|
|
||||||
|
### 🔒 Security Tips
|
||||||
|
|
||||||
|
```dockerfile
|
||||||
|
# Example: Production-hardened Dockerfile
|
||||||
|
FROM registry.gitlab.com/hosttoday/ht-docker-node:alpine-node
|
||||||
|
|
||||||
|
# Create non-root user
|
||||||
|
RUN addgroup -g 1001 -S nodejs && adduser -S nodejs -u 1001
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Install deps as root
|
||||||
|
COPY package*.json ./
|
||||||
|
RUN pnpm install --frozen-lockfile && pnpm cache clean
|
||||||
|
|
||||||
|
# Copy source
|
||||||
|
COPY --chown=nodejs:nodejs . .
|
||||||
|
|
||||||
|
# Build
|
||||||
|
RUN pnpm build
|
||||||
|
|
||||||
|
# Switch to non-root user
|
||||||
|
USER nodejs
|
||||||
|
|
||||||
|
EXPOSE 3000
|
||||||
|
CMD ["node", "dist/index.js"]
|
||||||
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -345,64 +429,92 @@ The standalone Alpine images (`:alpine-bun`, `:alpine-deno`) have no registry de
|
|||||||
|
|
||||||
### NVM command not found
|
### NVM command not found
|
||||||
|
|
||||||
Shouldn't happen in our images, but if it does:
|
If NVM isn't available in your script:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
# Manually source NVM (shouldn't be needed in our images)
|
||||||
export NVM_DIR="/usr/local/nvm"
|
export NVM_DIR="/usr/local/nvm"
|
||||||
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
|
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
|
||||||
```
|
```
|
||||||
|
|
||||||
### Alpine native module build failures
|
### Alpine native module build failures
|
||||||
|
|
||||||
Some npm packages require native build tools:
|
Some npm packages need build tools:
|
||||||
|
|
||||||
```dockerfile
|
```dockerfile
|
||||||
FROM code.foss.global/host.today/ht-docker-node:alpine-node
|
FROM registry.gitlab.com/hosttoday/ht-docker-node:alpine-node
|
||||||
|
|
||||||
|
# Install build dependencies
|
||||||
RUN apk add --no-cache python3 make g++
|
RUN apk add --no-cache python3 make g++
|
||||||
|
|
||||||
|
# Now install your packages
|
||||||
RUN pnpm install
|
RUN pnpm install
|
||||||
```
|
```
|
||||||
|
|
||||||
Or use `:alpine-szci` which ships with build tools pre-installed.
|
### Permission denied errors
|
||||||
|
|
||||||
### Version not persisting across RUN steps
|
|
||||||
|
|
||||||
Each Dockerfile `RUN` creates a new shell. Use `nvm alias default`:
|
|
||||||
|
|
||||||
```dockerfile
|
```dockerfile
|
||||||
RUN nvm install 22 && nvm alias default 22
|
# Fix ownership before switching users
|
||||||
RUN node -v # ✅ v22.x.x
|
COPY --chown=node:node . .
|
||||||
|
USER node
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 🔗 Links
|
## 📊 Image Comparison
|
||||||
|
|
||||||
- **Source Code:** [code.foss.global/host.today/ht-docker-node](https://code.foss.global/host.today/ht-docker-node)
|
| Feature | Ubuntu `:latest` | Alpine `:alpine-node` |
|
||||||
- **NVM:** [github.com/nvm-sh/nvm](https://github.com/nvm-sh/nvm)
|
|---------|------------------|----------------------|
|
||||||
- **tini:** [github.com/krallin/tini](https://github.com/krallin/tini)
|
| Base Size | ~900MB | ~200MB |
|
||||||
- **tsdocker:** [code.foss.global/git.zone/tsdocker](https://code.foss.global/git.zone/tsdocker)
|
| Build Tools | ✅ Full | ⚠️ Install separately |
|
||||||
- **Alpine Linux:** [alpinelinux.org](https://alpinelinux.org/)
|
| Compatibility | ✅ Maximum | ✅ Good (musl) |
|
||||||
- **Node.js Unofficial Builds:** [unofficial-builds.nodejs.org](https://unofficial-builds.nodejs.org/) (musl support)
|
| Multi-arch | ❌ amd64 only | ✅ amd64, arm64 |
|
||||||
|
| Security | ✅ Good | ✅ Excellent (smaller surface) |
|
||||||
|
| Speed | Fast | Faster (smaller) |
|
||||||
|
| Use Case | Complex builds | Production, CI/CD |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🔗 Useful Links
|
||||||
|
|
||||||
|
- **GitHub Repository:** https://github.com/HostToday/ht-docker-node
|
||||||
|
- **Docker Hub:** registry.gitlab.com/hosttoday/ht-docker-node
|
||||||
|
- **NVM Documentation:** https://github.com/nvm-sh/nvm
|
||||||
|
- **Alpine Linux:** https://alpinelinux.org/
|
||||||
|
- **Node.js Unofficial Builds:** https://unofficial-builds.nodejs.org/ (musl support)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📋 Changelog
|
||||||
|
|
||||||
|
See [changelog.md](changelog.md) for detailed version history.
|
||||||
|
|
||||||
|
**Latest Updates (v5.0.148):**
|
||||||
|
- ✨ Multi-architecture Alpine images (amd64 + arm64)
|
||||||
|
- ✨ Native Deno support via Alpine edge
|
||||||
|
- ✨ Bun runtime integration
|
||||||
|
- ✨ Simplified image tags (`:alpine-node` vs `:alpine-x64-node`)
|
||||||
|
- 🚀 docker buildx integration for cross-platform builds
|
||||||
|
- 📦 pnpm preinstalled on Alpine Node image
|
||||||
|
- 🔧 NVM 0.40.1 with improved Alpine/musl support
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## License and Legal Information
|
## License and Legal Information
|
||||||
|
|
||||||
This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [LICENSE](./LICENSE) file.
|
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
|
||||||
|
|
||||||
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
|
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
### Trademarks
|
### Trademarks
|
||||||
|
|
||||||
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH or third parties, and are not included within the scope of the MIT license granted herein.
|
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
|
||||||
|
|
||||||
Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines or the guidelines of the respective third-party owners, and any usage must be approved in writing. Third-party trademarks used herein are the property of their respective owners and used only in a descriptive manner, e.g. for an implementation of an API or similar.
|
|
||||||
|
|
||||||
### Company Information
|
### Company Information
|
||||||
|
|
||||||
Task Venture Capital GmbH
|
Task Venture Capital GmbH
|
||||||
Registered at District Court Bremen HRB 35230 HB, Germany
|
Registered at District court Bremen HRB 35230 HB, Germany
|
||||||
|
|
||||||
For any legal inquiries or further information, please contact us via email at hello@task.vc.
|
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
|
||||||
|
|
||||||
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
|
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
|
||||||
|
|||||||
13
test/test_npmci.sh
Normal file
13
test/test_npmci.sh
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# check if npmci is available
|
||||||
|
npm init -y
|
||||||
|
npmci -v
|
||||||
|
|
||||||
|
# TODO update npmci to not require package.json
|
||||||
|
npmci node install stable
|
||||||
|
|
||||||
|
# check if npm picks it up
|
||||||
|
npmci command pnpm install -g @gitzone/tsrun
|
||||||
|
npmci command tsrun -v
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
set -e
|
|
||||||
|
|
||||||
# check if szci is available
|
|
||||||
npm init -y
|
|
||||||
szci -v
|
|
||||||
|
|
||||||
# TODO update szci to not require package.json
|
|
||||||
szci node install stable
|
|
||||||
|
|
||||||
# check if npm picks it up
|
|
||||||
szci command pnpm install -g @gitzone/tsrun
|
|
||||||
szci command tsrun -v
|
|
||||||
Reference in New Issue
Block a user