diff --git a/Dockerfile.cn b/Dockerfile.cn new file mode 100644 index 0000000..0db1fb3 --- /dev/null +++ b/Dockerfile.cn @@ -0,0 +1,70 @@ +# syntax=docker.io/docker/dockerfile:1 +FROM node:22-alpine AS base + +# 全局配置淘宝镜像源 +RUN npm config set registry https://registry.npmmirror.com && \ + sed -i 's#https\?://dl-cdn.alpinelinux.org/alpine#https://mirror.nju.edu.cn/alpine#g' /etc/apk/repositories + +FROM base AS deps +RUN sed -i 's#https\?://dl-cdn.alpinelinux.org/alpine#https://mirror.nju.edu.cn/alpine#g' /etc/apk/repositories && \ + apk add --no-cache libc6-compat +WORKDIR /app + +COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* bun.lock* .npmrc* ./ + +# 统一配置所有包管理器使用淘宝源 +RUN \ + echo "开始安装依赖..." && \ + if [ -f yarn.lock ]; then \ + yarn config set registry https://registry.npmmirror.com && \ + yarn --frozen-lockfile; \ + elif [ -f package-lock.json ]; then \ + npm ci --registry=https://registry.npmmirror.com; \ + elif [ -f pnpm-lock.yaml ]; then \ + corepack enable pnpm && \ + pnpm config set registry https://registry.npmmirror.com && \ + pnpm i --frozen-lockfile; \ + elif [ -f bun.lock ]; then \ + apk add --no-cache curl bash && \ + curl -fsSL https://bun.sh/install | bash && \ + export BUN_INSTALL="$HOME/.bun" && \ + export PATH="$BUN_INSTALL/bin:$PATH" && \ + bun config set registry https://registry.npmmirror.com && \ + bun install --frozen-lockfile; \ + else echo "Lockfile not found." && exit 1; \ + fi + +FROM base AS builder +WORKDIR /app +COPY --from=deps /app/node_modules ./node_modules +COPY . . + +ENV NEXT_TELEMETRY_DISABLED=1 + +# 合并构建命令 +RUN \ + if [ -f yarn.lock ]; then yarn run build; \ + elif [ -f package-lock.json ]; then npm run build; \ + elif [ -f pnpm-lock.yaml ]; then pnpm run build; \ + elif [ -f bun.lock ]; then bun run build; \ + fi + +FROM base AS runner +WORKDIR /app + +RUN sed -i 's#https\?://dl-cdn.alpinelinux.org/alpine#https://mirror.nju.edu.cn/alpine#g' /etc/apk/repositories && \ + apk add --no-cache curl && \ + addgroup --system --gid 1001 nodejs && \ + adduser --system --uid 1001 nextjs + +ENV NODE_ENV=production +ENV NEXT_TELEMETRY_DISABLED=1 + +COPY --from=builder /app/public ./public +COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ +COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static + +USER nextjs +EXPOSE 3000 +ENV PORT=3000 HOSTNAME="0.0.0.0" +CMD ["node", "server.js"] diff --git a/bun.lock b/bun.lock index 808c4af..b68b1a8 100644 --- a/bun.lock +++ b/bun.lock @@ -16,6 +16,7 @@ "@radix-ui/react-toggle": "^1.1.2", "@radix-ui/react-tooltip": "^1.1.8", "@types/vscode": "^1.97.0", + "bun": "^1.2.4", "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", "devicons-react": "^1.4.0", @@ -198,6 +199,28 @@ "@nolyfill/is-core-module": ["@nolyfill/is-core-module@1.0.39", "https://registry.npmmirror.com/@nolyfill/is-core-module/-/is-core-module-1.0.39.tgz", {}, "sha512-nn5ozdjYQpUCZlWGuxcJY/KpxkWQs4DcbMCmKojjyrYDEAGy4Ce19NN4v5MduafTwJlbKc99UA8YhSVqq9yPZA=="], + "@oven/bun-darwin-aarch64": ["@oven/bun-darwin-aarch64@1.2.4", "", { "os": "darwin", "cpu": "arm64" }, "sha512-xBz/Q7X6AFwMg7MXtBemjjt5uB+tvEYBmi9Zbm1r8qnI2V8m/Smuhma0EARhiVfLuIAYj2EM5qjzxeAFV4TBJA=="], + + "@oven/bun-darwin-x64": ["@oven/bun-darwin-x64@1.2.4", "", { "os": "darwin", "cpu": "x64" }, "sha512-ufyty+2754QCFDhq447H39JiqabMlFRItLn1YFp+2hdpKak7KCYLGOUuHnlr1pmImKJzDHURjnvTTq1QRlUWAA=="], + + "@oven/bun-darwin-x64-baseline": ["@oven/bun-darwin-x64-baseline@1.2.4", "", { "os": "darwin", "cpu": "x64" }, "sha512-stsq8vBiYgfGunBGlf2M7ST7Ymyw3WnwrxEeJ04vkKmMEEE2LpX8Rkol6UPRvZawab9s9/scFIRgFi6hu9H4SQ=="], + + "@oven/bun-linux-aarch64": ["@oven/bun-linux-aarch64@1.2.4", "", { "os": "linux", "cpu": "arm64" }, "sha512-OhVpzme2vvLA7w8GYeJg2SQ2h2CwJQN9oYDiGeoML4EwE+DEoYHdxgaBZsQySOwZtFIr8ufpc/8iD4hssJ50qg=="], + + "@oven/bun-linux-aarch64-musl": ["@oven/bun-linux-aarch64-musl@1.2.4", "", { "os": "linux", "cpu": "none" }, "sha512-+lxWF7up9MuB1ZdGxXCH3AH3XmYtdBC6soQ38+yg3+y3iOPrAlSG+wytHEkypN/UU2mGvCuaEED3cMvejrGdDw=="], + + "@oven/bun-linux-x64": ["@oven/bun-linux-x64@1.2.4", "", { "os": "linux", "cpu": "x64" }, "sha512-oof3ii92Cz2yIOZRbVFHMHmffCutRPFITIdXLZ2/rkqVuKUe0ZdqWjHPhxJFm31AL9MlJ/dSqDbPb51SaLI7tw=="], + + "@oven/bun-linux-x64-baseline": ["@oven/bun-linux-x64-baseline@1.2.4", "", { "os": "linux", "cpu": "x64" }, "sha512-3nmDDZJH73MzhBg2sRYioj4CE8wgaz0w24OieMqj4/c44BbNr3X5RewrldsMD2cU6DtVbi52FuD5WpTw3N8nmw=="], + + "@oven/bun-linux-x64-musl": ["@oven/bun-linux-x64-musl@1.2.4", "", { "os": "linux", "cpu": "x64" }, "sha512-cLdMbK7srNoUbYSG3Tp4GYdPAO0+5mgUhdbU053GZs0DLQmQ8h1JQhALp+ZjrUWstmQe7ddcNu7l7EAu6E76XA=="], + + "@oven/bun-linux-x64-musl-baseline": ["@oven/bun-linux-x64-musl-baseline@1.2.4", "", { "os": "linux", "cpu": "x64" }, "sha512-qDsUvKCW0WUlVOt6Yx5eEzxgCbvzuSJBsu0sXtr6uGt8TnMKghmliRO5FmiMLQ0k/PUDA8vPJCtuv5k14bDi6g=="], + + "@oven/bun-windows-x64": ["@oven/bun-windows-x64@1.2.4", "", { "os": "win32", "cpu": "x64" }, "sha512-4YRJd4pdaTWEM+uawYmchOeNv874RGAFpIZQubWnN4SBf6HfcDm0OMMZcm0f0I70Wd5gbPg1+rvCRtDZWVmZog=="], + + "@oven/bun-windows-x64-baseline": ["@oven/bun-windows-x64-baseline@1.2.4", "", { "os": "win32", "cpu": "x64" }, "sha512-j/G4bnfsRAiCvpTADda40m29iSGvueIaF9Kc9hBu4jN8dTS9fEXdNNXuf8c30/z7/npxw2dhzsAn8jbc5QvD1A=="], + "@pkgjs/parseargs": ["@pkgjs/parseargs@0.11.0", "https://registry.npmmirror.com/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", {}, "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg=="], "@protobufjs/aspromise": ["@protobufjs/aspromise@1.1.2", "https://registry.npmmirror.com/@protobufjs/aspromise/-/aspromise-1.1.2.tgz", {}, "sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ=="], @@ -448,6 +471,8 @@ "buildcheck": ["buildcheck@0.0.6", "https://registry.npmmirror.com/buildcheck/-/buildcheck-0.0.6.tgz", {}, "sha512-8f9ZJCUXyT1M35Jx7MkBgmBMo3oHTTBIPLiY9xyL0pl3T5RwcPEY8cUHr5LBNfu/fk6c2T4DJZuVM/8ZZT2D2A=="], + "bun": ["bun@1.2.4", "", { "optionalDependencies": { "@oven/bun-darwin-aarch64": "1.2.4", "@oven/bun-darwin-x64": "1.2.4", "@oven/bun-darwin-x64-baseline": "1.2.4", "@oven/bun-linux-aarch64": "1.2.4", "@oven/bun-linux-aarch64-musl": "1.2.4", "@oven/bun-linux-x64": "1.2.4", "@oven/bun-linux-x64-baseline": "1.2.4", "@oven/bun-linux-x64-musl": "1.2.4", "@oven/bun-linux-x64-musl-baseline": "1.2.4", "@oven/bun-windows-x64": "1.2.4", "@oven/bun-windows-x64-baseline": "1.2.4" }, "os": [ "linux", "win32", "darwin", ], "cpu": [ "x64", "arm64", ], "bin": { "bun": "bin/bun.exe", "bunx": "bin/bun.exe" } }, "sha512-ZY0EZ/UKqheaLeAtMsfJA6jWoWvV9HAtfFaOJSmS3LrNpFKs1Sg5fZLSsczN1h3a+Dtheo4O3p3ZYWrf40kRGw=="], + "busboy": ["busboy@1.6.0", "https://registry.npmmirror.com/busboy/-/busboy-1.6.0.tgz", { "dependencies": { "streamsearch": "^1.1.0" } }, "sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA=="], "call-bind": ["call-bind@1.0.8", "https://registry.npmmirror.com/call-bind/-/call-bind-1.0.8.tgz", { "dependencies": { "call-bind-apply-helpers": "^1.0.0", "es-define-property": "^1.0.0", "get-intrinsic": "^1.2.4", "set-function-length": "^1.2.2" } }, "sha512-oKlSFMcMwpUg2ednkhQ454wfWiU/ul3CkJe/PEHcTKuiX6RpbehUiFMXu13HalGZxfUwCQzZG747YXBn1im9ww=="], diff --git a/compose.cn.yml b/compose.cn.yml new file mode 100644 index 0000000..40470e0 --- /dev/null +++ b/compose.cn.yml @@ -0,0 +1,63 @@ +services: + monaco-editor-lsp-next: + build: + context: ./ + dockerfile: Dockerfile.cn + image: monaco-editor-lsp-next:latest + container_name: monaco-editor-lsp-next + restart: always + ports: + - "3000:3000" + networks: + - monaco-editor-lsp-next + depends_on: + - lsp-c + - lsp-cpp + healthcheck: + test: [ "CMD-SHELL", "curl --fail http://localhost:3000 || exit 1" ] + interval: 10s + timeout: 5s + retries: 5 + start_period: 10s + user: root + volumes: + - /var/run/docker.sock:/var/run/docker.sock + + lsp-c: + build: + context: ./docker/lsp/clangd + dockerfile: Dockerfile.cn + image: lsp-c:latest + container_name: lsp-c + restart: always + ports: + - "4594:3000" + networks: + - monaco-editor-lsp-next + healthcheck: + test: [ "CMD-SHELL", "nc -zv localhost 3000" ] + interval: 10s + timeout: 5s + retries: 5 + + lsp-cpp: + build: + context: ./docker/lsp/clangd + dockerfile: Dockerfile.cn + image: lsp-cpp:latest + container_name: lsp-cpp + restart: always + ports: + - "4595:3000" + networks: + - monaco-editor-lsp-next + healthcheck: + test: [ "CMD-SHELL", "nc -zv localhost 3000" ] + interval: 10s + timeout: 5s + retries: 5 + +networks: + monaco-editor-lsp-next: + name: monaco-editor-lsp-next + driver: bridge diff --git a/docker/lsp/clangd/Dockerfile.cn b/docker/lsp/clangd/Dockerfile.cn new file mode 100644 index 0000000..91677af --- /dev/null +++ b/docker/lsp/clangd/Dockerfile.cn @@ -0,0 +1,31 @@ +FROM alpine:latest AS builder + +RUN sed -i 's#https\?://dl-cdn.alpinelinux.org/alpine#https://mirror.nju.edu.cn/alpine#g' /etc/apk/repositories&& \ + apk add --no-cache git npm + +# 修改为南京大学镜像源 +RUN npm config set registry https://repo.nju.edu.cn/repository/npm/ + +WORKDIR /app + +RUN git clone https://gh-proxy.com/github.com/wylieconlon/jsonrpc-ws-proxy.git + +WORKDIR /app/jsonrpc-ws-proxy + +COPY servers.yml . + +# 合并命令减少镜像层 +RUN npm install --registry=https://repo.nju.edu.cn/repository/npm/ && npm run prepare + +FROM alpine:latest + +RUN sed -i 's#https\?://dl-cdn.alpinelinux.org/alpine#https://mirror.nju.edu.cn/alpine#g' /etc/apk/repositories&& \ + apk add --no-cache build-base clang-extra-tools nodejs + +WORKDIR /app/jsonrpc-ws-proxy + +COPY --from=builder /app/jsonrpc-ws-proxy . + +EXPOSE 3000 + +CMD ["node", "dist/server.js", "--port", "3000", "--languageServers", "servers.yml"] diff --git a/package.json b/package.json index 79bd8f8..b016961 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "@radix-ui/react-toggle": "^1.1.2", "@radix-ui/react-tooltip": "^1.1.8", "@types/vscode": "^1.97.0", + "bun": "^1.2.4", "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", "devicons-react": "^1.4.0",