Skip to content

Commit

Permalink
chore(cat-fostering-api): add targets to run nodesecure CI
Browse files Browse the repository at this point in the history
  • Loading branch information
getlarge committed Aug 16, 2024
1 parent 7a0d213 commit 3524c98
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 10 deletions.
3 changes: 2 additions & 1 deletion apps/cat-fostering-api/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
.env*
.flaskenv*
!.env.project
!.env.vault
!.env.vault
package-lock.json
6 changes: 3 additions & 3 deletions apps/cat-fostering-api/Dockerfile
Original file line number Diff line number Diff line change
@@ -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`.

Expand All @@ -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
Expand Down
36 changes: 31 additions & 5 deletions apps/cat-fostering-api/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"dockerFiles",
{ "dependentTasksOutputFiles": "**/dist/**/*", "transitive": true }
],
"cache": true,
"dependsOn": ["lint", "build"],
"options": {
"file": "apps/cat-fostering-api/Dockerfile",
Expand All @@ -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"
}
}
}
}
9 changes: 8 additions & 1 deletion apps/cat-fostering-api/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down

0 comments on commit 3524c98

Please sign in to comment.