From 7b52531c87b7d2e386202e9ee5fbca208761feb9 Mon Sep 17 00:00:00 2001 From: Tareq Hasan Date: Sat, 24 Jan 2026 20:35:26 +0300 Subject: [PATCH] feat: node js image added --- README.MD | 57 +++++++++++++++++++++++++++++++++++++++- node-structure-test.yaml | 28 ++++++++++++++++++++ node/Dockerfile | 10 +++++++ node/build.sh | 18 +++++++++++++ 4 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 node-structure-test.yaml create mode 100644 node/Dockerfile create mode 100755 node/build.sh diff --git a/README.MD b/README.MD index e09d110..bc18bc5 100644 --- a/README.MD +++ b/README.MD @@ -69,5 +69,60 @@ Install [Container Structure Test](https://github.com/GoogleContainerTools/conta ```bash -container-structure-test test --image meghsh/php:8.2 --config structure-test.yaml +container-structure-test test --image meghsh/php:8.2 --config php-structure-test.yaml +``` + +### Node.js (Alpine) + +Docker images for Node.js (Alpine variant), including `yarn`, `pnpm`, and `vite`. + +#### Supported Versions + +- Node 18 +- Node 20 +- Node 22 +- Node 24 +- Node 25 + +### Getting the images + +```bash +# Node 25 (Latest) +docker image pull meghsh/node:25 + +# Node 22 (LTS) +docker image pull meghsh/node:22 +``` + +### Using the images + +One-off commands: + +```bash +docker run --rm meghsh/node:25 node -v +docker run --rm meghsh/node:25 yarn -v +docker run --rm meghsh/node:25 pnpm -v +``` + +With docker-compose: + +```yaml +services: + node: + image: "meghsh/node:25" + volumes: + - "./app:/var/www/html" + command: npm run dev +``` + +### Testing Node.js Images + +To verify the Node.js image structure and installed tools: + +```bash +# Build the image locally (optional, if testing changes) +./node/build.sh + +# Run structure tests +container-structure-test test --image meghsh/node:25 --config node-structure-test.yaml ``` \ No newline at end of file diff --git a/node-structure-test.yaml b/node-structure-test.yaml new file mode 100644 index 0000000..29ba04a --- /dev/null +++ b/node-structure-test.yaml @@ -0,0 +1,28 @@ +schemaVersion: '2.0.0' + +commandTests: + - name: "Node is installed" + command: "node" + args: ["-v"] + expectedOutput: ["v"] + + - name: "Yarn is installed" + command: "yarn" + args: ["-v"] + # expectedOutput: ["1."] # Yarn version might vary, just checking it runs + + - name: "PNPM is installed" + command: "pnpm" + args: ["-v"] + + - name: "Vite is installed" + command: "vite" + args: ["-v"] + expectedOutput: ["vite"] + + - name: "Git is installed" + command: "git" + args: ["--version"] + expectedOutput: ["git version"] + + diff --git a/node/Dockerfile b/node/Dockerfile new file mode 100644 index 0000000..fb5003b --- /dev/null +++ b/node/Dockerfile @@ -0,0 +1,10 @@ +ARG NODE_VERSION=18 +FROM node:${NODE_VERSION}-alpine + +# Install system dependencies +RUN apk add --no-cache git bash + +# Install global packages and clean cache +RUN npm install -g yarn pnpm vite --force && npm cache clean --force + +CMD ["node"] diff --git a/node/build.sh b/node/build.sh new file mode 100755 index 0000000..4903725 --- /dev/null +++ b/node/build.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +export DOCKER_BUILDKIT=1 + +# Build for Node 18 +docker buildx build --platform linux/amd64,linux/arm64 --build-arg NODE_VERSION=18 -t meghsh/node:18 -f node/Dockerfile node --push + +# Build for Node 20 +docker buildx build --platform linux/amd64,linux/arm64 --build-arg NODE_VERSION=20 -t meghsh/node:20 -f node/Dockerfile node --push + +# Build for Node 22 +docker buildx build --platform linux/amd64,linux/arm64 --build-arg NODE_VERSION=22 -t meghsh/node:22 -f node/Dockerfile node --push + +# Build for Node 24 +docker buildx build --platform linux/amd64,linux/arm64 --build-arg NODE_VERSION=24 -t meghsh/node:24 -f node/Dockerfile node --push + +# Build for Node 25 +docker buildx build --platform linux/amd64,linux/arm64 --build-arg NODE_VERSION=25 -t meghsh/node:25 -f node/Dockerfile node --push