feat: Modernize Node.js environment, dependencies, and Docker setup - #3
feat: Modernize Node.js environment, dependencies, and Docker setup#3romainPrignon wants to merge 1 commit into
Conversation
This commit brings several foundational improvements to the project:
1. **Node.js Modernization:**
* Updated Node.js engine to `^18.17.0` in `package.json`.
* Updated npm engine to `^9.6.7` in `package.json`.
* Updated `@types/node` to `^18.17.0`.
2. **Core Dependency Updates:**
* Upgraded TypeScript to `^5.2.2`.
* Upgraded ESLint to `^8.50.0` and its TypeScript plugins (`@typescript-eslint/eslint-plugin`, `@typescript-eslint/parser`) to `^6.7.3`.
* Added `plugin:@typescript-eslint/recommended` to ESLint configuration.
* Upgraded Jest to `^29.7.0`, `ts-jest` to `^29.1.1`, and `@types/jest` to `^29.5.5`.
* Pinned Husky to `^8.0.0`.
3. **Dockerfile Enhancements:**
* Base images updated to `node:18-alpine`.
* Corrected npm install commands to `npm install --legacy-peer-deps` (for build stage) and `npm ci --only=production --legacy-peer-deps` (for final stage).
* Ensured `package-lock.json` is copied and used for installations.
* Set the `CMD` to `["node", "dist/index.js"]` to correctly run the application.
4. **Build Process Improvements:**
* Added a `.dockerignore` file to optimize Docker build context.
* Updated `tsconfig.json` for `es2022` target and lib.
* Updated `.eslintrc.js` for `ecmaVersion: 2022`.
These changes provide a more secure, stable, and modern foundation for future development.
There was a problem hiding this comment.
Pull Request Overview
Modernize the project’s Node.js environment, dependencies, and Docker setup for a more stable and current foundation.
- Bump Node.js, npm, and core dev dependencies (TypeScript, ESLint, Jest, etc.) to latest compatible versions
- Refactor Dockerfile to use Alpine images, legacy-peer-deps install, and correct runtime command
- Add
.dockerignoreand update ESLint/TS config to target modern ECMAScript and TypeScript rules
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| package.json | Updated engines and core dev dependencies to current versions |
| Dockerfile | Switched to node:18-alpine, adjusted install commands and CMD |
| .eslintrc.js | Bumped ecmaVersion to 2022 and added TypeScript ESLint plugin |
| .dockerignore | Added ignore rules to optimize Docker build context |
Comments suppressed due to low confidence (2)
package.json:51
- The
jest-configversion remains at23.6.0while Jest itself is updated to^29.7.0, which may cause version mismatches or unexpected behavior. Consider updatingjest-configto a compatible version or removing it if it’s no longer needed.
"jest-config": "23.6.0",
.dockerignore:6
- [nitpick] Ignoring the
Dockerfilein.dockerignorecan prevent it from being sent to the build context. It's generally recommended to keep the Dockerfile outside of ignore rules so builds remain reproducible.
Dockerfile
| "typescript": "^5.2.2" | ||
| }, | ||
| "optionalDependencies": { |
There was a problem hiding this comment.
[nitpick] Husky is configured under optionalDependencies, but it’s a development tool and should typically be in devDependencies to avoid shipping unnecessary packages to production.
| "typescript": "^5.2.2" | |
| }, | |
| "optionalDependencies": { | |
| "typescript": "^5.2.2", |
| WORKDIR /opt | ||
|
|
||
| COPY --from=build /opt/package.json package.json | ||
| COPY package-lock.json . |
There was a problem hiding this comment.
In the final stage you copy package-lock.json from the build context instead of the build stage. You may want to COPY --from=build /opt/package-lock.json . to ensure the exact lockfile used during build is applied in the runtime image.
| COPY package-lock.json . | |
| COPY --from=build /opt/package-lock.json . |
This commit brings several foundational improvements to the project:
Node.js Modernization:
^18.17.0inpackage.json.^9.6.7inpackage.json.@types/nodeto^18.17.0.Core Dependency Updates:
^5.2.2.^8.50.0and its TypeScript plugins (@typescript-eslint/eslint-plugin,@typescript-eslint/parser) to^6.7.3.plugin:@typescript-eslint/recommendedto ESLint configuration.^29.7.0,ts-jestto^29.1.1, and@types/jestto^29.5.5.^8.0.0.Dockerfile Enhancements:
node:18-alpine.npm install --legacy-peer-deps(for build stage) andnpm ci --only=production --legacy-peer-deps(for final stage).package-lock.jsonis copied and used for installations.CMDto["node", "dist/index.js"]to correctly run the application.Build Process Improvements:
.dockerignorefile to optimize Docker build context.tsconfig.jsonfores2022target and lib..eslintrc.jsforecmaVersion: 2022.These changes provide a more secure, stable, and modern foundation for future development.