openvsx搭建私有插件仓库

https://github.com/eclipse/openvsx/issues/703

  1. 构建docker镜像,openvsx-server 整合 前后端+ cli
    基于 https://github.com/eclipse/openvsx.git v0.27.0

    ARG OPENVSX_VERSION

    Builder image to compile the website

    FROM ubuntu AS builder

    WORKDIR /workdir

    See https://github.com/nodesource/distributions/blob/main/README.md#debinstall

    RUN apt-get update
    && apt-get install --no-install-recommends -y
    bash
    ca-certificates
    git
    curl
    && apt-get clean
    && rm -rf /var/lib/apt/lists/*
    && curl -sSL https://deb.nodesource.com/setup_20.x | bash -
    && apt-get install -y nodejs
    && apt-get clean
    && corepack enable
    && corepack prepare yarn@stable --activate

    ARG OPENVSX_VERSION
    ENV VERSION=v0.27.0

    RUN HTTPS_PROXY=150.223.210.7:7890 git clone --branch ${VERSION} --depth 1 https://github.com/eclipse/openvsx.git /workdir
    COPY ./configuration /workdir/configuration

    RUN /usr/bin/yarn --cwd webui
    && /usr/bin/yarn --cwd webui build
    && /usr/bin/yarn --cwd webui build:default

    FROM node:20 AS cli_builder
    RUN npm config set registry https://registry.npmmirror.com
    RUN npm config get registry
    RUN npm install -g ovsx --registry=https://registry.npmmirror.com

    Main image derived from openvsx-server

    FROM ghcr.io/eclipse/openvsx-server:v0.27.0
    ARG OPENVSX_VERSION

    COPY --from=builder --chown=openvsx:openvsx /workdir/webui/static/ BOOT-INF/classes/static/
    COPY --from=builder --chown=openvsx:openvsx /workdir/configuration/application.yml config/

    COPY --from=cli_builder /usr/local/lib/node_modules/ /usr/local/lib/node_modules/
    COPY --from=cli_builder /usr/local/bin/ /usr/local/bin/

    RUN sed -i "s/<OPENVSX_VERSION>/v0.27.0/g" config/application.yml

配置文件 application.yml

复制代码
logging:
  pattern:
    level: '%5p [${spring.application.name:},%X{traceId:-},%X{spanId:-}]'

server:
  port: 8080
  jetty:
    threads:
      max-queue-capacity: 100

spring:
  application:
    name: openvsx-server
  autoconfigure:
    # don't send traces to Zipkin in development
    exclude: org.springframework.boot.actuate.autoconfigure.tracing.zipkin.ZipkinAutoConfiguration
  profiles:
    include: ovsx
  cache:
    jcache:
      config: classpath:ehcache.xml
  datasource:
    url: jdbc:postgresql://postgres:5432/openvsx
    username: openvsx
    password: openvsx
  flyway:
    baseline-on-migrate: true
    baseline-version: 0.1.0
    baseline-description: JobRunr tables
  jpa:
    open-in-view: false
    properties:
      hibernate:
        dialect: org.hibernate.dialect.PostgreSQLDialect
    hibernate:
      ddl-auto: none
  session:
    store-type: jdbc
    jdbc:
      initialize-schema: never

  security:
      oauth2:
        client:
          registration:
            github:
              client-id: none
              client-secret: none

management:
  health:
    probes:
      enabled: true
  endpoints:
    web:
      exposure:
        include:
          - health
          - metrics
          - prometheus
  metrics:
    distribution:
      percentiles-histogram:
        http:
          server:
            requests: true
          client:
            requests: true

springdoc:
  model-and-view-allowed: true
  swagger-ui:
    path: /swagger-ui
    docExpansion: list
    operationsSorter: alpha
    supportedSubmitMethods:
      - get

org:
  jobrunr:
    job-scheduler:
      enabled: true
    background-job-server:
      enabled: true
      worker-count: 2
    dashboard:
      enabled: false
    database:
      type: sql
    miscellaneous:
      allow-anonymous-data-usage: false

bucket4j:
  enabled: true
  filters:
    - cache-name: buckets
      url: '/api/-/(namespace/create|publish)'
      http-response-headers:
        Access-Control-Allow-Origin: '*'
        Access-Control-Expose-Headers: X-Rate-Limit-Retry-After-Seconds, X-Rate-Limit-Remaining
      rate-limits:
        - cache-key: getParameter("token")
          bandwidths:
            - capacity: 15
              time: 1
              unit: seconds
    - cache-name: buckets
      url: '/vscode/asset/.*/.*/.*/Microsoft.VisualStudio.Services.Icons.Default'
      http-response-headers:
        Access-Control-Allow-Origin: '*'
        Access-Control-Expose-Headers: X-Rate-Limit-Retry-After-Seconds, X-Rate-Limit-Remaining
      rate-limits:
        - cache-key: getRemoteAddr()
          bandwidths:
            - capacity: 75
              time: 1
              unit: seconds
    - cache-name: buckets
      url: '/vscode/(?!asset/.*/.*/.*/Microsoft.VisualStudio.Services.Icons.Default).*|/api/(?!(.*/.*/review(/delete)?)|(-/(namespace/create|publish))).*'
      http-response-headers:
        Access-Control-Allow-Origin: '*'
        Access-Control-Expose-Headers: X-Rate-Limit-Retry-After-Seconds, X-Rate-Limit-Remaining
      rate-limits:
        - cache-key: getRemoteAddr()
          bandwidths:
            - capacity: 15
              time: 1
              unit: seconds

