diff --git a/apps/cat-fostering-api/.gitignore b/apps/cat-fostering-api/.gitignore index 797ca4d..2a51009 100644 --- a/apps/cat-fostering-api/.gitignore +++ b/apps/cat-fostering-api/.gitignore @@ -2,4 +2,5 @@ .env* .flaskenv* !.env.project -!.env.vault \ No newline at end of file +!.env.vault +package-lock.json diff --git a/apps/cat-fostering-api/Dockerfile b/apps/cat-fostering-api/Dockerfile index c651346..381fa62 100644 --- a/apps/cat-fostering-api/Dockerfile +++ b/apps/cat-fostering-api/Dockerfile @@ -1,5 +1,5 @@ -# Build the docker image with `npx nx docker-build cat-fostering-api`. -# Tip: Modify "docker-build" options in project.json to change docker build args. +# Build the docker image with `npx nx run cat-fostering-api:container`. +# Tip: Modify "container" options in project.json to change docker build args. # # Run the container with `docker run -e ORY_ACTION_API_KEY='hello' -e POSTGRES_URL='postgres://dbuser:secret@postgres:5432/appdb' --network cat-fostering_ory -p 3000:3000 -t ghcr.io/getlarge/cat-fostering/cat-fostering-api:latest`. @@ -12,7 +12,7 @@ WORKDIR /app RUN echo "Building cat-fostering-api image with NODE_VERSION=$NODE_VERSION" -COPY ./apps/cat-fostering-api/package*.json ./ +COPY ./dist/apps/cat-fostering-api/package*.json ./ RUN npm install --omit=dev -f --loglevel=error RUN curl -sf https://gobinaries.com/tj/node-prune | sh diff --git a/apps/cat-fostering-api/project.json b/apps/cat-fostering-api/project.json index 9ec8d14..ce975af 100644 --- a/apps/cat-fostering-api/project.json +++ b/apps/cat-fostering-api/project.json @@ -50,6 +50,7 @@ "dockerFiles", { "dependentTasksOutputFiles": "**/dist/**/*", "transitive": true } ], + "cache": true, "dependsOn": ["lint", "build"], "options": { "file": "apps/cat-fostering-api/Dockerfile", @@ -59,14 +60,39 @@ "build-args": ["APP_NAME=cat-fostering-api", "NODE_VERSION=20.9.0"] } }, - "docker-build": { + "generate-lock-file": { + "inputs": ["{projectRoot}/package.json"], + "outputs": ["{projectRoot}/package-lock.json"], + "dependsOn": [ + { + "target": "lint", + "params": "forward" + } + ], "cache": true, - "dependsOn": ["lint", "build"], + "command": "npm i --prefix apps/cat-fostering-api --package-lock-only", + "metadata": { + "description": "Generate NPM lock file" + } + }, + "nsci": { "inputs": [ - "dockerFiles", - { "dependentTasksOutputFiles": "**/dist/**/*", "transitive": true } + "{workspaceRoot}/.nodesecurerc", + "{workspaceRoot}/.nodesecureignore", + { + "dependentTasksOutputFiles": "apps/cat-fostering-api/package-lock.json" + } ], - "command": "docker build -f apps/cat-fostering-api/Dockerfile . -t ghcr.io/getlarge/cat-fostering/cat-fostering-api:dev" + "dependsOn": ["generate-lock-file", "build"], + "cache": true, + "executor": "nx:run-commands", + "options": { + "command": "npx nsci --directory=dist/apps/cat-fostering-api --strategy=npm --vulnerabilities=medium run", + "forwardAllArgs": true + }, + "metadata": { + "description": "Run the NodeSecure CI analysis" + } } } } diff --git a/apps/cat-fostering-api/webpack.config.js b/apps/cat-fostering-api/webpack.config.js index 629d085..54241e2 100644 --- a/apps/cat-fostering-api/webpack.config.js +++ b/apps/cat-fostering-api/webpack.config.js @@ -14,7 +14,14 @@ module.exports = { compiler: 'tsc', main: './src/main.ts', tsConfig: './tsconfig.app.json', - assets: ['./src/assets'], + assets: [ + './src/assets', + { + input: './', + glob: './package*.json', + output: '.', + }, + ], optimization: false, outputHashing: 'none', transformers: [