-
Notifications
You must be signed in to change notification settings - Fork 0
add docker & api route #122
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
Conversation
PR Review ❌ Documentation drift: Update documentation for default server port change from 8080 to 80. Generated by Firstmate to make sure you can focus on coding new features. |
return process.env.PORT || 80; | ||
} |
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.
You changed the default server port from 8080 to 80. This change seems important, so it might be smart to change the documentation accordingly.
For example, update the documentation to reflect the new default port:
## Running the Application
To start the application, use the following command:
```bash
npm start
The application will now run on port 80 by default.
FROM node:19-alpine | ||
|
||
WORKDIR /usr/src/app | ||
|
||
RUN addgroup -S appgroup && adduser -S appuser -G appgroup | ||
USER appuser | ||
|
||
RUN apk add --no-cache git | ||
COPY . . | ||
CMD ["npm", "start", "--no-update-notifier"] |
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.
Your Dockerfile should implement a multi-stage build to optimize image size and enhance security. Consider adding a build stage and a final stage like this:
# Build stage
FROM node:19-alpine AS build
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
# Final stage
FROM node:19-alpine
WORKDIR /usr/src/app
COPY --from=build /usr/src/app .
CMD ["npm", "start", "--no-update-notifier"]
(Based on guideline 'Dockerfiles should use multi-stage builds')
router.route("/get/:id").get(exampleController.getById) | ||
|
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.
The new route /get/:id
lacks the grantAccessByPermissionMiddleware
, which is essential for proper permission checks. Update the route as follows to include the middleware:
router.route("/get/:id")
.get(grantAccessByPermissionMiddleware([API_PERMISSIONS.PUBLIC_ENDPOINT]), exampleController.getById);
This ensures that the necessary access control is enforced.
(Based on guideline 'Routes must check permissions')
I analysed the failed pipeline job Failure AnalysisThe pipeline crashed during the Docker build step, specifically when attempting to install the
This suggests that the Dockerfile is trying to run this command as a non-root user ( USER appuser
RUN apk add --no-cache git Suggested FixTo resolve the permission issue, you can switch back to the root user before running the - USER appuser
+ USER root
RUN apk add --no-cache git
+ USER appuser This change ensures that the package installation has the necessary permissions while maintaining the intended user context for subsequent commands. |
💡 PR Summary generated by FirstMate
Overview: Added Docker support and a new API route for fetching examples by ID.
Changes:
Dockerfile:
API Route Update:
/get/:id
inexampleRouter.js
for fetching example data.Configuration Change:
appConfig.js
from 8080 to 80 for consistency.TLDR: Introduced Docker support and a new API route for fetching examples; updated server port configuration. Focus on the Dockerfile and new route in
exampleRouter.js
.Generated by FirstMate and automatically updated on every commit.