Skip to content

Commit

Permalink
feat(node-distroless): add node-distroless image combines google dist…
Browse files Browse the repository at this point in the history
…roless and dump-init
  • Loading branch information
johnitvn committed Nov 24, 2024
1 parent a99d80f commit 15df91a
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 1 deletion.
6 changes: 6 additions & 0 deletions images/node-distroless/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM node:22-alpine AS init
RUN apk add --no-cache dumb-init

FROM gcr.io/distroless/nodejs22:latest AS runtime

Check warning on line 4 in images/node-distroless/Dockerfile

View check run for this annotation

codefactor.io / CodeFactor

images/node-distroless/Dockerfile#L4

Using latest is prone to errors if the image will ever update. Pin the version explicitly to a release tag. (DL3007)
COPY --from=init /usr/bin/dumb-init /usr/bin/dumb-init
ENTRYPOINT [ "/usr/bin/dumb-init", "--", "/nodejs/bin/node" ]
16 changes: 16 additions & 0 deletions images/node-distroless/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# node-distroless

This image combines the compactness and security of distroless with the convenience of dumb-init for process management, making Node.js applications run more stably in a container environment.

> This image is maintained with node latest LTS version
## Usage

The simple usage example

```dockerfile
FROM ghcr.io/ebizbase/node-distroless
WORKDIR /usr/src/app
COPY . .
CMD [ "index.js" ]
```
32 changes: 32 additions & 0 deletions images/node-distroless/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "node-distroless",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "library",
"metadata": {
"version": "0.0.0"
},
"tags": [],
"targets": {
"build": {
"executor": "@ebizbase/nx-docker:build",
"options": {
"tags": ["node-distroless:edge"],
"outputs": ["type=docker"]
}
},
"test": {
"dependsOn": ["build"],
"executor": "nx:run-commands",
"options": {
"command": "docker run --rm node-distroless:edge -e 'console.log(process.version)'"
}
},
"publish": {
"executor": "@ebizbase/nx-docker:build",
"options": {
"tags": ["ghcr.io/ebizbase/node-distroless"],
"outputs": ["type=image"]
}
}
}
}
10 changes: 10 additions & 0 deletions release-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,16 @@
"jsonpath": "$.metadata.version"
}
]
},
"images/node-distroless": {
"package-name": "node-distroless",
"extra-files": [
{
"type": "json",
"path": "project.json",
"jsonpath": "$.metadata.version"
}
]
}
}
}
3 changes: 2 additions & 1 deletion release-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
"devcontainer-images/node-devcontainer": "1.0.0",
"devcontainer-images/node-dind-devcontainer": "1.0.0",
"devcontainer-images/node-dind-playwright-devcontainer": "1.0.0",
"devcontainer-images/node-playwright-devcontainer": "1.0.0"
"devcontainer-images/node-playwright-devcontainer": "1.0.0",
"images/node-distroless": "0.0.0"
}

0 comments on commit 15df91a

Please sign in to comment.