Skip to content

Commit

Permalink
[sofastack#19] Docker image built support
Browse files Browse the repository at this point in the history
  • Loading branch information
chpengzh committed Jun 15, 2019
1 parent bcb3e56 commit 0f5e3f5
Show file tree
Hide file tree
Showing 7 changed files with 185 additions and 1 deletion.
44 changes: 44 additions & 0 deletions scripts/docker-quick-start/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
version: '2'

services:
sofa-dashboard-quick-start:
image: sofastack/sofa-dashboard-web:1.0.0-SNAPSHOT
container_name: sofa-dashboard-quick-start
depends_on:
- sofa-dashboard-db
- sofa-dashboard-zk
ports:
- "8080:8080"
links:
- sofa-dashboard-zk
- sofa-dashboard-db

sofa-dashboard-zk:
image: zookeeper:3.4.14
container_name: sofa-dashboard-zk
environment:
ZOO_MY_ID: 1
ZOO_SERVERS: server.1=0.0.0.0:2888:3888
ports:
- "2181:2181"

sofa-dashboard-db:
image: mysql:5.7
container_name: sofa-dashboard-db
environment:
TZ: Asia/Shanghai
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
depends_on:
- sofa-dashboard-dbdata
ports:
- "3306:3306"
volumes:
- ../../sql:/docker-entrypoint-initdb.d
volumes_from:
- sofa-dashboard-dbdata

sofa-dashboard-dbdata:
image: alpine:latest
container_name: sofa-dashboard-dbdata
volumes:
- /var/lib/mysql
10 changes: 10 additions & 0 deletions sofa-dashboard-backend/sofa-dashboard-web/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM openjdk:8

WORKDIR /root

ADD sofa-dashboard-web-latest.jar /root/

EXPOSE 8080

CMD java -jar sofa-dashboard-web-latest.jar \
--spring.profiles.active=docker
19 changes: 19 additions & 0 deletions sofa-dashboard-backend/sofa-dashboard-web/docker/build-docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

echo
echo '--- Build SOFA-Dashboard Docker image ---'
echo " DOCKER_BUILD_DIR=${DOCKER_BUILD_DIR}"
echo " DOCKER_IMG_NAME=${DOCKER_IMG_NAME}"
echo " SCRIPTS_DIR=${SCRIPTS_DIR}"
echo " ARTIFACT_JAR=${ARTIFACT_JAR}"
echo

# Re-create build context
rm -rf ${DOCKER_BUILD_DIR} && mkdir -p ${DOCKER_BUILD_DIR}

# Copy artifact resources
cp -r ${SCRIPTS_DIR}/* ${DOCKER_BUILD_DIR}
cp ${ARTIFACT_JAR} ${DOCKER_BUILD_DIR}/sofa-dashboard-web-latest.jar


docker build ${DOCKER_BUILD_DIR} -t ${DOCKER_IMG_NAME}
60 changes: 60 additions & 0 deletions sofa-dashboard-backend/sofa-dashboard-web/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,64 @@
</plugins>
</build>

<profiles>
<profile>
<id>docker</id>
<dependencies>
<dependency>
<groupId>com.alipay.sofa</groupId>
<artifactId>sofa-dashboard-front</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>../../sofa-dashboard-front/target</directory>
<targetPath>static</targetPath>
</resource>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>bash</executable>
<arguments>
<argument>-e</argument>
<argument>
${project.basedir}/docker/build-docker.sh
</argument>
</arguments>
<environmentVariables>
<DOCKER_BUILD_DIR>
${project.build.directory}/docker
</DOCKER_BUILD_DIR>
<DOCKER_IMG_NAME>
sofastack/${project.artifactId}:${project.version}
</DOCKER_IMG_NAME>
<SCRIPTS_DIR>
${project.basedir}/docker
</SCRIPTS_DIR>
<ARTIFACT_JAR>
${project.build.directory}/${project.artifactId}-${project.version}.jar
</ARTIFACT_JAR>
</environmentVariables>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
server.port=8080
# ark 管控端配置中心地址
com.alipay.sofa.dashboard.zookeeper.address=sofa-dashboard-zk:2181
# mysql 数据库连接属性配置
spring.datasource.url=jdbc:mysql://sofa-dashboard-db:3306/SofaDashboardDB
spring.datasource.username=root
spring.datasource.password=
# zookeeper 注册中心地址
com.alipay.sofa.dashboard.registry=zookeeper://sofa-dashboard-zk:2181
2 changes: 1 addition & 1 deletion sofa-dashboard-front/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default {
},

// build path
outputPath: '/home/admin/release/run/target/static',
outputPath: 'target',

proxy: {
'/api': {
Expand Down
42 changes: 42 additions & 0 deletions sofa-dashboard-front/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,47 @@

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

<profiles>
<profile>
<id>docker</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>npm-install</id>
<phase>validate</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>npm</executable>
<arguments>
<argument>install</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>npm-run-build</id>
<phase>generate-resources</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>npm</executable>
<arguments>
<argument>run</argument>
<argument>build</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>

0 comments on commit 0f5e3f5

Please sign in to comment.