Skip to content

Commit d1f8d76

Browse files
committed
change dockerfile
1 parent 4985b9b commit d1f8d76

File tree

4 files changed

+51
-8
lines changed

4 files changed

+51
-8
lines changed

Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ RUN cd $FLOW_PLATFORM_SOURCE_CODE \
3838
&& rm -rf $FLOW_PLATFORM_SOURCE_CODE \
3939
&& rm -rf $MVN_CACHE
4040

41+
42+
# add aliyun proxy
43+
ADD ./docker/settings.xml /root/.m2/
44+
45+
# cache mvn package
46+
VOLUME /root/.m2/repository
47+
4148
# setup flow.ci default configuration
4249
COPY ./docker/app-cc.properties $FLOW_PLATFORM_CONFIG_DIR
4350
COPY ./docker/app-api.properties $FLOW_PLATFORM_CONFIG_DIR

platform-plugin/src/main/java/com/flow/platform/plugin/service/PluginServiceImpl.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,9 +488,11 @@ public void exec(Plugin plugin) {
488488
}
489489

490490
private void build(Plugin plugin) {
491+
LOGGER.trace("Start build");
491492
Path cachePath = gitCachePath(plugin);
492493
String cmd = "cd " + cachePath.toString() + Unix.LINE_SEPARATOR + plugin.getPluginDetail().getBuild();
493494
CmdUtil.exeCmd(cmd);
495+
LOGGER.trace("Finish build");
494496
}
495497

496498
private void dockerPullAndBuild(Plugin plugin) {

platform-plugin/src/main/java/com/flow/platform/plugin/util/CmdUtil.java

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@
2020
import com.flow.platform.util.CommandUtil.Unix;
2121
import com.flow.platform.util.Logger;
2222
import java.io.BufferedReader;
23+
import java.io.IOException;
24+
import java.io.InputStream;
2325
import java.io.InputStreamReader;
26+
import java.util.concurrent.LinkedBlockingQueue;
27+
import java.util.concurrent.ThreadPoolExecutor;
28+
import java.util.concurrent.TimeUnit;
2429

2530
/**
2631
* @author yh@firim
@@ -29,8 +34,14 @@ public class CmdUtil {
2934

3035
private final static Logger LOGGER = new Logger(CmdUtil.class);
3136

37+
private final static int BUFFER_SIZE = 1024;
38+
39+
private static final ThreadPoolExecutor executor = new ThreadPoolExecutor(5, 5, 60, TimeUnit.SECONDS,
40+
new LinkedBlockingQueue<>());
41+
3242
public static void exeCmd(String shell) {
33-
BufferedReader br;
43+
44+
LOGGER.debug("Exec cmd is " + shell);
3445
try {
3546
Process process;
3647
ProcessBuilder pb = new ProcessBuilder(Unix.CMD_EXECUTOR, "-c", shell);
@@ -42,23 +53,45 @@ public static void exeCmd(String shell) {
4253
// start
4354
process = pb.start();
4455
if (process != null) {
45-
br = new BufferedReader(
46-
new InputStreamReader(process.getInputStream()), 1024);
56+
57+
LOGGER.trace("Start debug logs");
58+
executor.execute(new LoggerRunner(process.getInputStream()));
4759

4860
// wait process finish
4961
process.waitFor();
5062
} else {
5163
throw new PluginException("Plugin running process is not start");
5264
}
5365

54-
String line;
55-
while (br != null && (line = br.readLine()) != null) {
56-
// show running log
57-
LOGGER.debug(line);
58-
}
66+
5967
} catch (Exception e) {
6068
LOGGER.error("Exec cmd error", e);
6169
} finally {
6270
}
6371
}
72+
73+
static class LoggerRunner implements Runnable {
74+
75+
private InputStream inputStream;
76+
77+
public LoggerRunner(InputStream inputStream) {
78+
this.inputStream = inputStream;
79+
}
80+
81+
@Override
82+
public void run() {
83+
BufferedReader br = new BufferedReader(
84+
new InputStreamReader(inputStream), BUFFER_SIZE);
85+
86+
String line;
87+
try {
88+
while (br != null && (line = br.readLine()) != null) {
89+
// show running log
90+
LOGGER.debug(line);
91+
}
92+
} catch (IOException e) {
93+
LOGGER.error("Logger running log", e);
94+
}
95+
}
96+
}
6497
}

platform-plugin/src/main/java/com/flow/platform/plugin/util/docker/Docker.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,4 +222,5 @@ public void run() {
222222
}
223223
}
224224
}
225+
225226
}

0 commit comments

Comments
 (0)