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
The default Dockerfile generated by `docker init` provides a reliable baseline for standard Node.js applications. However, since this project is a full-stack TypeScript application that includes both a backend API and frontend React components, the Dockerfile should be customized to better support and optimize this specific architecture.
299
299
300
-
### Step 1: Review the generated files
300
+
### Review the generated files
301
301
302
-
In this step, you’ll improve the Dockerfile and configuration files by following best practices:
302
+
In the following step, you’ll improve the Dockerfile and configuration files by following best practices:
303
303
304
304
- Use multi-stage builds to keep the final image clean and small
305
305
- Improve performance and security by only including what’s needed
@@ -310,25 +310,30 @@ These updates help ensure your app is easy to deploy, fast to load, and producti
310
310
> A `Dockerfile` is a plain text file that contains step-by-step instructions to build a Docker image. It automates packaging your application along with its dependencies and runtime environment.
311
311
> For full details, see the [Dockerfile reference](/reference/dockerfile/).
312
312
313
-
### Step 2: Configure the Dockerfile file
313
+
### Step 1: Configure the Dockerfile
314
314
315
315
Before creating a Dockerfile, you need to choose a base image. You can either use the [Node.js Official Image](https://hub.docker.com/_/node) or a Docker Hardened Image (DHI) from the [Hardened Image catalog](https://hub.docker.com/hardened-images/catalog).
316
316
317
317
Choosing DHI offers the advantage of a production-ready image that is lightweight and secure. For more information, see [Docker Hardened Images](https://docs.docker.com/dhi/).
318
318
319
+
> [!IMPORTANT]
320
+
> This guide uses a stable Node.js LTS image tag that is considered secure when the guide is written. Because new releases and security patches are published regularly, the tag shown here may no longer be the safest option when you follow the guide. Always review the latest available image tags and select a secure, up-to-date version before building or deploying your application.
321
+
>
322
+
> Official Node.js Docker Images: https://hub.docker.com/_/node
323
+
319
324
{{< tabs >}}
320
325
{{< tab name="Using Docker Hardened Images" >}}
321
326
Docker Hardened Images (DHIs) are available for Node.js on [Docker Hub](https://hub.docker.com/hardened-images/catalog/dhi/node). Unlike using the Docker Official Image, you must first mirror the Node.js image into your organization and then use it as your base image. Follow the instructions in the [DHI quickstart](/dhi/get-started/) to create a mirrored repository for Node.js.
322
327
323
-
Mirrored repositories must start with `dhi-`, for example: `FROM <your-namespace>/dhi-node:<tag>`. In the following Dockerfile, the `FROM` instruction uses `<your-namespace>/dhi-node:22` as the base image.
328
+
Mirrored repositories must start with `dhi-`, for example: `FROM <your-namespace>/dhi-node:<tag>`. In the following Dockerfile, the `FROM` instruction uses `<your-namespace>/dhi-node:24-alpine3.22-dev` as the base image.
324
329
325
330
```dockerfile
326
331
# ========================================
327
332
# Optimized Multi-Stage Dockerfile
328
333
# Node.js TypeScript Application (Using DHI)
329
334
# ========================================
330
335
331
-
FROM <your-namespace>/dhi-node:22 AS base
336
+
FROM <your-namespace>/dhi-node:24-alpine3.22-dev AS base
0 commit comments