|
| 1 | +schemaVersion: 2.3.0 |
| 2 | +metadata: |
| 3 | + name: openvsx |
| 4 | +components: |
| 5 | + - name: tool |
| 6 | + container: |
| 7 | + image: quay.io/devfile/universal-developer-image:ubi8-latest |
| 8 | + memoryRequest: 256Mi |
| 9 | + memoryLimit: 8Gi |
| 10 | + cpuRequest: 100m |
| 11 | + cpuLimit: 2000m |
| 12 | + env: |
| 13 | + - name: OPENVSX_NAMESPACE |
| 14 | + value: openvsx |
| 15 | + volumeMounts: |
| 16 | + - name: local |
| 17 | + path: /home/user/.local/ |
| 18 | + - name: elasticsearch |
| 19 | + container: |
| 20 | + image: docker.elastic.co/elasticsearch/elasticsearch:8.7.1 |
| 21 | + memoryRequest: 256Mi |
| 22 | + memoryLimit: 2Gi |
| 23 | + cpuRequest: 100m |
| 24 | + cpuLimit: 800m |
| 25 | + endpoints: |
| 26 | + - exposure: internal |
| 27 | + name: elasticsearch |
| 28 | + protocol: tcp |
| 29 | + targetPort: 9200 |
| 30 | + - exposure: internal |
| 31 | + name: es9300 |
| 32 | + protocol: tcp |
| 33 | + targetPort: 9300 |
| 34 | + - exposure: public |
| 35 | + name: che-server |
| 36 | + targetPort: 8080 |
| 37 | + - exposure: public |
| 38 | + name: che-webui |
| 39 | + targetPort: 3000 |
| 40 | + env: |
| 41 | + - name: bootstrap.memory_lock |
| 42 | + value: 'true' |
| 43 | + - name: cluster.routing.allocation.disk.threshold_enabled |
| 44 | + value: 'false' |
| 45 | + - name: discovery.type |
| 46 | + value: single-node |
| 47 | + - name: xpack.ml.enabled |
| 48 | + value: 'false' |
| 49 | + - name: xpack.security.enabled |
| 50 | + value: 'false' |
| 51 | + - name: postgresql |
| 52 | + container: |
| 53 | + image: 'image-registry.openshift-image-registry.svc:5000/openshift/postgresql:15-el8' |
| 54 | + memoryRequest: 256Mi |
| 55 | + memoryLimit: 2Gi |
| 56 | + cpuRequest: 100m |
| 57 | + cpuLimit: '1' |
| 58 | + env: |
| 59 | + - name: POSTGRESQL_USER |
| 60 | + value: openvsx |
| 61 | + - name: POSTGRESQL_PASSWORD |
| 62 | + value: openvsx |
| 63 | + - name: POSTGRESQL_DATABASE |
| 64 | + value: openvsx |
| 65 | + - volume: |
| 66 | + ephemeral: true |
| 67 | + name: local |
| 68 | + |
| 69 | +commands: |
| 70 | + - id: build-cli |
| 71 | + exec: |
| 72 | + label: "1.1. Build OVSX CLI" |
| 73 | + component: tool |
| 74 | + workingDir: ${PROJECTS_ROOT}/openvsx/cli |
| 75 | + commandLine: | |
| 76 | + yarn install && |
| 77 | + yarn prepare |
| 78 | +
|
| 79 | + - id: build-webui |
| 80 | + exec: |
| 81 | + label: "1.2. Build UI Component" |
| 82 | + component: tool |
| 83 | + workingDir: ${PROJECTS_ROOT}/openvsx/webui |
| 84 | + commandLine: | |
| 85 | + yarn install && |
| 86 | + yarn build && |
| 87 | + yarn build:default |
| 88 | +
|
| 89 | + - id: build-server |
| 90 | + exec: |
| 91 | + label: "1.3. Build Server Component" |
| 92 | + component: tool |
| 93 | + workingDir: ${PROJECTS_ROOT}/openvsx |
| 94 | + commandLine: | |
| 95 | + server/gradlew -p server assemble downloadTestExtensions |
| 96 | +
|
| 97 | + - id: run-server |
| 98 | + exec: |
| 99 | + label: "1.4. Run OpenVSX Server" |
| 100 | + component: tool |
| 101 | + workingDir: ${PROJECTS_ROOT}/openvsx/server |
| 102 | + commandLine: | |
| 103 | + ./scripts/generate-properties.sh && |
| 104 | + sed -i 's/localhost:5432\/postgres/localhost:5432\/openvsx/g' src/dev/resources/application.yml && |
| 105 | + sed -i 's/username: gitpod/username: openvsx/g' src/dev/resources/application.yml && |
| 106 | + sed -i 's/password: gitpod/password: openvsx/g' src/dev/resources/application.yml && |
| 107 | + ./gradlew runServer |
| 108 | +
|
| 109 | + - id: run-webui |
| 110 | + exec: |
| 111 | + label: "1.5. Run OpenVSX WebUI" |
| 112 | + component: tool |
| 113 | + workingDir: ${PROJECTS_ROOT}/openvsx/webui |
| 114 | + commandLine: | |
| 115 | + yarn start:default |
| 116 | +
|
| 117 | + - id: cli-publish |
| 118 | + exec: |
| 119 | + label: "1.6. Publish extensions by OVSX CLI" |
| 120 | + component: tool |
| 121 | + workingDir: ${PROJECTS_ROOT}/openvsx |
| 122 | + commandLine: | |
| 123 | + nvm use v${NODEJS_20_VERSION} |
| 124 | + export OVSX_REGISTRY_URL=http://localhost:8080 |
| 125 | + export OVSX_PAT=super_token |
| 126 | + export PUBLISHERS="DotJoshJohnson eamodio felixfbecker formulahendry HookyQR ms-azuretools ms-mssql ms-python ms-vscode octref redhat ritwickdey sburg vscode vscodevim Wscats" |
| 127 | + for pub in $PUBLISHERS; do cli/lib/ovsx create-namespace $pub; done |
| 128 | + find server/build/test-extensions-builtin -name '*.vsix' -exec cli/lib/ovsx publish '{}' \; |
| 129 | + find server/build/test-extensions -name '*.vsix' -exec cli/lib/ovsx publish '{}' \; |
| 130 | +
|
| 131 | +# Commands to deploy OpenVSX to OpenShift |
| 132 | + - id: build-openvsx-image |
| 133 | + exec: |
| 134 | + label: "2.1. Build and Publish OpenVSX Image" |
| 135 | + component: tool |
| 136 | + workingDir: ${PROJECTS_ROOT}/openvsx/openshift |
| 137 | + commandLine: | |
| 138 | + read -p "Please enter the value for OPENVSX_VERSION (default: v0.18.0): " OPENVSX_VERSION |
| 139 | + OPENVSX_VERSION=${OPENVSX_VERSION:-v0.18.0} |
| 140 | + export OPENVSX_VERSION |
| 141 | + echo "OPENVSX_VERSION is set to $OPENVSX_VERSION" |
| 142 | + podman build -t "openvsx:$OPENVSX_VERSION" --build-arg "OPENVSX_VERSION=$OPENVSX_VERSION" -f openvsx.Dockerfile .&& |
| 143 | + oc new-project $OPENVSX_NAMESPACE |
| 144 | + export IMAGE=image-registry.openshift-image-registry.svc:5000/$OPENVSX_NAMESPACE/openvsx && |
| 145 | + podman tag openvsx:$OPENVSX_VERSION ${IMAGE} && |
| 146 | + podman login --tls-verify=false -u $(oc whoami | tr -d :) -p $(oc whoami -t) image-registry.openshift-image-registry.svc:5000 && |
| 147 | + podman push --tls-verify=false "${IMAGE}" |
| 148 | +
|
| 149 | + - id: build-ovsx-cli-image |
| 150 | + exec: |
| 151 | + label: "2.2. Build and Publish OpenVSX CLI Image" |
| 152 | + component: tool |
| 153 | + workingDir: ${PROJECTS_ROOT}/openvsx/openshift |
| 154 | + commandLine: | |
| 155 | + podman build -t "openvsx-cli" -f cli.Dockerfile .&& |
| 156 | + export IMAGE=image-registry.openshift-image-registry.svc:5000/$OPENVSX_NAMESPACE/openvsx-cli && |
| 157 | + podman tag openvsx-cli ${IMAGE} && |
| 158 | + podman login --tls-verify=false -u $(oc whoami | tr -d :) -p $(oc whoami -t) image-registry.openshift-image-registry.svc:5000 && |
| 159 | + podman push --tls-verify=false "${IMAGE}" |
| 160 | +
|
| 161 | + - id: deploy-openvsx |
| 162 | + exec: |
| 163 | + label: "2.3. Deploy OpenVSX" |
| 164 | + component: tool |
| 165 | + workingDir: ${PROJECTS_ROOT}/openvsx/openshift |
| 166 | + commandLine: | |
| 167 | + oc process -f openvsx-deployment.yml \ |
| 168 | + -p OPENVSX_SERVER_IMAGE=image-registry.openshift-image-registry.svc:5000/$OPENVSX_NAMESPACE/openvsx \ |
| 169 | + -p OPENVSX_CLI_IMAGE=image-registry.openshift-image-registry.svc:5000/$OPENVSX_NAMESPACE/openvsx-cli \ |
| 170 | + | oc apply -f - |
| 171 | +
|
| 172 | + - id: add-openvsx-user-with-pat |
| 173 | + exec: |
| 174 | + label: "2.4. Add OpenVSX user with PAT to the DB" |
| 175 | + component: tool |
| 176 | + commandLine: | |
| 177 | + read -p "Please enter OpenVSX user name (default: eclipse-che): " OPENVSX_USER_NAME |
| 178 | + OPENVSX_USER_NAME=${OPENVSX_USER_NAME:-eclipse-che} |
| 179 | + export OPENVSX_USER_NAME |
| 180 | + echo "OPENVSX_USER_NAME is set to $OPENVSX_USER_NAME" |
| 181 | + read -p "Please enter the value for OpenVSX user PAT (default: eclipse_che_token): " OPENVSX_USER_PAT |
| 182 | + OPENVSX_USER_PAT=${OPENVSX_USER_PAT:-eclipse_che_token} |
| 183 | + export OPENVSX_USER_PAT |
| 184 | + echo "OPENVSX_USER_PAT is set to $OPENVSX_USER_PAT" |
| 185 | + export POSTGRESQL_POD_NAME=$(kubectl get pods -n "$OPENVSX_NAMESPACE" -o jsonpath="{.items[*].metadata.name}" | tr ' ' '\n' | grep ^postgresql) && |
| 186 | + kubectl exec -n "${OPENVSX_NAMESPACE}" "${POSTGRESQL_POD_NAME}" -- bash -c "psql -d openvsx -c \"INSERT INTO user_data (id, login_name, role) VALUES (1001, '$OPENVSX_USER_NAME', 'privileged');\"" && |
| 187 | + kubectl exec -n "${OPENVSX_NAMESPACE}" "${POSTGRESQL_POD_NAME}" -- bash -c "psql -d openvsx -c \"INSERT INTO personal_access_token (id, user_data, value, active, created_timestamp, accessed_timestamp, description) VALUES (1001, 1001, '$OPENVSX_USER_PAT', true, current_timestamp, current_timestamp, 'extensions publisher');\"" |
| 188 | +
|
| 189 | + - id: enable-internal-openvsx |
| 190 | + exec: |
| 191 | + label: "2.5. Configure Che to use the internal OpenVSX registry" |
| 192 | + component: tool |
| 193 | + workingDir: ${PROJECTS_ROOT}/openvsx/openshift |
| 194 | + commandLine: | |
| 195 | + export CHECLUSTER_NAME="$(kubectl get checluster --all-namespaces -o json | jq -r '.items[0].metadata.name')" && |
| 196 | + export CHECLUSTER_NAMESPACE="$(kubectl get checluster --all-namespaces -o json | jq -r '.items[0].metadata.namespace')" && |
| 197 | + export OPENVSX_ROUTE_URL="$(oc get route internal -n "$OPENVSX_NAMESPACE" -o jsonpath='{.spec.host}')" && |
| 198 | + export PATCH='{"spec":{"components":{"pluginRegistry":{"openVSXURL":"https://'"$OPENVSX_ROUTE_URL"'"}}}}' && |
| 199 | + kubectl patch checluster "${CHECLUSTER_NAME}" --type=merge --patch "${PATCH}" -n "${CHECLUSTER_NAMESPACE}" |
| 200 | +
|
| 201 | + - id: publish-extension |
| 202 | + exec: |
| 203 | + label: "2.6. Publish VS Code Extension to the internal OpenVSX" |
| 204 | + component: tool |
| 205 | + commandLine: | |
| 206 | + read -p "Please enter extension's namespace name: " EXTENSION_NAMESPACE_NAME |
| 207 | + EXTENSION_NAMESPACE_NAME=${EXTENSION_NAMESPACE_NAME} |
| 208 | + export EXTENSION_NAMESPACE_NAME |
| 209 | + echo "EXTENSION_NAMESPACE_NAME is set to $EXTENSION_NAMESPACE_NAME" |
| 210 | + read -p "Please enter extension's download URL: " EXTENSION_DOWNLOAD_URL |
| 211 | + EXTENSION_DOWNLOAD_URL=${EXTENSION_DOWNLOAD_URL} |
| 212 | + export EXTENSION_DOWNLOAD_URL |
| 213 | + echo "EXTENSION_DOWNLOAD_URL is set to $EXTENSION_DOWNLOAD_URL" |
| 214 | + export OVSX_POD_NAME=$(kubectl get pods -n "$OPENVSX_NAMESPACE" -o jsonpath="{.items[*].metadata.name}" | tr ' ' '\n' | grep ^ovsx-cli) && |
| 215 | + kubectl exec -n "${OPENVSX_NAMESPACE}" "${OVSX_POD_NAME}" -- bash -c "wget -O /tmp/extension.vsix '$EXTENSION_DOWNLOAD_URL' " && |
| 216 | + kubectl exec -n "${OPENVSX_NAMESPACE}" "${OVSX_POD_NAME}" -- bash -c "ovsx create-namespace '$EXTENSION_NAMESPACE_NAME'" || true && |
| 217 | + kubectl exec -n "${OPENVSX_NAMESPACE}" "${OVSX_POD_NAME}" -- bash -c "ovsx publish /tmp/extension.vsix" && |
| 218 | + kubectl exec -n "${OPENVSX_NAMESPACE}" "${OVSX_POD_NAME}" -- bash -c "rm /tmp/extension.vsix" |
0 commit comments