You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/guides/nodejs/containerize.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -644,16 +644,16 @@ This Dockerfile implements several strategies to minimize the final image size:
644
644
645
645
**Expected size reduction**: ~50% smaller than standard Node.js images
646
646
647
-
### Step 3: Configure the .dockerignore file
647
+
### Step 2: Configure the .dockerignore file
648
648
649
649
The `.dockerignore` file tells Docker which files and folders to exclude when building the image.
650
650
651
651
> [!NOTE]
652
652
> This helps:
653
653
>
654
-
> 1.Reduce image size
655
-
> 2.Speed up the build process
656
-
> 3.Prevent sensitive or unnecessary files (like `.env`, `.git`, or `node_modules`) from being added to the final image.
654
+
> - Reduce image size
655
+
> - Speed up the build process
656
+
> - Prevent sensitive or unnecessary files (like `.env`, `.git`, or `node_modules`) from being added to the final image.
657
657
>
658
658
> To learn more, visit the [.dockerignore reference](/reference/dockerfile.md#dockerignore-file).
659
659
@@ -705,7 +705,7 @@ nodejs-sample-kubernetes.yaml
705
705
!tsconfig.json
706
706
```
707
707
708
-
### Step 4: Build the Node.js application image
708
+
### Step 3: Build the Node.js application image
709
709
710
710
After creating all the configuration files, your project directory should now contain all necessary Docker configuration files:
711
711
@@ -735,7 +735,7 @@ What this command does:
735
735
- Packages the application and its dependencies into a Docker image
736
736
- Tags the image as docker-nodejs-sample so you can reference it later
737
737
738
-
#### Step 6: View local images
738
+
#### Step 4: View local images
739
739
740
740
After building your Docker image, you can check which images are available on your local machine using either the Docker CLI or [Docker Desktop](/manuals/desktop/use-desktop/images.md). Since you're already working in the terminal, let's use the Docker CLI.
Copy file name to clipboardExpand all lines: content/guides/nodejs/develop.md
+76-76Lines changed: 76 additions & 76 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -166,7 +166,7 @@ networks:
166
166
167
167
1. The PostgreSQL database configuration is handled automatically by the application. The database is created and initialized when the application starts, with data persisted using the `postgres_data` volume.
168
168
169
-
2. Configure your environment by copying the example file:
169
+
1. Configure your environment by copying the example file:
3. Run the following command to start your application in development mode:
195
+
1. Run the following command to start your application in development mode:
196
196
197
197
```console
198
198
$ docker compose up app-dev --build
199
199
```
200
200
201
-
4. Open a browser and verify that the application is running at [http://localhost:5173](http://localhost:5173) for the frontend or [http://localhost:3000](http://localhost:3000) for the API. The React frontend is served by Vite dev server on port 5173, with API calls proxied to the Express server on port 3000.
201
+
1. Open a browser and verify that the application is running at [http://localhost:5173](http://localhost:5173) for the frontend or [http://localhost:3000](http://localhost:3000) for the API. The React frontend is served by Vite dev server on port 5173, with API calls proxied to the Express server on port 3000.
202
202
203
-
5. Add some items to the todo list to test data persistence.
203
+
1. Add some items to the todo list to test data persistence.
204
204
205
-
6. After adding some items to the todo list, press `CTRL + C` in the terminal to stop your application.
205
+
1. After adding some items to the todo list, press `CTRL + C` in the terminal to stop your application.
206
206
207
-
7. Run the application again:
207
+
1. Run the application again:
208
208
209
-
```console
210
-
$ docker compose up app-dev
211
-
```
209
+
```console
210
+
$ docker compose up app-dev
211
+
```
212
212
213
-
8. Refresh [http://localhost:5173](http://localhost:5173) in your browser and verify that the todo items persisted, even after the containers were removed and ran again.
213
+
1. Refresh [http://localhost:5173](http://localhost:5173) in your browser and verify that the todo items persisted, even after the containers were removed and ran again.
1. Save the file and the Vite dev server will automatically reload the page with your changes
412
412
413
-
**Debugging Support:**
413
+
**Debugging support:**
414
414
415
415
You can connect a debugger to your application on port 9229. The Node.js inspector is enabled with `--inspect=0.0.0.0:9230` in the development script (`dev:server`).
416
416
417
-
### VS Code Debugger Setup
417
+
### VS Code debugger setup
418
418
419
-
1. **Create a launch configuration** in `.vscode/launch.json`:
419
+
1. Create a launch configuration in `.vscode/launch.json`:
420
420
421
-
```json
422
-
{
423
-
"version": "0.2.0",
424
-
"configurations": [
421
+
```json
425
422
{
426
-
"name": "Attach to Docker Container",
427
-
"type": "node",
428
-
"request": "attach",
429
-
"port": 9229,
430
-
"address": "localhost",
431
-
"localRoot": "${workspaceFolder}",
432
-
"remoteRoot": "/app",
433
-
"protocol": "inspector",
434
-
"restart": true,
435
-
"sourceMaps": true,
436
-
"skipFiles": ["<node_internals>/**"]
423
+
"version": "0.2.0",
424
+
"configurations": [
425
+
{
426
+
"name": "Attach to Docker Container",
427
+
"type": "node",
428
+
"request": "attach",
429
+
"port": 9229,
430
+
"address": "localhost",
431
+
"localRoot": "${workspaceFolder}",
432
+
"remoteRoot": "/app",
433
+
"protocol": "inspector",
434
+
"restart": true,
435
+
"sourceMaps": true,
436
+
"skipFiles": ["<node_internals>/**"]
437
+
}
438
+
]
437
439
}
438
-
]
439
-
}
440
440
```
441
441
442
-
1. **Start your development container**:
442
+
1. Start your development container:
443
443
444
-
```console
445
-
docker compose up app-dev --build
446
-
```
444
+
```console
445
+
docker compose up app-dev --build
446
+
```
447
447
448
-
1. **Attach the debugger**:
448
+
1. Attach the debugger:
449
449
- Open VS Code
450
450
- Go to the Debug panel (Ctrl/Cmd + Shift + D)
451
451
- Select "Attach to Docker Container" from the drop-down
@@ -455,27 +455,27 @@ docker compose up app-dev --build
455
455
456
456
You can also use Chrome DevTools for debugging:
457
457
458
-
1. **Start your container** (if not already running):
458
+
1. Start your container (if not already running):
459
459
460
-
```console
461
-
docker compose up app-dev --build
462
-
```
460
+
```console
461
+
docker compose up app-dev --build
462
+
```
463
463
464
-
1. **Open Chrome** and navigate to:
464
+
1. Open Chrome and navigate to:
465
465
466
-
```text
467
-
chrome://inspect
468
-
```
466
+
```text
467
+
chrome://inspect
468
+
```
469
469
470
-
1. **Select "Configure"** and add:
470
+
1. Select **Configure** and add:
471
471
472
-
```text
473
-
localhost:9229
474
-
```
472
+
```text
473
+
localhost:9229
474
+
```
475
475
476
-
1. **Select "inspect"** under your Node.js target when it appears
476
+
1. Select **inspect** under your Node.js target when it appears.
477
477
478
-
### Debugging Configuration Details
478
+
### Debugging configuration details
479
479
480
480
The debugger configuration:
481
481
@@ -485,32 +485,32 @@ The debugger configuration:
485
485
486
486
The debugger listens on all interfaces (`0.0.0.0`) inside the container on port 9230 and is accessible on port 9229 from your host machine.
487
487
488
-
### Troubleshooting Debugger Connection
488
+
### Troubleshooting debugger connection
489
489
490
490
If the debugger doesn't connect:
491
491
492
-
1. **Check if the container is running**:
492
+
1. Check if the container is running:
493
493
494
-
```console
495
-
docker ps
496
-
```
494
+
```console
495
+
docker ps
496
+
```
497
497
498
-
1. **Check if the port is exposed**:
498
+
1. Check if the port is exposed:
499
499
500
-
```console
501
-
docker port todoapp-dev
502
-
```
500
+
```console
501
+
docker port todoapp-dev
502
+
```
503
503
504
-
1. **Check container logs**:
504
+
1. Check container logs:
505
505
506
-
```console
507
-
docker compose logs app-dev
508
-
```
506
+
```console
507
+
docker compose logs app-dev
508
+
```
509
509
510
-
You should see a message like:
510
+
You should see a message like:
511
511
512
-
```text
513
-
Debugger listening on ws://0.0.0.0:9230/...
512
+
```text
513
+
Debugger listening on ws://0.0.0.0:9230/...
514
514
```
515
515
516
516
Now you can set breakpoints in your TypeScript source files and debug your containerized Node.js application!
0 commit comments