Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(node-distroless): add node-distroless image combines google dist… #31

Merged
merged 1 commit into from
Nov 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
}