ovsx:
  databasesearch:
    enabled: false
  elasticsearch:
    clear-on-start: true
    host: 'elasticsearch:9200'
  extension-control:
    update-on-start: true
  integrity:
    key-pair: create # create, renew, delete, 'undefined'
  registry:
    version: v0.27.0
  storage:
    local:
      directory: /home/ovsx
构建命令
docker build -t "openvsx:v0.27.0" .
2. Docker-compose 启动
services:
  postgres:
    image: postgres:latest
    environment:
      - POSTGRES_USER=openvsx
      - POSTGRES_PASSWORD=openvsx
    logging:
      options:
        max-size: 10m
        max-file: "3"
    ports:
      - '5432:5432'
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U openvsx"]
      interval: 10s
      timeout: 10s
      retries: 6

  elasticsearch:
    image: elasticsearch:8.6.2
    environment:
      - xpack.security.enabled=false
      - xpack.ml.enabled=false
      - discovery.type=single-node
      - bootstrap.memory_lock=true
      - cluster.routing.allocation.disk.threshold_enabled=false
    ports:
      - 9200:9200
      - 9300:9300
    healthcheck:
      test: curl -s http://elasticsearch:9200 >/dev/null || exit 1
      interval: 10s
      timeout: 5s
      retries: 50
      start_period: 5s
  server:
    image: openvsx:v0.27.0
    ports:
      - "8080:8080"
      - "3000:3000"
    healthcheck:
      test: ["CMD-SHELL", "curl http://openvsx-server:8080"]
      interval: 10s
      timeout: 10s
      retries: 6
    volumes:
      - ./configuration/application.yml:/home/openvsx/server/config/application.yml
      - ./vsix:/home/vsix
      - ./ovsx_storage:/home/ovsx
    depends_on:
      elasticsearch:
        condition: service_healthy
      postgres:
        condition: service_healthy
  1. 初始化和发布插件

    docker exec -it vsx-registry-postgres-1 bash
    psql -hlocalhost -Uopenvsx -p5432

    INSERT INTO user_data(id, login_name, role) VALUES(1001, 'super_user', 'admin');
    INSERT INTO personal_access_token(id, active, description, value, user_data) VALUES(1002, TRUE, 'For publishing test extensions', 'super_token', 1001);

    select * from extensions;
    select * from file_resources;

    wget https://open-vsx.org/api/robole/file-bunny/1.3.6/file/robole.file-bunny-1.3.6.vsix

    docker exec -it vsx-registry-server-1 bash
    cd /home/vsix
    ovsx -p super_token -r http://server:8080/ create-namespace robole
    ovsx -p super_token -r http://server:8080/ publish *.vsix

举例

复制代码
openvsx@6046657205fa:~/server$ ovsx -p super_token -r http://server:8080/ create-namespace robole
🚀  Created namespace robole
openvsx@6046657205fa:/home/vsix$ ovsx -p super_token -r http://server:8080/ publish ./*.vsix
🚀  Published robole.file-bunny v1.3.6
  1. Vscode 插件配置
    下载插件,配置本地仓库

    https://marketplace.visualstudio.com/items?itemName=NikolajFogh.private-extension-marketplace

  2. Vscode remote 离线安装

    wget https://update.code.visualstudio.com/commit:704ed70d4fd1c6bd6342c436f1ede30d1cf4710/server-linux-x64/stable
    commit_id=704ed70d4fd1c6bd6342c436f1ede30d1cf4710
    mkdir -p ~/.vscode-server/bin/${commit_id}
    tar -xvzf vscode-server-linux-x64.tar.gz --strip-components 1

  3. 版本要求:

    1. 低版本vscode 非 insider 版本不支持 remote-ssh

    2. 高版本 vscode 对 linux 有要求, 比如要求glibc >2.28, libstdc++ > 3.4.25 详见 https://code.visualstudio.com/docs/remote/linux#_remote-host-container-wsl-linux-prerequisites

    3. 如下是 kylin v10 升级 libstdc++ 的思路

    4. 修改yum 添加,gcc-updates 源, 从mirror 发现 tlinux 2.4 带的 libstdc++ 8.5.0 可用

    5. yum update libstdc++, 并解决依赖问题,如有

    6. strings /usr/lib64/libstdc++.6 |grep GLIBCXX