Skip to content

Commit 360995c

Browse files
committed
feat: 提交dockr构建脚本
1 parent d266ac2 commit 360995c

File tree

8 files changed

+109
-18
lines changed

8 files changed

+109
-18
lines changed

.github/workflows/docker.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: DockerImage
2+
3+
on:
4+
release:
5+
types: [ published ]
6+
7+
jobs:
8+
release:
9+
name: Release Polaris Docker Image
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v2
14+
15+
- name: Get version
16+
id: get_version
17+
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
18+
19+
- name: Set up JDK 8
20+
uses: actions/setup-java@v3
21+
with:
22+
distribution: 'temurin'
23+
java-version: 8
24+
25+
- name: Set up Docker Buildx
26+
uses: docker/setup-buildx-action@v1
27+
28+
- name: Log in to Docker Hub
29+
uses: docker/login-action@v1
30+
with:
31+
username: ${{ secrets.POLARIS_DOCKER_NAME }}
32+
password: ${{ secrets.POLARIS_DOCKER_PASSWORD }}
33+
34+
- name: Build Server
35+
id: build-server
36+
env:
37+
DOCKER_TAG: ${{ steps.get_version.outputs.VERSION }}
38+
run: |
39+
ls -lstrh
40+
bash build-docker.sh ${DOCKER_TAG}

Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM java:8
2+
3+
COPY polaris-sync-server/target/polaris-sync-${version}.jar /app/polaris-sync-server.jar
4+
5+
WORKDIR /app
6+
7+
RUN chmod 777 /app/
8+
9+
CMD ["java", "-jar", "polaris-sync-server.jar"]

build-docker.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
set -o errexit
4+
5+
if [ "$#" -ne 1 ]; then
6+
echo "Incorrect parameters"
7+
echo "Usage: build-docker.sh <version>"
8+
exit 1
9+
fi
10+
11+
VERSION=$1
12+
13+
PREFIX="docker.io/polarismesh"
14+
SCRIPTDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
15+
16+
pushd "$SCRIPTDIR/"
17+
#java build the app.
18+
docker run --rm -u root -v "$(pwd)":/home/maven/project -w /home/maven/project maven:3.8.1-openjdk-8-slim mvn clean package
19+
#plain build -- no ratings
20+
docker build --pull -t "${PREFIX}/polaris-sync:${VERSION}" -t "${PREFIX}/polaris-sync:latest" --build-arg version=${VERSION} .
21+
docker push "${PREFIX}/polaris-sync:${VERSION}"
22+
popd

polaris-sync-commons/src/main/java/cn/polarismesh/polaris/sync/common/rest/RestResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public static <T> RestResponse<T> withNormalResponse(ResponseEntity<T> responseE
4747
public static <T> RestResponse<T> withRestClientException(RestClientException restClientException) {
4848
if (restClientException instanceof RestClientResponseException) {
4949
//存在消息返回,只是前面没有出错
50-
RestClientResponseException restClientResponseException = (RestClientResponseException)restClientException;
50+
RestClientResponseException restClientResponseException = (RestClientResponseException) restClientException;
5151
return new RestResponse<T>(null, null,
5252
restClientResponseException.getRawStatusCode(), restClientResponseException.getStatusText());
5353
} else {

polaris-sync-registry-core/src/main/java/cn/polarismesh/polaris/sync/registry/config/SyncRegistryProperties.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222
import org.springframework.validation.annotation.Validated;
2323

2424
@ConfigurationProperties("polaris.sync.registry")
25-
//@Validated
25+
@Validated
2626
public class SyncRegistryProperties {
2727

28-
//@NotEmpty
28+
@NotEmpty
2929
private String configPath;
3030

31-
//@NotEmpty
31+
@NotEmpty
3232
private String watchPath;
3333

3434
public String getConfigPath() {

polaris-sync-registry-core/src/main/java/cn/polarismesh/polaris/sync/registry/utils/DurationUtils.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,11 @@
1919

2020
import java.time.Duration;
2121
import java.util.regex.Pattern;
22-
import org.springframework.util.StringUtils;
2322

2423
/**
2524
* 解析时间格式的工具类
2625
*
2726
* @author andrewshan
28-
* @date 2019/8/20
2927
*/
3028
public class DurationUtils {
3129

polaris-sync-server/pom.xml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,26 @@
4646
<version>${project.version}</version>
4747
</dependency>
4848
</dependencies>
49+
50+
<build>
51+
<plugins>
52+
<plugin>
53+
<groupId>org.springframework.boot</groupId>
54+
<artifactId>spring-boot-maven-plugin</artifactId>
55+
<configuration>
56+
<mainClass>cn.polarismesh.polaris.server.SyncServer</mainClass>
57+
<layout>JAR</layout>
58+
<executable>true</executable>
59+
</configuration>
60+
<executions>
61+
<execution>
62+
<id>repackage</id>
63+
<goals>
64+
<goal>repackage</goal>
65+
</goals>
66+
</execution>
67+
</executions>
68+
</plugin>
69+
</plugins>
70+
</build>
4971
</project>

pom.xml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@
7676
</plugins>
7777
</pluginManagement>
7878
<plugins>
79-
<plugin>
80-
<groupId>org.apache.maven.plugins</groupId>
81-
<artifactId>maven-checkstyle-plugin</artifactId>
82-
</plugin>
79+
<!-- <plugin>-->
80+
<!-- <groupId>org.apache.maven.plugins</groupId>-->
81+
<!-- <artifactId>maven-checkstyle-plugin</artifactId>-->
82+
<!-- </plugin>-->
8383
<plugin>
8484
<groupId>org.apache.maven.plugins</groupId>
8585
<artifactId>maven-compiler-plugin</artifactId>
@@ -154,14 +154,14 @@
154154
</plugins>
155155
</build>
156156

157-
<reporting>
158-
<plugins>
159-
<plugin>
160-
<groupId>org.apache.maven.plugins</groupId>
161-
<artifactId>maven-checkstyle-plugin</artifactId>
162-
</plugin>
163-
</plugins>
164-
</reporting>
157+
<!-- <reporting>-->
158+
<!-- <plugins>-->
159+
<!-- <plugin>-->
160+
<!-- <groupId>org.apache.maven.plugins</groupId>-->
161+
<!-- <artifactId>maven-checkstyle-plugin</artifactId>-->
162+
<!-- </plugin>-->
163+
<!-- </plugins>-->
164+
<!-- </reporting>-->
165165

166166
<profiles>
167167
<profile>

0 commit comments

Comments
 (0)