mirror of
https://github.com/d0zingcat/alert-message-center.git
synced 2026-05-13 15:09:19 +00:00
feat: add docker ci pack
Signed-off-by: d0zingcat <iamtangli42@gmail.com>
This commit is contained in:
@@ -1,15 +0,0 @@
|
||||
FROM oven/bun:1-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy the entire project for monorepo context
|
||||
COPY . .
|
||||
|
||||
# Install dependencies
|
||||
RUN bun install --frozen-lockfile
|
||||
|
||||
WORKDIR /app/apps/server
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
CMD ["bun", "run", "start"]
|
||||
@@ -2,7 +2,7 @@
|
||||
"name": "@alertmessagecenter/server",
|
||||
"version": "1.0.0",
|
||||
"scripts": {
|
||||
"dev": "bun run --watch src/index.ts",
|
||||
"dev": "bun run --env-file .env --watch src/index.ts",
|
||||
"start": "bun run src/index.ts",
|
||||
"db:generate": "drizzle-kit generate",
|
||||
"db:migrate": "drizzle-kit migrate",
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Hono } from 'hono';
|
||||
import { cors } from 'hono/cors';
|
||||
import { serveStatic } from 'hono/bun';
|
||||
import { db } from './db';
|
||||
import { topics } from './db/schema';
|
||||
import webhook from './webhook';
|
||||
@@ -14,14 +15,15 @@ app.use('/*', cors({
|
||||
credentials: true,
|
||||
}));
|
||||
|
||||
app.get('/', (c) => {
|
||||
return c.text('Alert Message Center API is running!');
|
||||
});
|
||||
|
||||
// API Routes
|
||||
const routes = app.route('/api/auth', auth)
|
||||
.route('/api', api)
|
||||
.route('/webhook', webhook);
|
||||
|
||||
// Serve static files (Frontend)
|
||||
app.use('/*', serveStatic({ root: './public' }));
|
||||
app.get('*', serveStatic({ path: './public/index.html' }));
|
||||
|
||||
app.onError((err, c) => {
|
||||
console.error(`[Global Error] ${c.req.method} ${c.req.url}:`, err);
|
||||
return c.json({ error: err.message || 'Internal Server Error' }, 500);
|
||||
|
||||
2
apps/web/.env.example
Normal file
2
apps/web/.env.example
Normal file
@@ -0,0 +1,2 @@
|
||||
# Backend API URL (for proxying)
|
||||
VITE_API_URL=http://localhost:3000
|
||||
@@ -1,21 +0,0 @@
|
||||
# Build stage
|
||||
FROM oven/bun:1-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy the entire project
|
||||
COPY . .
|
||||
|
||||
# Install dependencies
|
||||
RUN bun install --frozen-lockfile
|
||||
|
||||
# Build the web app
|
||||
WORKDIR /app/apps/web
|
||||
RUN bun run build
|
||||
|
||||
# Serve stage
|
||||
FROM nginx:alpine
|
||||
COPY --from=builder /app/apps/web/dist /usr/share/nginx/html
|
||||
# Add a custom nginx config if needed to handle SPA routing, but for now default is okay
|
||||
EXPOSE 80
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
@@ -3,7 +3,7 @@
|
||||
"version": "1.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"dev": "bun run --env-file .env vite",
|
||||
"build": "tsc && vite build",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
|
||||
@@ -13,11 +13,11 @@ export default defineConfig({
|
||||
server: {
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'http://localhost:3000',
|
||||
target: process.env.VITE_API_URL || 'http://localhost:3000',
|
||||
changeOrigin: true,
|
||||
},
|
||||
'/webhook': {
|
||||
target: 'http://localhost:3000',
|
||||
target: process.env.VITE_API_URL || 'http://localhost:3000',
|
||||
changeOrigin: true,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user