-
Couldn't load subscription status.
- Fork 0
Thaw/wc 117 #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Thaw/wc 117 #2
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| # compiled output | ||
| /dist | ||
| /node_modules | ||
| /build | ||
|
|
||
| # Logs | ||
| logs | ||
| *.log | ||
| npm-debug.log* | ||
| pnpm-debug.log* | ||
| yarn-debug.log* | ||
| yarn-error.log* | ||
| lerna-debug.log* | ||
|
|
||
| # OS | ||
| .DS_Store | ||
|
|
||
| # Tests | ||
| /coverage | ||
| /.nyc_output | ||
|
|
||
| # IDEs and editors | ||
| /.idea | ||
| .project | ||
| .classpath | ||
| .c9/ | ||
| *.launch | ||
| .settings/ | ||
| *.sublime-workspace | ||
|
|
||
| # IDE - VSCode | ||
| .vscode/* | ||
| !.vscode/settings.json | ||
| !.vscode/tasks.json | ||
| !.vscode/launch.json | ||
| !.vscode/extensions.json | ||
|
|
||
| # dotenv environment variable files | ||
| .env | ||
| .env.development.local | ||
| .env.test.local | ||
| .env.production.local | ||
| .env.local | ||
|
|
||
| # temp directory | ||
| .temp | ||
| .tmp | ||
|
|
||
| # Runtime data | ||
| pids | ||
| *.pid | ||
| *.seed | ||
| *.pid.lock | ||
|
|
||
| # Diagnostic reports (https://nodejs.org/api/report.html) | ||
| report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,40 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Stage 1: Build the application | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| FROM node:22 AS builder | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Declare build-time arguments | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ARG DATABASE_URL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ARG NATS_URL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Set environment variables in the Docker image | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ENV DATABASE_URL=$DATABASE_URL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ENV NATS_URL=$NATS_URL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| WORKDIR /app | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| COPY package*.json ./ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| RUN npm install | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| COPY . . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| RUN npm run build | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+12
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Optimize build process and improve reliability Several improvements can enhance build efficiency and reliability:
Apply this diff: WORKDIR /app
COPY package*.json ./
-RUN npm install
+RUN npm ci
+# Copy only necessary source files
-COPY . .
+COPY src/ ./src/
+COPY tsconfig*.json ./
+
+# Build the application
RUN npm run buildAlso, create a
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Stage 2: Run the application | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| FROM node:22 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Declare build-time arguments | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ARG DATABASE_URL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ARG NATS_URL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Set environment variables in the Docker image | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ENV DATABASE_URL=$DATABASE_URL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ENV NATS_URL=nats://nats-streaming:4222 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+20
to
+30
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Address security concerns and configuration flexibility Several critical improvements needed:
Apply this diff: -FROM node:22
+FROM --platform=$BUILDPLATFORM node:20.11-slim
# Declare build-time arguments
ARG DATABASE_URL
ARG NATS_URL
+# Create non-root user
+RUN groupadd -r nodejs && useradd -r -g nodejs nodejs
# Set environment variables in the Docker image
ENV DATABASE_URL=$DATABASE_URL
-ENV NATS_URL=nats://nats-streaming:4222
+ENV NATS_URL=${NATS_URL:-nats://nats-streaming:4222}
WORKDIR /app
+# Change ownership of working directory
+RUN chown nodejs:nodejs /app
+
+# Switch to non-root user
+USER nodejs📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| WORKDIR /app | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| COPY package*.json ./ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| RUN npm install --only=production | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| COPY --from=builder /app/dist ./dist | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| EXPOSE 3000 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| CMD ["node", "dist/main"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,42 +29,56 @@ | |
| ## Project setup | ||
|
|
||
| ```bash | ||
| $ pnpm install | ||
| $ npm install | ||
| ``` | ||
|
|
||
| ## Compile and run the project | ||
|
|
||
| ```bash | ||
| # development | ||
| $ pnpm run start | ||
| $ npm run start | ||
|
|
||
| # watch mode | ||
| $ pnpm run start:dev | ||
| $ npm run start:dev | ||
|
|
||
| # production mode | ||
| $ pnpm run start:prod | ||
| $ npm run start:prod | ||
| ``` | ||
|
|
||
| ## Run tests | ||
|
|
||
| ```bash | ||
| # unit tests | ||
| $ pnpm run test | ||
| $ npm run test | ||
|
|
||
| # e2e tests | ||
| $ pnpm run test:e2e | ||
| $ npm run test:e2e | ||
|
|
||
| # test coverage | ||
| $ pnpm run test:cov | ||
| $ npm run test:cov | ||
| ``` | ||
|
|
||
| ## Deployment | ||
|
|
||
| When you're ready to deploy your NestJS application to production, there are some key steps you can take to ensure it runs as efficiently as possible. Check out the [deployment documentation](https://docs.nestjs.com/deployment) for more information. | ||
|
|
||
| If you are looking for a cloud-based platform to deploy your NestJS application, check out [Mau](https://mau.nestjs.com), our official platform for deploying NestJS applications on AWS. Mau makes deployment straightforward and fast, requiring just a few simple steps: | ||
|
|
||
| ```bash | ||
| $ npm install -g mau | ||
| $ mau deploy | ||
| ``` | ||
|
|
||
| With Mau, you can deploy your application in just a few clicks, allowing you to focus on building features rather than managing infrastructure. | ||
|
|
||
|
Comment on lines
+61
to
+73
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add Docker deployment instructions While the Mau deployment instructions are valuable, considering the PR's focus on Docker containerization, it would be beneficial to add Docker-specific deployment instructions. Consider adding a section like this: ## Deployment
+ ### Docker Deployment
+
+ To run the service using Docker:
+
+ ```bash
+ # Build the Docker image
+ $ docker build -t chef-service .
+
+ # Run the container
+ $ docker run -p 3000:3000 chef-service
+ ```
+
### Cloud Deployment
When you're ready to deploy your NestJS application to production...🧰 Tools🪛 Markdownlint68-68: null (MD014, commands-show-output) 69-69: null (MD014, commands-show-output) |
||
| ## Resources | ||
|
|
||
| Check out a few resources that may come in handy when working with NestJS: | ||
|
|
||
| - Visit the [NestJS Documentation](https://docs.nestjs.com) to learn more about the framework. | ||
| - For questions and support, please visit our [Discord channel](https://discord.gg/G7Qnnhy). | ||
| - To dive deeper and get more hands-on experience, check out our official video [courses](https://courses.nestjs.com/). | ||
| - Deploy your application to AWS with the help of [NestJS Mau](https://mau.nestjs.com) in just a few clicks. | ||
| - Visualize your application graph and interact with the NestJS application in real-time using [NestJS Devtools](https://devtools.nestjs.com). | ||
| - Need help with your project (part-time to full-time)? Check out our official [enterprise support](https://enterprise.nestjs.com). | ||
| - To stay in the loop and get updates, follow us on [X](https://x.com/nestframework) and [LinkedIn](https://linkedin.com/company/nestjs). | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Consider security improvements and version stability
Several improvements can enhance security and stability:
node:20.11-slim) for better predictability--platformflag for multi-architecture supportApply this diff:
📝 Committable suggestion