Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
705 views
in Technique[技术] by (71.8m points)

dockerfile - Converting a program into a docker container

I'm trying to convert this program:

DownloadJetAdvice Edge

Full installation guide for can be seen here

From an installation to a linux machine, into a Docker container.

I need multiple running instances of this, and i've been using Docker alot in my sparetime, and it's finally time to use in my work aswell!

I've got the dockerfile complete (i think) when i build it, it downloads, and installs what it needs to, and the build completes without issues.

However, I can't get the JetAdvice program / services to run! I've read, that if i want multiple things to run in a container, i should use supervisor, and since the JetEdge program has 3 running services, i'm using that.

This is my dockerfile:

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"]

This is my 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

And the startup.sh script:

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

I've tried to run the JetAdvice a bunch of ways, but i can't get the program to run.

For info, this is one of the JedAdvice-Edge.service files:

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

If i log into my docker container and try to run the service, i get this erroor

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

If i try to run the program directly i get:

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

I tried doing chmod +x on /usr/bin/JetAdvice/Edge/Edge and then it seems like the program is running for 3 seconds, then nothing happens.

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

I'm not even close to a linux expert, but i can't imagine that what i'm trying to do, can't be done. So what am i doing wrong, what's the next step?

Working install.json file from the JetEdge team

{
  "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
      }
    ]
  }
}

And the key i generated for testing is: 4809b732-eb36-413f-8993-bd8d1f2e2942

EDIT, i've updated the dockerfile, and added the startup.sh script to the OP.

question from:https://stackoverflow.com/questions/65830110/converting-a-program-into-a-docker-container

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I have slightly modified your 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"]

I have added this line RUN chmod +x /usr/bin/JetAdvice/Edge/Edge for adding +x to the executable.

Now when I started the container gave me an error and it stop the supervisord. Under /usr/share/JetAdvice/Edge/LogFiles you can find the JetAdvice Edge logs whitin it this error

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)

I have found the install.json file under /usr/share/JetAdvice/Edge/Config/Shared, inside there are the InstallKey json field

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

I found on google this web site about JetAdvice where says:

Download JetAdvice Edge and generate Install Key

I don't have an account but I suppose you must generate the key and setup the install.json.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...