update(docker)
This commit is contained in:
parent
e09992f851
commit
9f3b4a4613
5 changed files with 103 additions and 31 deletions
14
.dockerignore
Normal file
14
.dockerignore
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
.git
|
||||
.gitignore
|
||||
node_modules
|
||||
server/node_modules
|
||||
client/node_modules
|
||||
server/dist
|
||||
client/dist
|
||||
client/storybook-static
|
||||
data
|
||||
nogit
|
||||
nosync
|
||||
README.md
|
||||
docs
|
||||
session-*.md
|
||||
64
Dockerfile
64
Dockerfile
|
|
@ -1,33 +1,57 @@
|
|||
FROM node:18-alpine
|
||||
ARG NODE_VERSION=24.13.0
|
||||
|
||||
FROM node:${NODE_VERSION}-bookworm-slim AS build
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install curl for healthcheck
|
||||
RUN apk add --no-cache curl
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends python3 make g++ pkg-config \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Copy package files
|
||||
COPY package.json package-lock.json* ./
|
||||
COPY server/package.json ./server/
|
||||
COPY client/package.json ./client/
|
||||
RUN corepack enable
|
||||
|
||||
# Install dependencies
|
||||
RUN npm ci
|
||||
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc ./
|
||||
COPY server/package.json ./server/package.json
|
||||
COPY client/package.json ./client/package.json
|
||||
|
||||
# Copy source code
|
||||
COPY server/ ./server/
|
||||
COPY client/ ./client/
|
||||
COPY scripts/ ./scripts/
|
||||
COPY database/ ./database/
|
||||
RUN pnpm install --frozen-lockfile
|
||||
|
||||
# Build client
|
||||
RUN npm run build --workspace=client
|
||||
COPY server ./server
|
||||
COPY client ./client
|
||||
COPY shared ./shared
|
||||
COPY database ./database
|
||||
COPY scripts ./scripts
|
||||
|
||||
# Build server
|
||||
RUN npm run build --workspace=server
|
||||
RUN pnpm build
|
||||
|
||||
FROM node:${NODE_VERSION}-bookworm-slim AS server
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends curl \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& corepack enable
|
||||
|
||||
ENV NODE_ENV=production
|
||||
ENV SERVER_PORT=3000
|
||||
ENV DB_DIR=/data
|
||||
|
||||
COPY --from=build /app/node_modules ./node_modules
|
||||
COPY --from=build /app/package.json ./package.json
|
||||
COPY --from=build /app/server/package.json ./server/package.json
|
||||
COPY --from=build /app/server/dist ./server/dist
|
||||
COPY --from=build /app/database ./database
|
||||
|
||||
# Create data directory
|
||||
RUN mkdir -p /data
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
CMD ["npm", "start"]
|
||||
CMD ["node", "server/dist/server/src/index.js"]
|
||||
|
||||
FROM nginx:1.28-alpine AS client
|
||||
|
||||
COPY docker/nginx.conf /etc/nginx/conf.d/default.conf
|
||||
COPY --from=build /app/client/dist /usr/share/nginx/html
|
||||
|
||||
EXPOSE 80
|
||||
|
|
|
|||
|
|
@ -1,17 +1,16 @@
|
|||
version: '3.8'
|
||||
|
||||
services:
|
||||
router:
|
||||
build: .
|
||||
server:
|
||||
build:
|
||||
context: .
|
||||
target: server
|
||||
ports:
|
||||
- "3000:3000"
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
- SERVER_PORT=3000
|
||||
- CLIENT_PORT=3001
|
||||
- CORE_DB_PATH=/data/core.db
|
||||
- ANALYTICS_DB_PATH=/data/analytics.db
|
||||
- ADMIN_PASSWORD=${ADMIN_PASSWORD:-}
|
||||
NODE_ENV: production
|
||||
SERVER_PORT: 3000
|
||||
DB_DIR: /data
|
||||
TZ: ${TZ:-UTC}
|
||||
CORS_ORIGINS: http://localhost:3002,http://127.0.0.1:3002
|
||||
volumes:
|
||||
- router-data:/data
|
||||
restart: unless-stopped
|
||||
|
|
@ -21,5 +20,20 @@ services:
|
|||
timeout: 10s
|
||||
retries: 3
|
||||
|
||||
client:
|
||||
build:
|
||||
context: .
|
||||
target: client
|
||||
depends_on:
|
||||
- server
|
||||
ports:
|
||||
- "3002:80"
|
||||
restart: unless-stopped
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "wget -q -O /dev/null http://localhost/ || exit 1"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
|
||||
volumes:
|
||||
router-data:
|
||||
|
|
|
|||
20
docker/nginx.conf
Normal file
20
docker/nginx.conf
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
location /api/ {
|
||||
proxy_pass http://server:3000/;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
}
|
||||
|
|
@ -23,6 +23,6 @@
|
|||
"client"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
"node": "24.13.0"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue