将程序转换为 docker 容器

Converting a program into a docker container

我正在尝试转换这个程序:

DownloadJetAdvice Edge

完整安装指南可见here

从安装到 linux 机器,到 Docker 容器。

我需要多个 运行ning 实例,我在业余时间一直在使用 Docker,现在终于可以在我的工作中使用了!

当我构建它时,我已经完成了 docker 文件(我认为),它下载并安装了它需要的东西,并且构建完成没有问题。

但是,我无法将 JetAdvice 程序/服务获取到 运行! 我读过,如果我想在一个容器中 运行 多个东西,我应该使用 supervisor,并且由于 JetEdge 程序有 3 个 运行ning 服务,我正在使用它。

这是我的docker文件:

FROM ubuntu

MAINTAINER me

EXPOSE 33322
COPY startup.sh /opt/scripts/startup.sh
RUN apt-get update && \
    apt-get install -y apt-utils wget libunwind8 icu-devtools supervisor 
RUN mkdir -p -- /var/log/supervisor /opt/print/download /opt/print/edgeinstaller /opt/scripts

RUN wget https://app.jetadvice.com/install/edge/jetadvice-edge-linux-x64.tar -P /opt/print/download && \
    tar -xvf /opt/print/download/jetadvice-edge-linux-x64.tar -C /opt/print/edgeinstaller

RUN chmod +x /opt/print/edgeinstaller/Installer && \
    /opt/print/edgeinstaller/Installer install

RUN chmod +x /usr/bin/JetAdvice/Edge/Edge && \
    chmod +x /usr/bin/JetAdvice/Updater/Updater && \
    chmod +x /usr/bin/JetAdvice/EdgeUI/EdgeUi && \
    chmod +x /opt/scripts/startup.sh

COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf

CMD ["/opt/scripts/startup.sh"]

这是我的supervisord.conf

[supervisord]
nodaemon=true
user=root
logfile=/var/log/supervisor/supervisord.log
pidfile=/var/run/supervisord.pid

[program:JetAdvice-Edge]
command=/usr/bin/JetAdvice/Edge/Edge

[program:JetAdvice-Updater]
command=/usr/bin/JetAdvice/Updater/Updater

[program:JetAdvice-Edge-UI]
command=/usr/bin/JetAdvice/EdgeUI/EdgeUi

和 startup.sh 脚本:

#!/bin/sh
#somethingvariblehere
/usr/bin/supervisord

我尝试了 运行 JetAdvice 的许多方法,但我无法将程序安装到 运行。

有关信息,这是 JedAdvice-Edge.service 文件之一:

Description=JetAdvice Edge connector service
Wants=network.target
After=syslog.target network-online.target

[Service]
Type = simple
ExecStart=/usr/bin/JetAdvice/Edge/Edge
Restart=on-failure
RestartSec=10
KillMode=process

[Install]
WantedBy=multi-user.target

如果我登录我的 docker 容器并尝试 运行 服务,我会得到这个错误

root@6727e8f42044:/# service JetAdvice-Updater start
JetAdvice-Updater: unrecognized service

如果我尝试直接 运行 程序,我会得到:

root@6727e8f42044:/# /usr/bin/JetAdvice/Edge/Edge
bash: /usr/bin/JetAdvice/Edge/Edge: Permission denied
root@6727e8f42044:/# ./usr/bin/JetAdvice/Edge/Edge
bash: ./usr/bin/JetAdvice/Edge/Edge: Permission denied

我尝试在 /usr/bin/JetAdvice/Edge/Edge 上执行 chmod +x,然后程序似乎 运行ning 了 3 秒,然后什么也没有发生。

root@6727e8f42044:/# chmod +x /usr/bin/JetAdvice/Edge/Edge
root@6727e8f42044:/# /usr/bin/JetAdvice/Edge/Edge
root@6727e8f42044:/#

我什至不接近 linux 专家,但我无法想象我正在尝试做的事情无法完成。 那么我做错了什么,下一步是什么?

来自 JetEdge 团队的工作 install.json 文件

{
  "InstallConfig": {
    "ApiClient": {
      "SignIn": {
        "InstallKey": "prettykeyhere",
        "DcaInstanceID": "prettyidhere"
      },
      "HttpLogging": {
        "MaxSize": 10240,
        "LogHttp": false
      },
      "Proxy": {
        "Address": "",
        "Port": 8080,
        "AutoDetect": true
      }
    },
    "ApiEndpoint": {
      "LoginBaseAddress": "https://auth.eu.edge-api.com",
      "BaseAddress": "https://dr.eu.edge-api.com",
      "ConfigBaseAddress": "https://config.eu.edge-api.com",
      "StayAliveBaseAddress": "https://p.eu.edge-api.com",
      "UpdateBaseAddress": "https://upd.eu.edge-api.com",
      "UiApiBaseAddress": "https://ui.eu.edge-api.com",
      "RangesBaseAddress": "https://ranges.eu.edge-api.com",
      "LoggerBaseAddress": "https://log.eu.edge-api.com",
      "StatusBaseAddress": "https://status.eu.edge-api.com"
    },
    "Installs": [
      {
        "Product": 1,
        "Folder": "C:\Program Files (x86)\JetAdvice\Updater",
        "ServiceName": "JetAdvice-Updater",
        "ServiceExe": "Updater.dll",
        "Version": "0.4.18.0",
        "BuildRID": "win-x86",
        "Oem": 0
      },
      {
        "Product": 10,
        "Folder": "C:\Program Files (x86)\JetAdvice\Edge",
        "ServiceName": "JetAdvice-Edge",
        "ServiceExe": "Edge.dll",
        "Version": "0.4.24.0",
        "BuildRID": "win-x86",
        "Oem": 0
      },
      {
        "Product": 20,
        "Folder": "C:\Program Files (x86)\JetAdvice\EdgeUI",
        "ServiceName": "JetAdvice-Edge-UI",
        "ServiceExe": "EdgeUi.dll",
        "Version": "0.4.1.0",
        "BuildRID": "win-x86",
        "Oem": 0
      }
    ]
  }
}

我为测试生成的密钥是: 4809b732-eb36-413f-8993-bd8d1f2e2942

编辑,我更新了 docker 文件,并将 startup.sh 脚本添加到 OP。

我稍微修改了你的 Dockerfile。

FROM ubuntu:20.04

EXPOSE 33322

RUN apt-get update && \
    apt-get install -y apt-utils wget libunwind8 icu-devtools supervisor 

#RUN apt-get install -y systemctl
#RUN apt-get install -y systemd

RUN mkdir -p -- /var/log/supervisor /opt/print/download /opt/print/edgeinstaller

RUN wget https://app.jetadvice.com/install/edge/jetadvice-edge-linux-x64.tar -P /opt/print/download && \
    tar -xvf /opt/print/download/jetadvice-edge-linux-x64.tar -C /opt/print/edgeinstaller && \
    chmod +x /opt/print/edgeinstaller/Installer && \
    /opt/print/edgeinstaller/Installer install
    
RUN chmod +x /usr/bin/JetAdvice/Edge/Edge
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf

CMD ["/usr/bin/supervisord"]

我添加了这一行 RUN chmod +x /usr/bin/JetAdvice/Edge/Edge 用于将 +x 添加到可执行文件。

现在,当我启动容器时出现错误,它停止了 supervisord。 在 /usr/share/JetAdvice/Edge/LogFiles 下,您可以找到 JetAdvice Edge 记录此错误

install.json - Install key is missing. (Parameter 'InstallKey')

at EF.JA.Edge.Service.Windows.Program.<>c.b__2_3(HostBuilderContext hostContext, IServiceCollection services) at Microsoft.Extensions.Hosting.HostBuilder.CreateServiceProvider() at Microsoft.Extensions.Hosting.HostBuilder.Build() at EF.JA.Edge.Service.Windows.Program.Main(String[] args)

我在/usr/share/JetAdvice/Edge/Config/Shared下找到了install.json文件,里面有InstallKeyjson字段

{
  "InstallConfig": {
    "ApiClient": {
      "SignIn": {
        "InstallKey": "",
        "DcaInstanceID": "e5860224-12a6-429e-b931-86c50a7a5900"
      },
[..]
}

我在 google 上找到了这个 web site about JetAdvice,其中说:

Download JetAdvice Edge and generate Install Key

我没有帐户,但我想您必须生成密钥并设置 install.json。