From b1741799618fe86a39720937cb087fc625e29c8e Mon Sep 17 00:00:00 2001 From: zhouyixun <291028775@qq.com> Date: Thu, 14 Oct 2021 21:50:16 +0800 Subject: [PATCH] save_docker_init --- pom.xml | 84 ++++++++++++++----- src/main/docker/Dockerfile | 67 +++++++++++++++ .../com/sonic/agent/receiver/MsgReceiver.java | 5 +- .../com/sonic/agent/tools/LocalHostTool.java | 19 ----- src/main/resources/application-dev.yml | 1 + src/main/resources/application-prod.yml | 24 ++++++ src/main/resources/banner.txt | 2 - 7 files changed, 159 insertions(+), 43 deletions(-) create mode 100644 src/main/docker/Dockerfile delete mode 100644 src/main/java/com/sonic/agent/tools/LocalHostTool.java create mode 100644 src/main/resources/application-prod.yml diff --git a/pom.xml b/pom.xml index 86d64c29..cc99796f 100644 --- a/pom.xml +++ b/pom.xml @@ -10,15 +10,15 @@ jar - 15 - 15 + 16 + 16 org.springframework.boot spring-boot-starter-parent - 2.3.11.RELEASE + 2.4.11 @@ -157,6 +157,50 @@ + + prod + + prod + + + + org.bytedeco + ffmpeg + 4.2.2-1.5.3 + linux-x86_64 + + + org.bytedeco + javacpp + 1.5.3 + linux-x86_64 + + + org.bytedeco + opencv + 4.3.0-1.5.3 + linux-x86_64 + + + org.bytedeco + openblas + 0.3.9-1.5.3 + linux-x86_64 + + + org.bytedeco + tesseract + 4.1.1-1.5.3 + linux-x86_64 + + + org.bytedeco + leptonica + 1.79.0-1.5.3 + linux-x86_64 + + + @@ -174,22 +218,22 @@ - - - - - - - - - - - - - - - - - + + + + + src/main/resources + true + + + + ${project.artifactId} + + + org.springframework.boot + spring-boot-maven-plugin + + + \ No newline at end of file diff --git a/src/main/docker/Dockerfile b/src/main/docker/Dockerfile new file mode 100644 index 00000000..7760aa30 --- /dev/null +++ b/src/main/docker/Dockerfile @@ -0,0 +1,67 @@ +FROM ubuntu:bionic-20200311 + +ENV DEBIAN_FRONTEND=noninteractive + +ENV SDK_VERSION=sdk-tools-linux-3859397 \ + ANDROID_BUILD_TOOLS_VERSION=31.0.0 \ + APPIUM_VERSION=1.22.0 \ + ATD_VERSION=1.2 + +WORKDIR /root + +RUN apt-get -qqy update && \ + apt-get -qqy --no-install-recommends install \ + openjdk-8-jdk \ + ca-certificates \ + zip \ + unzip \ + curl \ + wget \ + libqt5webkit5 \ + libgconf-2-4 \ + gnupg \ + salt-minion \ + && rm -rf /var/lib/apt/lists/* + +ENV JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64/jre" \ + PATH=$PATH:$JAVA_HOME/bin + +RUN wget -O java.tar.gz https://download.oracle.com/otn-pub/java/jdk/16.0.2+7/d4a915d82b4c4fbb9bde534da945d746/jdk-16.0.2_linux-x64_bin.tar.gz?AuthParam=1634195311_0d15009c3d955574b75fd6d51664b996 && \ + tar zxvf java.tar.gz && rm java.tar.gz && \ + chmod a+x -R /root/jdk-16.0.2 && \ + chown -R root:root /root/jdk-16.0.2 + +ARG ANDROID_PLATFORM_VERSION="android-25" +ENV ANDROID_HOME=/root + +RUN wget -O tools.zip https://dl.google.com/android/repository/${SDK_VERSION}.zip && \ + unzip tools.zip && rm tools.zip && \ + chmod a+x -R $ANDROID_HOME && \ + chown -R root:root $ANDROID_HOME + +ENV PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin + +RUN mkdir -p ~/.android && \ + touch ~/.android/repositories.cfg && \ + echo y | sdkmanager "platform-tools" && \ + echo y | sdkmanager "build-tools;$ANDROID_BUILD_TOOLS_VERSION" && \ + echo y | sdkmanager "platforms;$ANDROID_PLATFORM_VERSION" + +ENV PATH=$PATH:$ANDROID_HOME/platform-tools:$ANDROID_HOME/build-tools + +RUN curl -sL https://deb.nodesource.com/setup_12.x | bash && \ + apt-get -qqy install nodejs && \ + npm install -g appium@${APPIUM_VERSION} --unsafe-perm=true --allow-root && \ + exit 0 && \ + npm cache clean && \ + apt-get remove --purge -y npm && \ + apt-get autoremove --purge -y && \ + rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \ + apt-get clean + +ADD /mini /root/ +ADD /chromeDriver /root/ +ADD /language /root/ +ADD /sonic-agent.jar /root/ +RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime +ENTRYPOINT ["/root/jdk-16.0.2/bin/java","-server","-Xmx800M","-Xms800M","-Xmn300M","-Xss256K","-XX:-UseGCOverheadLimit","-XX:+DisableExplicitGC","-XX:SurvivorRatio=1","-XX:LargePageSizeInBytes=128M","-XX:SoftRefLRUPolicyMSPerMB=0","-Djava.security.egd=file:/dev/./urandom","-jar","/root/sonic-agent.jar"] \ No newline at end of file diff --git a/src/main/java/com/sonic/agent/receiver/MsgReceiver.java b/src/main/java/com/sonic/agent/receiver/MsgReceiver.java index 23479b37..bc876388 100644 --- a/src/main/java/com/sonic/agent/receiver/MsgReceiver.java +++ b/src/main/java/com/sonic/agent/receiver/MsgReceiver.java @@ -14,7 +14,6 @@ import com.sonic.agent.tests.AndroidTests; import com.sonic.agent.tools.AgentTool; import com.sonic.agent.tools.GetWebStartPort; -import com.sonic.agent.tools.LocalHostTool; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.amqp.core.Message; @@ -35,6 +34,8 @@ public class MsgReceiver { @Value("${spring.version}") private String version; + @Value("${sonic.agent.host}") + private String host; @Autowired private AndroidTests androidTests; private final Logger logger = LoggerFactory.getLogger(MsgReceiver.class); @@ -54,7 +55,7 @@ public void process(JSONObject jsonObject, Channel channel, Message message) { agentInfo.put("port", GetWebStartPort.getTomcatPort()); agentInfo.put("version", version); agentInfo.put("systemType", System.getProperty("os.name")); - agentInfo.put("host", LocalHostTool.getHostIp()); + agentInfo.put("host", host); RabbitMQThread.send(agentInfo); try { channel.basicAck(deliveryTag, true); diff --git a/src/main/java/com/sonic/agent/tools/LocalHostTool.java b/src/main/java/com/sonic/agent/tools/LocalHostTool.java deleted file mode 100644 index c58ca1b4..00000000 --- a/src/main/java/com/sonic/agent/tools/LocalHostTool.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.sonic.agent.tools; - -import java.net.InetAddress; - -public class LocalHostTool { - public static String host = "127.0.0.1"; - - public static String getHostIp() { - if (!host.equals("127.0.0.1")) { - return host; - } - try { - host = InetAddress.getLocalHost().getHostAddress(); - } catch (Exception e) { - e.printStackTrace(); - } - return host; - } -} \ No newline at end of file diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 53f9043f..a9e41e1a 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -20,4 +20,5 @@ sonic: folder: url: http://localhost:8094/api/folder agent: + host: 127.0.0.1 key: 1 diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml new file mode 100644 index 00000000..3e794cb7 --- /dev/null +++ b/src/main/resources/application-prod.yml @@ -0,0 +1,24 @@ +server: + port: 7777 + +spring: + application: + name: apex-agent + rabbitmq: + host: ${RABBITMQ_HOST:localhost} + port: ${RABBITMQ_PORT:5672} + username: ${RABBITMQ_USERNAME:sonic} + password: ${RABBITMQ_PASSWORD:sonic} + virtual-host: ${RABBITMQ_VHOST:sonic} + listener: + simple: + acknowledge-mode: manual + publisher-confirm-type: correlated + publisher-returns: true + +sonic: + folder: + url: ${SONIC_FOLDER_URL:http://localhost:8094/api/folder} + agent: + host: ${SONIC_AGENT_HOST:127.0.0.1} + key: ${SONIC_AGENT_KEY} diff --git a/src/main/resources/banner.txt b/src/main/resources/banner.txt index b6b41fe3..e8492434 100644 --- a/src/main/resources/banner.txt +++ b/src/main/resources/banner.txt @@ -5,5 +5,3 @@ ▀██ ██ ██ ██ █▄██ ██ ██▄ █▄▄▄▄▄█▀ ██▄▄██ ██ ███ ▄▄██▄▄ ██▄▄▄▄█ ▀▀▀▀▀ ▀▀▀▀ ▀▀ ▀▀▀ ▀▀▀▀▀▀ ▀▀▀▀ - - Sonic云测平台 - Agent端