如何解决如何将 Visual Studio Code 扩展重新打包成 Che-Theia 插件及其自己的依赖项
我正在尝试将 Visual Studio Code 扩展作为 Che-theia 插件重新打包到 Eclipse Che 中。 plug-in 从 Ansible 文件中提取源代码指标,如下所示:
它通过执行一个用 Python 编写的工具的命令行来实现,即 ansiblemetrics,它必须安装在用户的环境中。 因此,我无法将该依赖项添加到 VSC 扩展的 package.json。相反,用户必须将其安装在 Eclipse Che 工作区中。不过,我希望 Eclipse Che 用户在使用扩展时不需要安装依赖项。容器看起来不错。
我有以下 Eclipse Che DevFile
Eclipse Che DevFile
apiVersion: 1.0.0
Metadata:
name: python-bd3zh
attributes:
persistVolumes: 'false'
projects:
- name: python-hello-world
source:
location: 'https://github.com/che-samples/python-hello-world.git'
type: git
branch: master
components:
- type: chePlugin
reference: 'https://raw.githubusercontent.com/radon-h2020/radon-plugin-registry/master/radon/radon-defect-predictor/latest/Meta.yaml'
alias: radon-dpt
Eclipse docs 表示“要将 VS Code 扩展重新打包为 Che-theia 插件及其自己的一组依赖项,请将依赖项打包到容器中。”
可以在 spec
keyword:
spec:
containers:
- image:
memoryLimit:
memoryRequest:
cpuLimit:
cpuRequest:
Meta.yaml
apiVersion: v2
publisher: radon
name: radon-defect-predictor
version: 0.0.5
type: VS Code extension
displayName: RADON-h2020 Defect Predictor
title: A Defect Predictor for Infrastructure-as-Code by RADON
description: A customized extension for analyzing the defectiveness of IaC blueprints
icon: https://www.eclipse.org/che/images/logo-eclipseche.svg
repository: https://github.com/radon-h2020/radon-defect-prediction-plugin
category: Other
spec:
containers:
- image: stefadp/radon-dpt-plugin
extensions:
- https://raw.githubusercontent.com/radon-h2020/radon-defect-prediction-plugin/master/radon-defect-predictor-0.0.5.vsix
其中映像 stefadp/radon-dpt-plugin 是基于以下 Dockerfile 构建的:
Dockerfile
FROM ubuntu:latest
RUN apt-get update \
&& apt-get install -y python3-pip python3-dev \
&& cd /usr/local/bin \
&& ln -s /usr/bin/python3 python \
&& pip3 install --upgrade pip
RUN pip3 install ansiblemetrics
但是,当我在 Eclipse Che 中运行工作区时,我观察到以下错误:
pulling image "quay.io/eclipse/che-plugin-Metadata-broker:v3.4.0"
Successfully pulled image "quay.io/eclipse/che-plugin-Metadata-broker:v3.4.0"
Created container
Started container
Starting plugin Metadata broker
List of plugins and editors to install
- radon/radon-defect-predictor/0.0.6 - A customized extension for analyzing the defectiveness of IaC blueprints
- eclipse/che-workspace-telemetry-woopra-plugin/0.0.1 - Telemetry plugin to send information to Woopra
- eclipse/che-machine-exec-plugin/7.24.2 - Che Plug-in with che-machine-exec service to provide creation terminal or tasks for Eclipse Che workspace containers.
- eclipse/che-theia/7.24.2 - Eclipse theia
All plugin Metadata has been successfully processed
pulling image "quay.io/eclipse/che-theia-endpoint-runtime-binary:7.24.2"
Successfully pulled image "quay.io/eclipse/che-theia-endpoint-runtime-binary:7.24.2"
Created container
Started container
pulling image "quay.io/eclipse/che-plugin-artifacts-broker:v3.4.0"
Successfully pulled image "quay.io/eclipse/che-plugin-artifacts-broker:v3.4.0"
Created container
Started container
Starting plugin artifacts broker
Cleaning /plugins dir
Processing plugin radon/radon-defect-predictor/0.0.6
Installing plugin extension 1/1
Downloading plugin from https://raw.githubusercontent.com/radon-h2020/radon-plugin-registry/master/radon/radon-defect-predictor/0.0.6/radon-defect-predictor-0.0.6.vsix
Saving log of installed plugins
All plugin artifacts have been successfully downloaded
pulling image "quay.io/eclipse/che-jwtproxy:0.10.0"
Successfully pulled image "quay.io/eclipse/che-jwtproxy:0.10.0"
Created container
Started container
pulling image "stefadp/radon-dpt-plugin"
Successfully pulled image "stefadp/radon-dpt-plugin"
Created container
Started container
pulling image "quay.io/eclipse/che-workspace-telemetry-woopra-plugin:latest"
Successfully pulled image "quay.io/eclipse/che-workspace-telemetry-woopra-plugin:latest"
Created container
Started container
pulling image "quay.io/eclipse/che-machine-exec:7.24.2"
Successfully pulled image "quay.io/eclipse/che-machine-exec:7.24.2"
Created container
Started container
pulling image "quay.io/eclipse/che-theia:7.24.2"
Error: Failed to run the workspace: "The following containers have terminated:
nt0: reason = 'Completed',exit code = 0,message = 'null'"
你有什么提示吗?
解决方法
你必须自定义你的 docker 镜像才能在 sidecar 容器中工作。例如,您可以查看已在 Che 中的 sidecars 中使用的图像:https://github.com/eclipse/che-plugin-registry/blob/master/CONTRIBUTE.md#sidecars
尝试创建下一个结构:
radon
etc
entrypoint.sh
Dockerfile
entrypoint.sh
的内容是:
#!/bin/sh
set -e
set -x
USER_ID=$(id -u)
export USER_ID
GROUP_ID=$(id -g)
export GROUP_ID
if ! whoami >/dev/null 2>&1; then
echo "${USER_NAME:-user}:x:${USER_ID}:0:${USER_NAME:-user} user:${HOME}:/bin/sh" >> /etc/passwd
fi
# Grant access to projects volume in case of non root user with sudo rights
if [ "${USER_ID}" -ne 0 ] && command -v sudo >/dev/null 2>&1 && sudo -n true > /dev/null 2>&1; then
sudo chown "${USER_ID}:${GROUP_ID}" /projects
fi
exec "$@"
而 Dockerfile
是:
FROM ubuntu:latest
ENV HOME=/home/theia
RUN mkdir /projects ${HOME} && \
# Change permissions to let any arbitrary user
for f in "${HOME}" "/etc/passwd" "/projects"; do \
echo "Changing permissions on ${f}" && chgrp -R 0 ${f} && \
chmod -R g+rwX ${f}; \
done
RUN apt-get update \
&& apt-get install -y python3-pip python3-dev \
&& cd /usr/local/bin \
&& ln -s /usr/bin/python3 python \
&& pip3 install --upgrade pip
RUN pip3 install ansiblemetrics
ADD etc/entrypoint.sh /entrypoint.sh
ENTRYPOINT [ "/entrypoint.sh" ]
CMD ${PLUGIN_REMOTE_ENDPOINT_EXECUTABLE}
然后构建此 Dockerfile 并在您的插件中使用它 meta.yaml
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。