diff --git a/.devcontainer/external/devcontainer.json b/.devcontainer/external/devcontainer.json index dc0e2f7..4a0dd3c 100644 --- a/.devcontainer/external/devcontainer.json +++ b/.devcontainer/external/devcontainer.json @@ -27,5 +27,9 @@ "SPRING_PROFILES_ACTIVE": "dev", "K12STUDY_DEV_MODE": "external" }, - "postCreateCommand": "cd /workspaces/K12study" + + "remoteUser": "codespace", + "updateRemoteUserUID": true, + + "postCreateCommand": "sudo chown -R codespace:codespace /pnpm-store /workspaces/K12study/frontend/node_modules" } diff --git a/.devcontainer/external/docker-compose.yml b/.devcontainer/external/docker-compose.yml index e91862a..bc9e068 100644 --- a/.devcontainer/external/docker-compose.yml +++ b/.devcontainer/external/docker-compose.yml @@ -3,9 +3,17 @@ services: image: mcr.microsoft.com/devcontainers/universal:2 volumes: - ../../:/workspaces/K12study:cached + - frontend-node-modules:/workspaces/K12study/frontend/node_modules + - pnpm-store:/pnpm-store working_dir: /workspaces/K12study command: sleep infinity + user: 1000:1000 # 👈 强制权限,最关键 environment: + NPM_CONFIG_USER: 1000 + PNPM_HOME: /pnpm-store + PNPM_STORE_DIR: /pnpm-store + + # 你原来的所有环境变量... K12STUDY_DB_HOST: ${K12STUDY_DB_HOST:-host.docker.internal} K12STUDY_DB_PORT: ${K12STUDY_DB_PORT:-5432} K12STUDY_DB_NAME: ${K12STUDY_DB_NAME:-k12study} @@ -30,3 +38,7 @@ services: PYTHONUNBUFFERED: "1" extra_hosts: - "host.docker.internal:host-gateway" + +volumes: + frontend-node-modules: + pnpm-store: \ No newline at end of file diff --git a/.devcontainer/internal/devcontainer.json b/.devcontainer/internal/devcontainer.json index 61dad36..c8202ee 100644 --- a/.devcontainer/internal/devcontainer.json +++ b/.devcontainer/internal/devcontainer.json @@ -39,5 +39,5 @@ "SPRING_PROFILES_ACTIVE": "dev", "K12STUDY_DEV_MODE": "internal" }, - "postCreateCommand": "cd /workspaces/K12study/frontend && pnpm install" + "postCreateCommand": "sudo chown -R codespace:codespace /pnpm-store /workspaces/K12study/frontend/node_modules && cd /workspaces/K12study/frontend && pnpm install" } diff --git a/.devcontainer/internal/docker-compose.yml b/.devcontainer/internal/docker-compose.yml index 8de14a7..e0574f6 100644 --- a/.devcontainer/internal/docker-compose.yml +++ b/.devcontainer/internal/docker-compose.yml @@ -3,6 +3,8 @@ services: image: mcr.microsoft.com/devcontainers/universal:2 volumes: - ../../:/workspaces/K12study:cached + - frontend-node-modules:/workspaces/K12study/frontend/node_modules + - pnpm-store:/pnpm-store working_dir: /workspaces/K12study command: sleep infinity environment: @@ -26,6 +28,7 @@ services: K12STUDY_VECTOR_PORT: 19530 K12STUDY_VECTOR_HTTP_PORT: 9091 PYTHONUNBUFFERED: "1" + PNPM_STORE_DIR: /pnpm-store depends_on: - postgres - redis @@ -151,6 +154,8 @@ services: - milvus-dev-data:/var/lib/milvus volumes: + frontend-node-modules: + pnpm-store: postgres-dev-data: redis-dev-data: nacos-dev-logs: