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
|
WORKDIR /app
|
||||||
|
|
||||||
# Install curl for healthcheck
|
RUN apt-get update \
|
||||||
RUN apk add --no-cache curl
|
&& apt-get install -y --no-install-recommends python3 make g++ pkg-config \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Copy package files
|
RUN corepack enable
|
||||||
COPY package.json package-lock.json* ./
|
|
||||||
COPY server/package.json ./server/
|
|
||||||
COPY client/package.json ./client/
|
|
||||||
|
|
||||||
# Install dependencies
|
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc ./
|
||||||
RUN npm ci
|
COPY server/package.json ./server/package.json
|
||||||
|
COPY client/package.json ./client/package.json
|
||||||
|
|
||||||
# Copy source code
|
RUN pnpm install --frozen-lockfile
|
||||||
COPY server/ ./server/
|
|
||||||
COPY client/ ./client/
|
|
||||||
COPY scripts/ ./scripts/
|
|
||||||
COPY database/ ./database/
|
|
||||||
|
|
||||||
# Build client
|
COPY server ./server
|
||||||
RUN npm run build --workspace=client
|
COPY client ./client
|
||||||
|
COPY shared ./shared
|
||||||
|
COPY database ./database
|
||||||
|
COPY scripts ./scripts
|
||||||
|
|
||||||
# Build server
|
RUN pnpm build
|
||||||
RUN npm run build --workspace=server
|
|
||||||
|
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
|
RUN mkdir -p /data
|
||||||
|
|
||||||
EXPOSE 3000
|
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:
|
services:
|
||||||
router:
|
server:
|
||||||
build: .
|
build:
|
||||||
|
context: .
|
||||||
|
target: server
|
||||||
ports:
|
ports:
|
||||||
- "3000:3000"
|
- "3000:3000"
|
||||||
environment:
|
environment:
|
||||||
- NODE_ENV=production
|
NODE_ENV: production
|
||||||
- SERVER_PORT=3000
|
SERVER_PORT: 3000
|
||||||
- CLIENT_PORT=3001
|
DB_DIR: /data
|
||||||
- CORE_DB_PATH=/data/core.db
|
TZ: ${TZ:-UTC}
|
||||||
- ANALYTICS_DB_PATH=/data/analytics.db
|
CORS_ORIGINS: http://localhost:3002,http://127.0.0.1:3002
|
||||||
- ADMIN_PASSWORD=${ADMIN_PASSWORD:-}
|
|
||||||
volumes:
|
volumes:
|
||||||
- router-data:/data
|
- router-data:/data
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
@ -21,5 +20,20 @@ services:
|
||||||
timeout: 10s
|
timeout: 10s
|
||||||
retries: 3
|
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:
|
volumes:
|
||||||
router-data:
|
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"
|
"client"
|
||||||
],
|
],
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18.0.0"
|
"node": "24.13.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue