Prep build setup for stack
This commit is contained in:
parent
3a761e3eb1
commit
bd2ffee9ae
14 changed files with 668 additions and 91 deletions
|
|
@ -6,17 +6,17 @@ WORKDIR /app
|
|||
# Copy package files first to leverage Docker's build cache
|
||||
COPY package*.json ./
|
||||
|
||||
# Install all dependencies needed for the build
|
||||
RUN npm install
|
||||
# Install dependencies
|
||||
RUN npm ci --only=production=false
|
||||
|
||||
# Copy the rest of your application code
|
||||
COPY . .
|
||||
|
||||
# Run the build script to compile the React frontend
|
||||
# Build the React application
|
||||
RUN npm run build
|
||||
|
||||
# Expose the port your server will listen on
|
||||
# Expose the port
|
||||
EXPOSE 3000
|
||||
|
||||
# The command to start your production server
|
||||
CMD ["npm", "run", "host"]
|
||||
# Use preview mode for production-like serving
|
||||
CMD ["npm", "run", "preview"]
|
||||
|
|
@ -1,40 +1,37 @@
|
|||
{
|
||||
"name": "codered-astra",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "vite build",
|
||||
"dev": "vite",
|
||||
"host": "vite host",
|
||||
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
|
||||
"clean-dist": "find apps/ -type d -name 'dist' -print0 | xargs -r0 -- rm -r",
|
||||
"clean-all": "find apps/ -type d -name 'dist' -print0 | xargs -r0 -- rm -r && find . -path ./node_modules -prune -o -name 'node_modules' | xargs rm -rf "
|
||||
"build": "vite build",
|
||||
"preview": "vite preview",
|
||||
"host": "vite --host 0.0.0.0 --port 3000",
|
||||
"lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0",
|
||||
"format": "prettier --write \"**/*.{js,jsx,md}\""
|
||||
},
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@google/genai": "^1.25.0",
|
||||
"@vitejs/plugin-react": "^5.0.4",
|
||||
"cors": "^2.8.5",
|
||||
"dotenv": "^17.2.3",
|
||||
"express": "^5.1.0",
|
||||
"helmet": "^8.1.0",
|
||||
"@google/generative-ai": "^0.21.0",
|
||||
"axios": "^1.7.7",
|
||||
"lucide-react": "^0.546.0",
|
||||
"pg": "^8.16.3",
|
||||
"react": "^19.2.0",
|
||||
"react-dom": "^19.2.0",
|
||||
"react-router": "^7.9.4",
|
||||
"react-router-dom": "^7.9.4",
|
||||
"tailwindcss": "^4.1.14",
|
||||
"vite-jsconfig-paths": "^2.0.1"
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1",
|
||||
"react-router-dom": "^6.28.0"
|
||||
},
|
||||
"packageManager": ">=npm@10.9.0",
|
||||
"devDependencies": {
|
||||
"eslint": "^9.38.0",
|
||||
"eslint-plugin-import": "^2.32.0",
|
||||
"eslint-plugin-react": "^7.37.5",
|
||||
"eslint-plugin-react-hooks": "^7.0.0",
|
||||
"eslint-plugin-react-refresh": "^0.4.24",
|
||||
"nodemon": "^3.1.10",
|
||||
"prettier": "^3.6.2",
|
||||
"vite": "^7.1.10"
|
||||
"@types/react": "^18.3.12",
|
||||
"@types/react-dom": "^18.3.1",
|
||||
"@vitejs/plugin-react": "^4.3.3",
|
||||
"autoprefixer": "^10.4.20",
|
||||
"eslint": "^9.14.0",
|
||||
"eslint-plugin-react": "^7.37.2",
|
||||
"eslint-plugin-react-hooks": "^5.0.0",
|
||||
"eslint-plugin-react-refresh": "^0.4.14",
|
||||
"postcss": "^8.4.47",
|
||||
"prettier": "^3.3.3",
|
||||
"tailwindcss": "^3.4.14",
|
||||
"vite": "^5.4.10",
|
||||
"vite-jsconfig-paths": "^2.0.1"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
6
web-app/postcss.config.js
Normal file
6
web-app/postcss.config.js
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
export default {
|
||||
plugins: {
|
||||
tailwindcss: {},
|
||||
autoprefixer: {},
|
||||
},
|
||||
}
|
||||
|
|
@ -1,34 +1,136 @@
|
|||
import { useState } from "react";
|
||||
import reactLogo from "./assets/react.svg";
|
||||
import viteLogo from "/vite.svg";
|
||||
import "./App.css";
|
||||
import { useState, useEffect } from "react";
|
||||
import { Cpu, Database, Zap, Activity } from "lucide-react";
|
||||
|
||||
function App() {
|
||||
const [count, setCount] = useState(0);
|
||||
const [engineStatus, setEngineStatus] = useState(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
checkEngineHealth();
|
||||
}, []);
|
||||
|
||||
const checkEngineHealth = async () => {
|
||||
try {
|
||||
const response = await fetch('/api/health');
|
||||
const data = await response.json();
|
||||
setEngineStatus(data);
|
||||
} catch (error) {
|
||||
console.error('Engine health check failed:', error);
|
||||
setEngineStatus({ success: false, message: 'Engine offline' });
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<div>
|
||||
<a href="https://vite.dev" target="_blank">
|
||||
<img src={viteLogo} className="logo" alt="Vite logo" />
|
||||
</a>
|
||||
<a href="https://react.dev" target="_blank">
|
||||
<img src={reactLogo} className="logo react" alt="React logo" />
|
||||
</a>
|
||||
<div className="min-h-screen bg-gradient-to-br from-gray-900 via-purple-900 to-violet-900">
|
||||
<div className="container mx-auto px-4 py-8">
|
||||
{/* Header */}
|
||||
<header className="text-center mb-12">
|
||||
<div className="flex items-center justify-center mb-4">
|
||||
<Zap className="h-12 w-12 text-yellow-400 mr-3" />
|
||||
<h1 className="text-4xl font-bold text-white">
|
||||
CodeRED-Astra
|
||||
</h1>
|
||||
</div>
|
||||
<p className="text-gray-300 text-lg">
|
||||
Hackathon Project - React Frontend + Rust Engine
|
||||
</p>
|
||||
</header>
|
||||
|
||||
{/* Status Cards */}
|
||||
<div className="grid md:grid-cols-2 gap-6 mb-8">
|
||||
{/* React App Status */}
|
||||
<div className="bg-white/10 backdrop-blur-lg rounded-lg p-6 border border-white/20">
|
||||
<div className="flex items-center mb-4">
|
||||
<Activity className="h-8 w-8 text-blue-400 mr-3" />
|
||||
<h2 className="text-xl font-semibold text-white">React Frontend</h2>
|
||||
</div>
|
||||
<div className="text-green-400 font-medium">✓ Online</div>
|
||||
<p className="text-gray-300 text-sm mt-2">
|
||||
Vite + React development environment ready
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Rust Engine Status */}
|
||||
<div className="bg-white/10 backdrop-blur-lg rounded-lg p-6 border border-white/20">
|
||||
<div className="flex items-center mb-4">
|
||||
<Cpu className="h-8 w-8 text-orange-400 mr-3" />
|
||||
<h2 className="text-xl font-semibold text-white">Rust Engine</h2>
|
||||
</div>
|
||||
<div className={`font-medium ${loading ? 'text-yellow-400' : engineStatus?.success ? 'text-green-400' : 'text-red-400'}`}>
|
||||
{loading ? '⏳ Checking...' : engineStatus?.success ? '✓ Online' : '✗ Offline'}
|
||||
</div>
|
||||
<p className="text-gray-300 text-sm mt-2">
|
||||
{loading ? 'Connecting to engine...' :
|
||||
engineStatus?.success ? 'Engine responding normally' :
|
||||
'Engine may still be starting up'}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Engine Details */}
|
||||
{engineStatus?.success && (
|
||||
<div className="bg-white/10 backdrop-blur-lg rounded-lg p-6 border border-white/20 mb-8">
|
||||
<div className="flex items-center mb-4">
|
||||
<Database className="h-6 w-6 text-purple-400 mr-3" />
|
||||
<h3 className="text-lg font-semibold text-white">Engine Status</h3>
|
||||
</div>
|
||||
<div className="grid md:grid-cols-2 gap-4 text-sm">
|
||||
<div>
|
||||
<span className="text-gray-400">Status:</span>
|
||||
<span className="text-white ml-2">{engineStatus.data?.status}</span>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-gray-400">Last Check:</span>
|
||||
<span className="text-white ml-2">
|
||||
{engineStatus.data?.timestamp ? new Date(engineStatus.data.timestamp).toLocaleTimeString() : 'N/A'}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
{engineStatus.message && (
|
||||
<div className="mt-3 p-3 bg-yellow-500/20 border border-yellow-500/30 rounded">
|
||||
<span className="text-yellow-200 text-sm">{engineStatus.message}</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Quick Actions */}
|
||||
<div className="bg-white/10 backdrop-blur-lg rounded-lg p-6 border border-white/20">
|
||||
<h3 className="text-lg font-semibold text-white mb-4">Quick Actions</h3>
|
||||
<div className="flex flex-wrap gap-3">
|
||||
<button
|
||||
onClick={checkEngineHealth}
|
||||
className="px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-colors"
|
||||
>
|
||||
Refresh Status
|
||||
</button>
|
||||
<button
|
||||
onClick={() => window.open('/api/health', '_blank')}
|
||||
className="px-4 py-2 bg-purple-600 hover:bg-purple-700 text-white rounded-lg transition-colors"
|
||||
>
|
||||
Test API Direct
|
||||
</button>
|
||||
<button
|
||||
onClick={() => alert('Add your hackathon features here!')}
|
||||
className="px-4 py-2 bg-green-600 hover:bg-green-700 text-white rounded-lg transition-colors"
|
||||
>
|
||||
Add Feature
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Development Notes */}
|
||||
<div className="mt-8 text-center text-gray-400 text-sm">
|
||||
<p>🚀 Ready for hackathon development!</p>
|
||||
<p className="mt-1">
|
||||
Frontend team: Work in <code className="bg-white/10 px-1 rounded">web-app/src/</code> |
|
||||
Backend team: Work in <code className="bg-white/10 px-1 rounded">rust-engine/src/</code>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<h1>Vite + React</h1>
|
||||
<div className="card">
|
||||
<button onClick={() => setCount((count) => count + 1)}>
|
||||
count is {count}
|
||||
</button>
|
||||
<p>
|
||||
Edit <code>src/App.jsx</code> and save to test HMR
|
||||
</p>
|
||||
</div>
|
||||
<p className="read-the-docs">
|
||||
Click on the Vite and React logos to learn more
|
||||
</p>
|
||||
</>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,28 +2,32 @@
|
|||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
|
||||
.light {
|
||||
--paragraph: 16, 17, 20;
|
||||
--background: 229, 230, 240;
|
||||
--primary: 41, 49, 97;
|
||||
--secondary: 122, 137, 220;
|
||||
--accent: 32, 55, 203;
|
||||
background: rgba(var(--background));
|
||||
}
|
||||
.dark {
|
||||
--paragraph: 235, 236, 239;
|
||||
--background: 15, 16, 26;
|
||||
--primary: 158, 166, 214;
|
||||
--secondary: 35, 50, 133;
|
||||
--accent: 52, 75, 223;
|
||||
background: rgba(var(--background));
|
||||
:root {
|
||||
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
|
||||
line-height: 1.5;
|
||||
font-weight: 400;
|
||||
color-scheme: dark;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
background-color: #242424;
|
||||
font-synthesis: none;
|
||||
text-rendering: optimizeLegibility;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
font-family:
|
||||
-apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu",
|
||||
"Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
display: flex;
|
||||
place-items: center;
|
||||
min-width: 320px;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
#root {
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
code {
|
||||
font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,4 +5,22 @@ import jsconfigPaths from "vite-jsconfig-paths";
|
|||
// https://vite.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [react(), jsconfigPaths()],
|
||||
server: {
|
||||
host: '0.0.0.0',
|
||||
port: 3000,
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: process.env.RUST_ENGINE_URL || 'http://localhost:8000',
|
||||
changeOrigin: true,
|
||||
rewrite: (path) => path.replace(/^\/api/, '')
|
||||
}
|
||||
}
|
||||
},
|
||||
preview: {
|
||||
host: '0.0.0.0',
|
||||
port: 3000
|
||||
},
|
||||
build: {
|
||||
outDir: 'dist'
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue