Skip to content

Commit 6633cdf

Browse files
committed
edits based on feedback
1 parent fd21b51 commit 6633cdf

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

articles/container-apps/javascript-overview.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Learn about the tools and resources needed to run JavaScript applic
44
services: container-apps
55
author: craigshoemaker
66
ms.service: azure-container-apps
7-
ms.custom: devx-track-extended-java
7+
ms.custom: devx-track-js
88
ms.topic: conceptual
99
ms.date: 02/14/2025
1010
ms.author: cshoe
@@ -32,15 +32,15 @@ AZURE_COSMOS_DB_ENDPOINT=https://your-cosmos-db.documents.azure.com:443/
3232
A well-configured Dockerfile is essential for containerizing your application:
3333
* **Common Setup – Use a Base Dockerfile**: If multiple projects share a common setup, you can create a base Dockerfile that includes these common steps. Each project's Dockerfile can then start with `FROM` this base image and add project-specific configurations.
3434
* **Parameterization – Build Arguments**: You can use build arguments (`ARG`) in your Dockerfile to make it more flexible. This way, you can pass in different values for these arguments when building for development or production.
35-
* **Optimized Base Image – Node.js Variant**: Ensure you're using an appropriate **Node.js base image**. Consider using smaller, optimized images such as the Alpine variants to reduce overhead.
36-
* **Minimal Files – Copy Only Essentials**: Focus on copying only the necessary files into your container.
35+
* **Optimized Base Image – Node.js Variant**: Ensure you're using an appropriate **Node.js base image**. Consider using smaller, optimized images such as the Alpine variants to reduce overhead. The development environment can add dependencies in its own Dockerfile.
36+
* **Minimal Files – Copy Only Essentials**: Focus on copying only the necessary files into your container. Create a `.dockerignore` file to ensure development files aren't copied in such as `.env` and `node_modules`. This file is helps speed up builds in cases where developers copied in unnecessary files.
3737
* **Multi-stage Builds – Separate Build and Runtime**: Use multi-stage builds to create a lean final image by separating the build environment from the runtime environment.
3838
* **Prebuild Artifacts – Compile/Bundling**: Prebuilding your application artifacts (such as compiling TypeScript or bundling JavaScript) before copying them into the runtime stage can further minimize image size, speed up container deployment, and improve cold start performance. Careful ordering of instructions in your Dockerfile will also optimize caching and rebuild times.
3939
* **Development Environments – Docker Compose**: Use Docker Compose for development environments. Docker Compose allows you to define and run multi-container Docker applications, which can be useful for setting up development environments. You can include the build context and Dockerfile in the compose file, allowing you to use different Dockerfiles for different services if necessary.
4040

4141
### Base Dockerfile
4242

43-
This file serves as a common starting point for your Node.js images. You can use it with a FROM directive in your other Dockerfiles.
43+
This file serves as a common starting point for your Node.js images. You can use it with a FROM directive in your other Dockerfiles. Use either a version number or a commit to support the most up to date and secure version of the image.
4444

4545
```yaml
4646
# Dockerfile.base
@@ -81,6 +81,8 @@ docker build \
8181

8282
In this build, the environment variables PORT and ENABLE_DEBUG are set to 4000 and true, respectively, instead of their default values.
8383

84+
Container image tagging conventions such as the use of `latest` are a convention. Learn more about [recommendations for tagging and versioning container images](/azure/container-registry/container-registry-image-tag-version).
85+
8486
### Development environment with Docker Compose
8587

8688
This configuration uses a dedicated development Dockerfile (Dockerfile.dev) along with volume mounts for live reloading and local source sync.
@@ -115,7 +117,7 @@ PORT=4000 ENABLE_DEBUG=true docker compose up
115117

116118
### Production Dockerfile
117119

118-
This multi-stage Dockerfile builds your application and produces a lean runtime image.
120+
This multi-stage Dockerfile builds your application and produces a lean runtime image. Make sure to have your `.dockerignore` already in our source code so that the `COPY . .` command doesn't copy in any files specific to the development environment you don't need in production.
119121

120122
```yaml
121123
# Stage 1: Builder
@@ -160,6 +162,9 @@ To run a container from the built production image with custom environment varia
160162
docker run -e PORT=4000 -e ENABLE_DEBUG=true -p 4000:4000 -p 9229:9229 my-production-image:latest
161163
```
162164

165+
For production builds, make sure you use the correct version tag, which may not be `latest`. Container image tagging conventions such as the use of `latest` are a convention. Learn more about [recommendations for tagging and versioning container images](/azure/container-registry/container-registry-image-tag-version).
166+
167+
163168
## Deployment
164169
* Continuous Integration/Continuous Deployment (CI/CD) - Set up a CI/CD pipeline using GitHub Actions, Azure DevOps, or another CI/CD tool to automate the deployment process.
165170

@@ -206,7 +211,7 @@ docker run -e PORT=4000 -e ENABLE_DEBUG=true -p 4000:4000 -p 9229:9229 my-produc
206211
--env-vars NODE_ENV=production PORT=3000
207212
```
208213
209-
* Docker Registry - Push your Docker images to a container registry like Azure Container Registry (ACR) or Docker Hub.
214+
* Docker Registry - Sign into your registry then push your Docker images to a container registry like Azure Container Registry (ACR) or Docker Hub.
210215
211216
```bash
212217
# Tag the image
@@ -267,10 +272,11 @@ export function errorHandler(err: any, req: Request, res: Response, next: NextFu
267272

268273
Properly shutting down your application is crucial to ensure that in-flight requests complete and resources are released correctly. This helps prevent data loss and maintains a smooth user experience during deployments or scale-in events. The following example demonstrates one approach using Node.js and Express to handle shutdown signals gracefully.
269274

270-
```javascript
271-
const express = require('express');
275+
```typescript
276+
import express from 'express';
277+
import healthRouter from './health.js';
278+
272279
const app = express();
273-
const healthRouter = require('./health');
274280
275281
app.use(healthRouter);
276282
@@ -283,7 +289,7 @@ process.on('SIGTERM', () => {
283289
console.log('Server closed');
284290
process.exit(0);
285291
});
286-
292+
287293
// Force close after 30s
288294
setTimeout(() => {
289295
console.error('Could not close connections in time, forcing shutdown');

0 commit comments

Comments
 (0)