I am trying to deploy nextjs app with python backend and while building, not getting .next
In my local it’s creating the .next folder but not able to do it runner. I have added github log, deploy.yml and Package.json for your reference.
Github Action log:
▲ Next.js 14.0.4
Creating an optimized production build ...
✓ Compiled successfully
Linting and checking validity of types ...
Collecting page data ...
Generating static pages (0/6) ...
Generating static pages (1/6)
Generating static pages (2/6)
Generating static pages (4/6)
✓ Generating static pages (6/6)
Finalizing page optimization ...
Collecting build traces ...
Route (app) Size First Load JS
┌ ○ / 17 kB 107 kB
├ ○ /_not-found 869 B 82.7 kB
└ ○ /search 2.02 kB 92 kB
+ First Load JS shared by all 81.9 kB
├ chunks/938-973fd475f3395692.js 26.7 kB
├ chunks/fd9d1056-6532a1a12736ec51.js 53.3 kB
├ chunks/main-app-9f89b1569ca96400.js 220 B
└ chunks/webpack-073e1eb02d0477d3.js 1.68 kB
○ (Static) prerendered as static content
Below is package.json which also installs requirements.txt for python backend.
Package.json:
{
"name": "rag",
"version": "0.1.0",
"private": true,
"scripts": {
"fastapi-dev": "pip install -r requirements.txt && python -m uvicorn api.app:app --reload",
"next-dev": "next dev",
"dev": "concurrently "npm run next-dev" "npm run fastapi-dev"",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@tabler/icons-react": "^2.47.0",
"ai": "^2.2.31",
"markdown-to-jsx": "^7.4.0",
"next": "14.0.4",
"react": "^18",
"react-dom": "^18",
"concurrently": "^8.0.1"
},
"devDependencies": {
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"autoprefixer": "^10.0.1",
"clsx": "^2.1.0",
"eslint": "^8",
"eslint-config-next": "14.0.4",
"postcss": "^8",
"prettier": "^3.2.5",
"tailwind-merge": "^2.2.1",
"tailwindcss": "^3.3.0",
"typescript": "^5"
}
}
deploy.yml
name: Deploy to EC2
on:
push:
branches:
- main # Replace with your main branch name
jobs:
deploy:
runs-on: self-hosted
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '20.10.0'
- run: npm ci
- run: npm run build
- run: ls -l
- name: Deploy to EC2
env:
PRIVATE_KEY: ${{ secrets.EC2_PRIVATE_KEY }}
HOST_NAME: ${{ secrets.EC2_HOST_NAME }}
USER_NAME: ${{ secrets.EC2_USER_NAME }}
run: |
echo "Creating SSH directory..."
mkdir -p ~/.ssh/
echo "Adding private key..."
echo "$PRIVATE_KEY" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
echo "Copying .next directory to EC2 instance..."
scp -o StrictHostKeyChecking=no -r .next $USER_NAME@$HOST_NAME:/home/$USER_NAME/chatbot-vector-search/
echo "Running deployment script on EC2 instance..."
ssh -o StrictHostKeyChecking=no $USER_NAME@$HOST_NAME "/home/$USER_NAME/chatbot-vector-search/deployNextApp.sh"