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:
18
.env.example
Normal file
18
.env.example
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Database Configuration
|
||||||
|
# Use localhost for local 'bun run dev'
|
||||||
|
# docker-compose will override this with its own service name 'postgres'
|
||||||
|
DATABASE_URL=postgres://postgres:password@localhost:5432/alert_message_center
|
||||||
|
|
||||||
|
# Feishu (Lark) App Configuration
|
||||||
|
# Make sure to ADD BOTH to your Feishu App Management console!
|
||||||
|
FEISHU_APP_ID=your_app_id
|
||||||
|
FEISHU_APP_SECRET=your_app_secret
|
||||||
|
FEISHU_VERIFICATION_TOKEN=your_verification_token
|
||||||
|
FEISHU_ENCRYPT_KEY=your_encrypt_key
|
||||||
|
|
||||||
|
# Admin configuration (comma-separated emails)
|
||||||
|
ADMIN_EMAILS=admin@example.com
|
||||||
|
|
||||||
|
# Optional: Frontend URL for CORS during local dev
|
||||||
|
FRONTEND_URL=http://localhost:3000
|
||||||
|
REDIRECT_URI=http://localhost:3000/auth/callback
|
||||||
26
Dockerfile
Normal file
26
Dockerfile
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
# Build stage for web
|
||||||
|
FROM oven/bun:1-alpine AS web-builder
|
||||||
|
WORKDIR /app
|
||||||
|
COPY . .
|
||||||
|
RUN bun install --frozen-lockfile
|
||||||
|
WORKDIR /app/apps/web
|
||||||
|
RUN bun run build
|
||||||
|
|
||||||
|
# Final stage
|
||||||
|
FROM oven/bun:1-alpine
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy the entire project for monorepo context
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Install dependencies for the server (and shared workspace if any)
|
||||||
|
RUN bun install --frozen-lockfile
|
||||||
|
|
||||||
|
# Copy built web assets to server's public directory
|
||||||
|
COPY --from=web-builder /app/apps/web/dist /app/apps/server/public
|
||||||
|
|
||||||
|
WORKDIR /app/apps/server
|
||||||
|
|
||||||
|
EXPOSE 3000
|
||||||
|
|
||||||
|
CMD ["bun", "run", "start"]
|
||||||
@@ -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",
|
"name": "@alertmessagecenter/server",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "bun run --watch src/index.ts",
|
"dev": "bun run --env-file .env --watch src/index.ts",
|
||||||
"start": "bun run src/index.ts",
|
"start": "bun run src/index.ts",
|
||||||
"db:generate": "drizzle-kit generate",
|
"db:generate": "drizzle-kit generate",
|
||||||
"db:migrate": "drizzle-kit migrate",
|
"db:migrate": "drizzle-kit migrate",
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { Hono } from 'hono';
|
import { Hono } from 'hono';
|
||||||
import { cors } from 'hono/cors';
|
import { cors } from 'hono/cors';
|
||||||
|
import { serveStatic } from 'hono/bun';
|
||||||
import { db } from './db';
|
import { db } from './db';
|
||||||
import { topics } from './db/schema';
|
import { topics } from './db/schema';
|
||||||
import webhook from './webhook';
|
import webhook from './webhook';
|
||||||
@@ -14,14 +15,15 @@ app.use('/*', cors({
|
|||||||
credentials: true,
|
credentials: true,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
app.get('/', (c) => {
|
// API Routes
|
||||||
return c.text('Alert Message Center API is running!');
|
|
||||||
});
|
|
||||||
|
|
||||||
const routes = app.route('/api/auth', auth)
|
const routes = app.route('/api/auth', auth)
|
||||||
.route('/api', api)
|
.route('/api', api)
|
||||||
.route('/webhook', webhook);
|
.route('/webhook', webhook);
|
||||||
|
|
||||||
|
// Serve static files (Frontend)
|
||||||
|
app.use('/*', serveStatic({ root: './public' }));
|
||||||
|
app.get('*', serveStatic({ path: './public/index.html' }));
|
||||||
|
|
||||||
app.onError((err, c) => {
|
app.onError((err, c) => {
|
||||||
console.error(`[Global Error] ${c.req.method} ${c.req.url}:`, err);
|
console.error(`[Global Error] ${c.req.method} ${c.req.url}:`, err);
|
||||||
return c.json({ error: err.message || 'Internal Server Error' }, 500);
|
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",
|
"version": "1.0.0",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "bun run --env-file .env vite",
|
||||||
"build": "tsc && vite build",
|
"build": "tsc && vite build",
|
||||||
"preview": "vite preview"
|
"preview": "vite preview"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -13,11 +13,11 @@ export default defineConfig({
|
|||||||
server: {
|
server: {
|
||||||
proxy: {
|
proxy: {
|
||||||
'/api': {
|
'/api': {
|
||||||
target: 'http://localhost:3000',
|
target: process.env.VITE_API_URL || 'http://localhost:3000',
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
},
|
},
|
||||||
'/webhook': {
|
'/webhook': {
|
||||||
target: 'http://localhost:3000',
|
target: process.env.VITE_API_URL || 'http://localhost:3000',
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
services:
|
services:
|
||||||
server:
|
app:
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: apps/server/Dockerfile
|
dockerfile: Dockerfile
|
||||||
ports:
|
ports:
|
||||||
- "3000:3000"
|
- "3000:3000"
|
||||||
environment:
|
environment:
|
||||||
@@ -13,15 +13,6 @@ services:
|
|||||||
depends_on:
|
depends_on:
|
||||||
- postgres
|
- postgres
|
||||||
|
|
||||||
web:
|
|
||||||
build:
|
|
||||||
context: .
|
|
||||||
dockerfile: apps/web/Dockerfile
|
|
||||||
ports:
|
|
||||||
- "80:80"
|
|
||||||
depends_on:
|
|
||||||
- server
|
|
||||||
|
|
||||||
postgres:
|
postgres:
|
||||||
image: postgres:17-alpine
|
image: postgres:17-alpine
|
||||||
restart: always
|
restart: always
|
||||||
|
|||||||
@@ -6,7 +6,8 @@
|
|||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "bun run --filter '*' dev",
|
"dev": "bun run --filter '*' dev",
|
||||||
"build": "bun run --filter '*' build"
|
"build": "bun run --filter '*' build",
|
||||||
|
"start": "bun run --filter '@alertmessagecenter/server' start"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"bun-types": "latest"
|
"bun-types": "latest"
|
||||||
|
|||||||
Reference in New Issue
Block a user