Skip to content

Commit d965810

Browse files
committed
[sofastack#19] Docker image built support
1 parent f4a0f58 commit d965810

File tree

7 files changed

+185
-1
lines changed

7 files changed

+185
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
version: '2'
2+
3+
services:
4+
sofa-dashboard-quick-start:
5+
image: sofastack/sofa-dashboard-web:1.0.0-SNAPSHOT
6+
container_name: sofa-dashboard-quick-start
7+
depends_on:
8+
- sofa-dashboard-db
9+
- sofa-dashboard-zk
10+
ports:
11+
- "8080:8080"
12+
links:
13+
- sofa-dashboard-zk
14+
- sofa-dashboard-db
15+
16+
sofa-dashboard-zk:
17+
image: zookeeper:3.4.14
18+
container_name: sofa-dashboard-zk
19+
environment:
20+
ZOO_MY_ID: 1
21+
ZOO_SERVERS: server.1=0.0.0.0:2888:3888
22+
ports:
23+
- "2181:2181"
24+
25+
sofa-dashboard-db:
26+
image: mysql:5.7
27+
container_name: sofa-dashboard-db
28+
environment:
29+
TZ: Asia/Shanghai
30+
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
31+
depends_on:
32+
- sofa-dashboard-dbdata
33+
ports:
34+
- "3306:3306"
35+
volumes:
36+
- ../../sql:/docker-entrypoint-initdb.d
37+
volumes_from:
38+
- sofa-dashboard-dbdata
39+
40+
sofa-dashboard-dbdata:
41+
image: alpine:latest
42+
container_name: sofa-dashboard-dbdata
43+
volumes:
44+
- /var/lib/mysql
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM openjdk:8
2+
3+
WORKDIR /root
4+
5+
ADD sofa-dashboard-web-latest.jar /root/
6+
7+
EXPOSE 8080
8+
9+
CMD java -jar sofa-dashboard-web-latest.jar \
10+
--spring.profiles.active=docker
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
echo
4+
echo '--- Build SOFA-Dashboard Docker image ---'
5+
echo " DOCKER_BUILD_DIR=${DOCKER_BUILD_DIR}"
6+
echo " DOCKER_IMG_NAME=${DOCKER_IMG_NAME}"
7+
echo " SCRIPTS_DIR=${SCRIPTS_DIR}"
8+
echo " ARTIFACT_JAR=${ARTIFACT_JAR}"
9+
echo
10+
11+
# Re-create build context
12+
rm -rf ${DOCKER_BUILD_DIR} && mkdir -p ${DOCKER_BUILD_DIR}
13+
14+
# Copy artifact resources
15+
cp -r ${SCRIPTS_DIR}/* ${DOCKER_BUILD_DIR}
16+
cp ${ARTIFACT_JAR} ${DOCKER_BUILD_DIR}/sofa-dashboard-web-latest.jar
17+
18+
19+
docker build ${DOCKER_BUILD_DIR} -t ${DOCKER_IMG_NAME}

sofa-dashboard-backend/sofa-dashboard-web/pom.xml

+60
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,64 @@
9595
</plugins>
9696
</build>
9797

98+
<profiles>
99+
<profile>
100+
<id>docker</id>
101+
<dependencies>
102+
<dependency>
103+
<groupId>com.alipay.sofa</groupId>
104+
<artifactId>sofa-dashboard-front</artifactId>
105+
<version>1.0.0-SNAPSHOT</version>
106+
</dependency>
107+
</dependencies>
108+
<build>
109+
<resources>
110+
<resource>
111+
<directory>../../sofa-dashboard-front/target</directory>
112+
<targetPath>static</targetPath>
113+
</resource>
114+
<resource>
115+
<directory>src/main/resources</directory>
116+
</resource>
117+
</resources>
118+
<plugins>
119+
<plugin>
120+
<groupId>org.codehaus.mojo</groupId>
121+
<artifactId>exec-maven-plugin</artifactId>
122+
<executions>
123+
<execution>
124+
<phase>install</phase>
125+
<goals>
126+
<goal>exec</goal>
127+
</goals>
128+
<configuration>
129+
<executable>bash</executable>
130+
<arguments>
131+
<argument>-e</argument>
132+
<argument>
133+
${project.basedir}/docker/build-docker.sh
134+
</argument>
135+
</arguments>
136+
<environmentVariables>
137+
<DOCKER_BUILD_DIR>
138+
${project.build.directory}/docker
139+
</DOCKER_BUILD_DIR>
140+
<DOCKER_IMG_NAME>
141+
sofastack/${project.artifactId}:${project.version}
142+
</DOCKER_IMG_NAME>
143+
<SCRIPTS_DIR>
144+
${project.basedir}/docker
145+
</SCRIPTS_DIR>
146+
<ARTIFACT_JAR>
147+
${project.build.directory}/${project.artifactId}-${project.version}.jar
148+
</ARTIFACT_JAR>
149+
</environmentVariables>
150+
</configuration>
151+
</execution>
152+
</executions>
153+
</plugin>
154+
</plugins>
155+
</build>
156+
</profile>
157+
</profiles>
98158
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
server.port=8080
2+
# ark 管控端配置中心地址
3+
com.alipay.sofa.dashboard.zookeeper.address=sofa-dashboard-zk:2181
4+
# mysql 数据库连接属性配置
5+
spring.datasource.url=jdbc:mysql://sofa-dashboard-db:3306/SofaDashboardDB
6+
spring.datasource.username=root
7+
spring.datasource.password=
8+
# zookeeper 注册中心地址
9+
com.alipay.sofa.dashboard.registry=zookeeper://sofa-dashboard-zk:2181

sofa-dashboard-front/config/config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export default {
7171
},
7272

7373
// build path
74-
outputPath: '/home/admin/release/run/target/static',
74+
outputPath: 'target',
7575

7676
externals: {
7777
'@antv/data-set': 'DataSet',

sofa-dashboard-front/pom.xml

+42
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,47 @@
1111

1212
<artifactId>sofa-dashboard-front</artifactId>
1313

14+
<profiles>
15+
<profile>
16+
<id>docker</id>
17+
<build>
18+
<plugins>
19+
<plugin>
20+
<groupId>org.codehaus.mojo</groupId>
21+
<artifactId>exec-maven-plugin</artifactId>
22+
<executions>
23+
<execution>
24+
<id>npm-install</id>
25+
<phase>validate</phase>
26+
<goals>
27+
<goal>exec</goal>
28+
</goals>
29+
<configuration>
30+
<executable>npm</executable>
31+
<arguments>
32+
<argument>install</argument>
33+
</arguments>
34+
</configuration>
35+
</execution>
36+
<execution>
37+
<id>npm-run-build</id>
38+
<phase>generate-resources</phase>
39+
<goals>
40+
<goal>exec</goal>
41+
</goals>
42+
<configuration>
43+
<executable>npm</executable>
44+
<arguments>
45+
<argument>run</argument>
46+
<argument>build</argument>
47+
</arguments>
48+
</configuration>
49+
</execution>
50+
</executions>
51+
</plugin>
52+
</plugins>
53+
</build>
54+
</profile>
55+
</profiles>
1456

1557
</project>

0 commit comments

Comments
 (0)