Skip to content

Commit a99d80f

Browse files
committed
docs: update document
1 parent a7e2e3d commit a99d80f

File tree

6 files changed

+124
-76
lines changed

6 files changed

+124
-76
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ This project is mainly used internally within ebizbase projects but we have deci
2626
| [npm-playwright][npm-playwright-readme] | This feature will be install playwright via npm with os dependencies and browser binaries |
2727

2828

29-
### devconainer prebuild images
29+
### devconainer images
3030

3131
| Name | Description|
3232
| ---------- | ---------- |
@@ -39,7 +39,7 @@ This project is mainly used internally within ebizbase projects but we have deci
3939
### npm packages
4040
| Name | Description|
4141
| ---------- | ---------- |
42-
| [nx-devkit][nx-devkit-readme] | The NX plugin to build, push and analyze image |
42+
| [nx-devkit][nx-devkit-readme] | It contains many utility functions for interactive with nx workspace and projects |
4343

4444
### nx plugins
4545
| Name | Description|

devcontainer-features/omz-plugin/README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This feature will install and active plugins for oh my zsh
1212
"zsh-syntax-highlighting:https://github.com/zsh-users/zsh-syntax-highlighting.git",
1313
"zsh-autosuggestions:https://github.com/zsh-users/zsh-autosuggestions/archive/refs/tags/v0.7.1.zip"
1414
],
15-
"deleteInactive": false, // you can delete inactive plugins for lighter image
15+
"deleteInactive": false,
1616
}
1717
}
1818
```
@@ -26,4 +26,5 @@ This feature will install and active plugins for oh my zsh
2626
| deleteInactive | Should delete inactive plugins or not | bool | false |
2727

2828
**(\*)** See [list of oh-my-zsh preinstalled plugins](https://github.com/ohmyzsh/ohmyzsh/wiki/plugins)
29-
**(\*\*)** We support zip release url or git url. See example [here](https://github.com/ebizbase/dev-infras/blob/fff3b6ab9dd104f899b1a67c72e65c21f6f4e310/devcontainer-images/base-devcontainer/.devcontainer/devcontainer.json#L30)
29+
30+
**(\*\*)** We support zip release url or git url. See example [here](https://github.com/ebizbase/dev-infras/blob/main/devcontainer-images/base-devcontainer/devcontainer.json)

packages/nx-devkit/README.md

+43-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,49 @@
11
# nx-devkit
22

3-
This library was generated with [Nx](https://nx.dev).
3+
It contains many utility functions for interactive with nx workspace and projects
44

5-
## Building
65

7-
Run `nx build nx-devkit` to build the library.
6+
## Installation
87

9-
## Running unit tests
8+
To install the package, run:
109

11-
Run `nx test nx-devkit` to execute the unit tests via [Jest](https://jestjs.io).
10+
```bash
11+
npm install @ebizbase/nx-devkit
12+
```
13+
14+
## Usage
15+
16+
Here is an example of how to use the `DockerUtils`:
17+
18+
```typescript
19+
import { DockerUtils } from '@ebizbase/nx-devkit';
20+
21+
const dockerService = new DockerUtils();
22+
23+
// Check docker installed and docker daemon is running
24+
if (!dockerService.checkDockerInstalled(context.isVerbose)) {
25+
logger.error('Docker is not installed or docker daemon is not running');
26+
return { success: false };
27+
}
28+
29+
// Determine using build or buildx for building Docker image
30+
const isBuildxInstalled = dockerService.checkBuildxInstalled(context.isVerbose);
31+
if (!isBuildxInstalled) {
32+
logger.warn(
33+
'Buildx is not installed falling back to docker build. Docker buildx is not installed so performance may be degraded'
34+
);
35+
}
36+
const buildCommand = isBuildxInstalled ? ['docker', 'buildx', 'build'] : ['docker', 'build'];
37+
```
38+
39+
40+
Here is an example of how to use the `DockerUtils`:
41+
42+
```typescript
43+
import { ProjectUtils } from '@ebizbase/nx-devkit';
44+
const executor: PromiseExecutor<DockerExecutorSchema> = async (options, context) => {
45+
const projectUtils = new ProjectUtils(context);
46+
const projectRoot: projectUtils.getProjectRoot();
47+
const projectName: projectUtils.getProjectName();
48+
};
49+
```

packages/nx-devkit/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@ebizbase/nx-devkit",
33
"version": "1.0.0",
44
"private": false,
5-
"description": "The nx devkit utils",
5+
"description": "It contains many utility functions for interactive with nx workspace and projects",
66
"bugs": "https://github.com/ebizbase/dev-infras/issues",
77
"repository": {
88
"type": "git",

packages/nx-dive/README.md

+74-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,80 @@
11
# nx-dive
2+
The NX plugin to using [dive](https://github.com/wagoodman/dive) for analyze image
23

3-
This library was generated with [Nx](https://nx.dev).
4+
## Prerequisites
45

5-
## Building
6+
- Ensure you have Docker installed and running on your machine.
7+
- Ensure you have NX installed in your workspace.
68

7-
Run `nx build nx-dive` to build the library.
9+
## Installation
810

9-
## Running unit tests
11+
To install plugin run the following command:
1012

11-
Run `nx test nx-dive` to execute the unit tests via [Jest](https://jestjs.io).
13+
```bash
14+
npm install -D @ebizbase/nx-dive
15+
yarn add -D @ebizbase/nx-dive
16+
pnpm add -D @ebizbase/nx-dive
17+
```
18+
19+
## Analyze docker image
20+
21+
The example of @ebizbase/nx-dive:analyze executor
22+
23+
```json
24+
{
25+
"targets": {
26+
"analyze": {
27+
"executor": "@ebizbase/nx-docker:analyze",
28+
"options": {
29+
"image": "your-app:latest"
30+
}
31+
}
32+
}
33+
}
34+
```
35+
36+
You can validate of image with `ci` option like this
37+
38+
```json
39+
{
40+
"targets": {
41+
"analyze": {
42+
"dependsOn": ["build"],
43+
"executor": "@ebizbase/nx-docker:analyze",
44+
"options": {
45+
"image": "your-app:latest",
46+
"ci": true,
47+
"highestUserWastedRatio": 0.1
48+
}
49+
}
50+
}
51+
}
52+
```
53+
54+
Or in ci/cd you can overwrite config with template `--[options]=value.` Example
55+
56+
```shell
57+
nx run project-name:analyze --ci --highestUserWastedRatio 0.1
58+
```
59+
60+
So ci will failed when wasted ratio greater than 10%
61+
62+
Bellow is all options of @ebizbase/nx-docker:analyze
63+
64+
| Option | Type | Description | Default |
65+
| ------------------------ | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
66+
| `ci` | boolean | Skip the interactive TUI and validate against CI rules | `false` |
67+
| `highestUserWastedRatio` | number | (only valid with --ci given) highest allowable percentage of bytes wasted (as a ratio between 0-1), otherwise CI validation will fail. (default 0.1) | |
68+
| `highestUserWastedBytes` | number | (only valid with --ci given) highest allowable bytes wasted, otherwise CI validation will fail. Set -1 mean disabled | |
69+
| `lowestEfficiencyRatio` | number | (only valid with --ci given) lowest allowable image efficiency (as a ratio between 0-1), otherwise CI validation will fail. (default 0.9) | |
70+
| `ignoreError` | boolean | Ignore image parsing errors and run the analysis anyway | `false` |
71+
| `source` | string | The container engine to fetch the image from. Allowed values: docker, podman, docker-archive (default docker) | `docker` |
72+
| `image` | string | The image to analyze | |
73+
| `dockerSocket` | string | The docker socket to use for the analysis | |
74+
| `version` | string | The version of dive to use | |
75+
76+
To check all possible options please check this [schema.json](./src/executors/analyze/schema.json) file
77+
78+
## License
79+
80+
This project is licensed under the MIT License.

packages/nx-docker/README.md

+1-61
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ The NX plugin to build, push containers, and analyze images from your applicatio
99

1010
## Installation
1111

12-
To install the `nx-docker` plugin, run the following command:
12+
To install plugin run the following command:
1313

1414
```bash
1515
npm install -D @ebizbase/nx-docker
@@ -90,66 +90,6 @@ Bellow is all options of @ebizbase/nx-docker:build
9090
9191
To check all possible options please check this [schema.json](./src/executors/build/schema.json) file
9292
93-
## Analyze image
94-
95-
@ebizbase/nx-docker:analyze using [dive](https://github.com/wagoodman/dive) for analyze image
96-
97-
The example of analyze executor
98-
99-
```json
100-
{
101-
"targets": {
102-
"analyze": {
103-
"dependsOn": ["build"],
104-
"executor": "@ebizbase/nx-docker:analyze",
105-
"options": {
106-
"image": "your-app:latest"
107-
}
108-
}
109-
}
110-
}
111-
```
112-
113-
You can validate of image with `ci` option like this
114-
115-
```json
116-
{
117-
"targets": {
118-
"analyze": {
119-
"dependsOn": ["build"],
120-
"executor": "@ebizbase/nx-docker:analyze",
121-
"options": {
122-
"image": "your-app:latest",
123-
"ci": true,
124-
"highestUserWastedRatio": 0.1
125-
}
126-
}
127-
}
128-
}
129-
```
130-
131-
Or in ci/cd you can overwrite config with template `--[options]=value.` Example
132-
133-
```shell
134-
nx run project-name:analyze --ci --highestUserWastedRatio 0.1
135-
```
136-
137-
So ci will failed when wasted ratio greater than 10%
138-
139-
Bellow is all options of @ebizbase/nx-docker:analyze
140-
141-
| Option | Type | Description | Default |
142-
| ------------------------ | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
143-
| `ci` | boolean | Skip the interactive TUI and validate against CI rules | `false` |
144-
| `highestUserWastedRatio` | number | (only valid with --ci given) highest allowable percentage of bytes wasted (as a ratio between 0-1), otherwise CI validation will fail. (default 0.1) | |
145-
| `highestUserWastedBytes` | number | (only valid with --ci given) highest allowable bytes wasted, otherwise CI validation will fail. Set -1 mean disabled | |
146-
| `lowestEfficiencyRatio` | number | (only valid with --ci given) lowest allowable image efficiency (as a ratio between 0-1), otherwise CI validation will fail. (default 0.9) | |
147-
| `ignoreError` | boolean | Ignore image parsing errors and run the analysis anyway | `false` |
148-
| `source` | string | The container engine to fetch the image from. Allowed values: docker, podman, docker-archive (default docker) | `docker` |
149-
| `image` | string | The image to analyze | |
150-
| `dockerSocket` | string | The docker socket to use for the analysis | |
151-
| `version` | string | The version of dive to use | |
152-
15393
## License
15494
15595
This project is licensed under the MIT License.

0 commit comments

Comments
 (0)