Skip to content

Commit da2b5d0

Browse files
authored
Merge pull request #56 from weaponsforge/fix/weaponsforge-55
fix: vitest package security cve-2025-24964
2 parents f0d94ae + 2f3271f commit da2b5d0

File tree

7 files changed

+508
-422
lines changed

7 files changed

+508
-422
lines changed

Dockerfile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
FROM node:20.15.0-alpine AS base
22
RUN mkdir -p /opt/app
33
WORKDIR /opt/app
4-
RUN addgroup -S user && adduser -S user -G user
5-
RUN chown -R user:user /opt/app
4+
# RUN addgroup -S user && adduser -S user -G user
5+
# RUN chown -R user:user /opt/app
6+
7+
# Use the image's default user
8+
RUN chown -R node:node /opt/app
69
COPY package*.json ./
710

811
# BUILD TARGET
@@ -16,8 +19,8 @@ FROM base AS development
1619
RUN npm install
1720
COPY . ./
1821
RUN mkdir /opt/app/node_modules/.vite \
19-
&& chown -R user:user /opt/app/node_modules/.vite
20-
USER user
22+
&& chown -R node:node /opt/app/node_modules/.vite
23+
USER node
2124
EXPOSE 9229
2225
CMD ["sh"]
2326

README.md

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ This repository contains solutions and a local development environment for the [
4141
- [Usage](#-usage)
4242
- [Alternate Usage](#-alternate-usage)
4343
- [Available Scripts](#-available-scripts)
44+
- [Docker Scripts](#-docker-scripts)
4445

4546
</details>
4647

@@ -129,33 +130,33 @@ Using Node
129130

130131
Using Docker
131132

132-
- Build the image
133+
- **Build the image**
133134
```
134135
docker compose -f docker-compose.dev.yml build
135136
```
136137

137-
- Transpile the TypeScript files to JavaScript (PowerShell)
138+
- **Transpile the TypeScript files to JavaScript** (PowerShell)
138139
```
139140
docker run -it -v ${pwd}:/opt/app -v /opt/app/node_modules --rm weaponsforge/adventofcode:dev npm run transpile
140141
```
141142

142-
- Run tests (PowerShell)
143+
- **Run tests** (PowerShell)
143144
```
144145
docker run -it -v ${pwd}:/opt/app -v /opt/app/node_modules --rm weaponsforge/adventofcode:dev npm test
145146
```
146147

147-
- Watch TS file updates: Use available scripts - `npm run watch`, `npm run watch:docker:win`
148+
- **Watch TS file updates: Use available scripts** - e.g., `npm run watch`, `npm run docker:watch:win`
148149
```
149150
docker run -it -v ${pwd}:/opt/app -v /opt/app/node_modules --rm weaponsforge/adventofcode:dev <AVAILABLE_SCRIPT>
150151
```
151152

152-
- Run a script and debug it with the VSCode Debugger.
153+
- **Run a script and debug it with the VSCode Debugger**
153154
- Prepare a function for debugging with VSCode in Docker. Wrap it in the `AOCRunScript()` function.
154-
- Assign the path to a TypeScript file from the previous step to the package.json file's `"dev:debug:docker"` script, replacing `src/sample/sample.ts`.
155-
- `"dev:debug:docker": "export IS_DOCKER=true && node --inspect=0.0.0.0:9229 ./node_modules/.bin/vite-node src/path/to/script.ts"`
155+
- Assign the path to a TypeScript file from the previous step to the package.json file's `"docker:debug"` script, replacing `src/sample/sample.ts`.
156+
- `"docker:debug": "export IS_DOCKER=true && node --inspect=0.0.0.0:9229 ./node_modules/.bin/vite-node src/path/to/script.ts"`
156157
- Run the script with VSCode debugging:
157158
```
158-
docker run -it -v ${pwd}:/opt/app -v /opt/app/node_modules --rm weaponsforge/adventofcode:dev npm run dev:debug:docker
159+
docker run -it -v ${pwd}:/opt/app -v /opt/app/node_modules -p 9229:9229 --rm weaponsforge/adventofcode:dev npm run docker:debug
159160
```
160161
> **INFO:** This process requires attaching a debugger with the VSCode launch config defined in Issue [#53](https://github.com/weaponsforge/adventofcode/issues/53)
161162
@@ -185,6 +186,8 @@ Using Docker
185186

186187
## 📜 Available Scripts
187188

189+
These scripts, compatible with running in Node and Docker, run various TypeScript scripts and tests.
190+
188191
<details>
189192
<summary>Click to expand the list of available scripts</summary>
190193

@@ -196,33 +199,54 @@ Runs `vitest` in watch mode, watching file changes and errors to files linked wi
196199

197200
Watches file changes in `.ts` files using the `tsc --watch` option.
198201

199-
### `npm run watch:docker:win`
200-
201-
Watches file changes in `.ts` files using the `tsc --watch` option with `dynamicPriorityPolling` in Docker containers running in Windows WSL2.
202-
203202
### `npm run dev:debug`
204203

205204
Runs the sample TS script.
206205

207206
### `npm run transpile`
208207

209-
Builds the JavaScript files from the TypeScript files.
208+
Builds JavaScript, `.d.ts` declaration files, and map files from the TypeScript source files.
210209

211210
### `npm run transpile:noemit`
212211

213-
Runs type-checking without generating the JavaScript or declatation files from the TypeScript files.
212+
Runs type-checking without generating the JavaScript or declaration files from the TypeScript files.
214213

215214
### `npm run lint`
216215

217216
Lints TypeScript source codes.
218217

219218
### `npm run lint:fix`
220219

221-
Fixes TypeScript lint errors.
220+
Fixes lint errors in TypeScript files.
222221

223222
### `npm test`
224223

225-
Runs tests defined in `*.test.ts` files.
224+
Runs test scripts defined in `*.test.ts` files.
225+
226+
</details>
227+
228+
## 📦 Docker Scripts
229+
230+
These scripts allow optional Docker-related processes, such as enabling file watching in Docker containers running in Windows WSL2 and others.
231+
232+
<details>
233+
<summary>Click to expand the list of available scripts</summary>
234+
235+
### `npm run docker:debug`
236+
237+
- Runs the `"/src/sample/sample.ts"` script in containers with debugging enabled in VSCode.
238+
- Replace the `"/src/sample/sample.ts"` file path in the package.json file's `"docker:debug"` script with a target TypeScript file for debugging.
239+
- Map port **9229** to enable debugging VSCode while running in Docker.<br>
240+
`docker:debug": "export IS_DOCKER=true && node --inspect=0.0.0.0:9229 ./node_modules/.bin/vite-node src/path/to/<NEW_SCRIPT>.ts`
241+
242+
### `npm run docker:watch:win`
243+
244+
Watches file changes in `.ts` files using the `tsc --watch` option with `dynamicPriorityPolling` in Docker containers running in Windows WSL2.
245+
246+
### `npm run docker:dev:win`
247+
248+
- Sets and exports the environment variables: `CHOKIDAR_USEPOLLING=1` and `CHOKIDAR_INTERVAL=1000`
249+
- Runs `vitest` in watch mode inside Docker containers running in Windows WSL2, watching file changes and errors to files linked with `*.test.ts` files.
226250

227251
</details>
228252
<br>

0 commit comments

Comments
 (0)