Compare commits
6 Commits
1433ac2ce7
...
e4c5432f47
| Author | SHA1 | Date | |
|---|---|---|---|
| e4c5432f47 | |||
|
|
1cffd1f4c9 | ||
|
|
0f8e57e93b | ||
|
|
77714c101b | ||
|
|
befab94352 | ||
|
|
14b16b3ea9 |
56
.gitea/workflows/deploy.yml
Normal file
56
.gitea/workflows/deploy.yml
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
name: Deploy to Production
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
npm install
|
||||
cd backend && npm install && cd ..
|
||||
cd frontend && npm install && cd ..
|
||||
|
||||
- name: Run backend tests
|
||||
run: |
|
||||
cd backend
|
||||
npm test || echo "No tests configured"
|
||||
|
||||
- name: Build frontend
|
||||
run: |
|
||||
cd frontend
|
||||
npm run build
|
||||
|
||||
- name: Deploy to server
|
||||
env:
|
||||
SERVER_HOST: ${{ secrets.SERVER_HOST }}
|
||||
SERVER_USER: ${{ secrets.SERVER_USER }}
|
||||
SSH_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
run: |
|
||||
# Setup SSH
|
||||
mkdir -p ~/.ssh
|
||||
echo "$SSH_KEY" > ~/.ssh/deploy_key
|
||||
chmod 600 ~/.ssh/deploy_key
|
||||
ssh-keyscan -H $SERVER_HOST >> ~/.ssh/known_hosts
|
||||
|
||||
# Deploy
|
||||
ssh -i ~/.ssh/deploy_key $SERVER_USER@$SERVER_HOST << 'EOF'
|
||||
cd /var/www/aeroEcho
|
||||
git pull origin main
|
||||
npm run install:all
|
||||
cd frontend && npm run build && cd ..
|
||||
pm2 restart ecosystem.config.js
|
||||
EOF
|
||||
1
backend/index.js
Normal file
1
backend/index.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
// CI/CD test
|
||||
|
|
@ -33,7 +33,7 @@ const allowedOrigins = ["https://aeroecho.onrender.com"];
|
|||
if (NODE_ENV === "development" || NODE_ENV === "staging") {
|
||||
allowedOrigins.push("http://localhost:3000");
|
||||
}
|
||||
|
||||
//test
|
||||
const corsOptions = {
|
||||
origin: function (origin, callback) {
|
||||
if (!origin || allowedOrigins.indexOf(origin) !== -1) {
|
||||
|
|
|
|||
24
ecosystem.config.js
Normal file
24
ecosystem.config.js
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
module.exports = {
|
||||
apps: [
|
||||
{
|
||||
name: 'aeroecho-backend',
|
||||
cwd: './backend',
|
||||
script: 'npm',
|
||||
args: 'start',
|
||||
env: {
|
||||
NODE_ENV: 'production',
|
||||
PORT: 3001
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'aeroecho-frontend',
|
||||
cwd: './frontend',
|
||||
script: 'npm',
|
||||
args: 'start',
|
||||
env: {
|
||||
NODE_ENV: 'production',
|
||||
PORT: 3000
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
|
@ -125,6 +125,23 @@ const FlightsLayer = ({ flightsData, updateInterval = 5000 }) => {
|
|||
return null;
|
||||
};
|
||||
|
||||
const InitialBounds = ({ setBoundries }) => {
|
||||
const map = useMap();
|
||||
|
||||
useEffect(() => {
|
||||
// Wait for map to be ready, then set initial bounds
|
||||
map.whenReady(() => {
|
||||
const bounds = map.getBounds();
|
||||
setBoundries({
|
||||
southWest: bounds.getSouthWest(),
|
||||
northEast: bounds.getNorthEast(),
|
||||
});
|
||||
});
|
||||
}, [map, setBoundries]);
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
const createPlaneIcon = (heading = 0) => {
|
||||
const html = `
|
||||
<div style="
|
||||
|
|
@ -220,6 +237,7 @@ const MapView = () => {
|
|||
worldCopyJump={true}
|
||||
>
|
||||
<TileLayer url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" />
|
||||
<InitialBounds setBoundries={setBoundaries} />
|
||||
<FlightsLayer flightsData={flights} updateInterval={2000} />
|
||||
<MapBounds setBoundries={setBoundaries} />
|
||||
</MapContainer>
|
||||
|
|
|
|||
4
package-lock.json
generated
4
package-lock.json
generated
|
|
@ -1,10 +1,10 @@
|
|||
{
|
||||
"name": "my-fullstack-app",
|
||||
"name": "aeroecho-fullstack",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "my-fullstack-app",
|
||||
"name": "aeroecho-fullstack",
|
||||
"devDependencies": {
|
||||
"concurrently": "^8.2.2"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
"name": "aeroecho-fullstack",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "concurrently \"npm run backend:dev\" \"npm run frontend:dev\"",
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user