-
Notifications
You must be signed in to change notification settings - Fork 5
CI-CD this closes #26 #141
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?
Conversation
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.
Pull request overview
This PR introduces CI/CD infrastructure for both frontend and backend applications, addressing issue #26. It adds GitHub Actions workflows for automated testing, building, and deployment, along with a Dockerfile for the frontend application.
Key changes:
- Added GitHub Actions workflows for frontend and backend CI/CD pipelines with test, build, and deploy stages
- Introduced a multi-stage Dockerfile for the Next.js frontend application using Bun
- Configured automated deployment to Railway with Docker image publishing to GitHub Container Registry
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 16 comments.
| File | Description |
|---|---|
apps/frontend/Dockerfile |
Multi-stage Dockerfile for building and running the Next.js frontend with Bun runtime |
.github/workflows/frontend_ci.yml |
CI/CD workflow for frontend including linting, testing, Docker build/push, security scanning, and Railway deployment |
.github/workflows/backend_ci.yml |
CI/CD workflow for backend including Python linting, type checking, security scanning, Docker build/push, and Railway deployment |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| EXPOSE 3000 | ||
|
|
||
| # Command to run the application | ||
| CMD ["bun", "run", "start"] |
Copilot
AI
Nov 27, 2025
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 CMD ["bun", "run", "start"] command on line 35 will fail because it's executed from /app, but the application files are in /app/apps/frontend/. The start command needs to run from the correct directory.
Suggested fix: Update the command to specify the working directory:
WORKDIR /app/apps/frontend
CMD ["bun", "run", "start"]Or update the CMD:
CMD ["bun", "run", "start", "--cwd", "./apps/frontend"]| - name: Deploy to Railway | ||
| uses: railwayapp/cli-action@v1 | ||
| with: | ||
| railway_token: ${{ secrets.RAILWAY_API_TOKEN }} |
Copilot
AI
Nov 27, 2025
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 Railway deployment step is missing critical information for a successful deployment. The railwayapp/cli-action@v1 requires additional parameters such as:
service: The service name to deployenvironment: The environment to deploy to (e.g., production, staging)
Without these parameters, the deployment may fail or deploy to an unintended target.
Suggested fix:
- name: Deploy to Railway
uses: railwayapp/cli-action@v1
with:
railway_token: ${{ secrets.RAILWAY_API_TOKEN }}
service: frontend
environment: production| railway_token: ${{ secrets.RAILWAY_API_TOKEN }} | |
| railway_token: ${{ secrets.RAILWAY_API_TOKEN }} | |
| service: frontend | |
| environment: production |
| with: | ||
| context: apps/backend | ||
| push: true | ||
| tags: ghcr.io/${{ github.repository }}/backend:latest |
Copilot
AI
Nov 27, 2025
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.
[nitpick] The Docker image is tagged only as latest (line 57), which makes it difficult to track which version is deployed and can cause issues with rollbacks. Consider implementing a versioning strategy using commit SHA or semantic versioning.
Suggested improvement:
- name: Build and push
uses: docker/build-push-action@v4
with:
context: apps/backend
push: true
tags: |
ghcr.io/${{ github.repository }}/backend:latest
ghcr.io/${{ github.repository }}/backend:${{ github.sha }}This allows you to track deployments and roll back to specific versions if needed.
| tags: ghcr.io/${{ github.repository }}/backend:latest | |
| tags: | | |
| ghcr.io/${{ github.repository }}/backend:latest | |
| ghcr.io/${{ github.repository }}/backend:${{ github.sha }} |
| # Copy the rest of the frontend application code | ||
| COPY apps/frontend/ ./apps/frontend/ | ||
|
|
||
| # Build the Next.js application |
Copilot
AI
Nov 27, 2025
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 bun run build command on line 15 will fail because it's executed from /app, but the Next.js project is located in /app/apps/frontend/. The build command needs to run from the correct directory.
Suggested fix: Add --cwd flag or change working directory:
RUN bun run build --cwd ./apps/frontendOr set the working directory:
WORKDIR /app/apps/frontend
RUN bun run build| # Build the Next.js application | |
| # Build the Next.js application | |
| WORKDIR /app/apps/frontend |
| uses: aquasecurity/trivy-action@master | ||
| with: | ||
| image-ref: 'ghcr.io/${{ github.repository }}/backend:latest' | ||
| format: 'table' | ||
| exit-code: '1' |
Copilot
AI
Nov 27, 2025
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 Trivy security scan on line 59 will attempt to scan an image that may not be publicly accessible from the GitHub Actions runner. Additionally, using @master for the action version is not a best practice as it can lead to unexpected breaking changes.
Suggested fix:
- name: Scan image
uses: aquasecurity/trivy-action@0.17.0 # Use a specific version
with:
image-ref: 'ghcr.io/${{ github.repository }}/backend:latest'
format: 'sarif'
output: 'trivy-results.sarif'| uses: aquasecurity/trivy-action@master | |
| with: | |
| image-ref: 'ghcr.io/${{ github.repository }}/backend:latest' | |
| format: 'table' | |
| exit-code: '1' | |
| uses: aquasecurity/trivy-action@0.17.0 # Use a specific version | |
| with: | |
| image-ref: 'ghcr.io/${{ github.repository }}/backend:latest' | |
| format: 'sarif' | |
| output: 'trivy-results.sarif' |
| WORKDIR /app | ||
|
|
||
| # Install dependencies | ||
| COPY apps/frontend/package.json apps/frontend/bun.lock ./apps/frontend/ |
Copilot
AI
Nov 27, 2025
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 bun install command on line 9 will fail because it runs from /app directory, but the package.json and bun.lock are copied to /app/apps/frontend/. The install command needs to specify the correct working directory or be run from the subdirectory.
Suggested fix: Add --cwd ./apps/frontend flag:
RUN bun install --frozen-lockfile --cwd ./apps/frontendOr change to the directory first:
WORKDIR /app/apps/frontend| COPY apps/frontend/package.json apps/frontend/bun.lock ./apps/frontend/ | |
| COPY apps/frontend/package.json apps/frontend/bun.lock ./apps/frontend/ | |
| WORKDIR /app/apps/frontend |
| - name: Build and push | ||
| uses: docker/build-push-action@v4 | ||
| with: | ||
| context: apps/frontend |
Copilot
AI
Nov 27, 2025
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 Docker build context is set to apps/frontend, but the Dockerfile copies files from apps/frontend/ within the container. This creates a mismatch where the Dockerfile expects to be run from the repository root, but the workflow sets the context to the apps/frontend directory.
This will cause the build to fail because paths like COPY apps/frontend/package.json won't work when the context is already apps/frontend.
Suggested fix: Either change the context to . (repository root):
context: .
file: apps/frontend/DockerfileOr update the Dockerfile to work with apps/frontend as the context by removing the apps/frontend/ prefix from COPY commands.
| context: apps/frontend | |
| context: . |
| uses: aquasecurity/trivy-action@master | ||
| with: | ||
| image-ref: 'ghcr.io/${{ github.repository }}/frontend:latest' | ||
| format: 'table' | ||
| exit-code: '1' |
Copilot
AI
Nov 27, 2025
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 Trivy security scan on line 63 will attempt to scan an image that may not be publicly accessible from the GitHub Actions runner, since it was just pushed to GHCR. The scan should either:
- Pull the image first after authenticating, or
- Scan the local image before pushing, or
- Include proper authentication for pulling from GHCR
Additionally, using @master for the action version is not a best practice as it can lead to unexpected breaking changes.
Suggested fix:
- name: Scan image
uses: aquasecurity/trivy-action@0.17.0 # Use a specific version
with:
image-ref: 'ghcr.io/${{ github.repository }}/frontend:latest'
format: 'sarif'
output: 'trivy-results.sarif'| uses: aquasecurity/trivy-action@master | |
| with: | |
| image-ref: 'ghcr.io/${{ github.repository }}/frontend:latest' | |
| format: 'table' | |
| exit-code: '1' | |
| uses: aquasecurity/trivy-action@0.17.0 | |
| with: | |
| image-ref: 'ghcr.io/${{ github.repository }}/frontend:latest' | |
| format: 'table' | |
| exit-code: '1' | |
| env: | |
| TRIVY_USERNAME: ${{ github.actor }} | |
| TRIVY_PASSWORD: ${{ secrets.GITHUB_TOKEN }} |
| - name: Deploy to Railway | ||
| uses: railwayapp/cli-action@v1 | ||
| with: | ||
| railway_token: ${{ secrets.RAILWAY_API_TOKEN }} |
Copilot
AI
Nov 27, 2025
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 Railway deployment step is missing critical information for a successful deployment. The railwayapp/cli-action@v1 requires additional parameters such as:
service: The service name to deployenvironment: The environment to deploy to (e.g., production, staging)
Without these parameters, the deployment may fail or deploy to an unintended target.
Suggested fix:
- name: Deploy to Railway
uses: railwayapp/cli-action@v1
with:
railway_token: ${{ secrets.RAILWAY_API_TOKEN }}
service: backend
environment: production| railway_token: ${{ secrets.RAILWAY_API_TOKEN }} | |
| railway_token: ${{ secrets.RAILWAY_API_TOKEN }} | |
| service: backend | |
| environment: production |
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| pull_request: | ||
| branches: | ||
| - main |
Copilot
AI
Nov 27, 2025
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.
[nitpick] The workflow uses push to main branch as a trigger (lines 5-7), which means every push to main will trigger build, push, and deploy. This could lead to unnecessary deployments if multiple commits are pushed quickly or if the deploy should only happen on releases.
Consider adding conditions to prevent deployment on every push:
on:
push:
branches:
- main
tags:
- 'v*' # Deploy only on version tags
pull_request:
branches:
- main
jobs:
# ... test and build jobs ...
deploy:
runs-on: ubuntu-latest
needs: build_and_push
if: github.event_name == 'push' && github.ref == 'refs/heads/main' # Only deploy on push to main, not PRs|
@kishore8220 -> pls review |
|
Hey! Thanks for the PR. I found a few issues that need fixing: Main Issues:
Suggestions:
|
|
I'll check that. |
|
The CI/CD pipeline implementation is well-structured and covers the necessary stages for build, test, and deployment. I appreciate the use of environment variables and the separation of concerns within the workflow files. |
📝 Description
A brief description of what this PR does.
🔗 Related Issue
Closes #(issue number)
🎯 Type of Change
🧪 Testing
How has this been tested?
Test Steps:
📸 Screenshots (if applicable)
Add screenshots to help explain your changes.
✅ Checklist
🔍 Review Notes
Any special notes for reviewers:
📚 Additional Context
Add any other context about the PR here.
Thank you for contributing to FairMind! 🎉