forked from apolloconfig/apollo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
冯靖
committed
Jul 13, 2017
1 parent
d010aa5
commit 441e20b
Showing
23 changed files
with
1,337 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Dockerfile for apollo-adminservice | ||
# Build with: | ||
# docker build -t apollo-adminservice . | ||
# Run with: | ||
# docker run -p 8090:8090 -d --name apollo-adminservice apollo-adminservice | ||
|
||
FROM openjdk:8-jre-alpine | ||
MAINTAINER ameizi <[email protected]> | ||
|
||
ENV VERSION 0.8.0 | ||
|
||
RUN echo "http://mirrors.aliyun.com/alpine/v3.6/main" > /etc/apk/repositories \ | ||
&& echo "http://mirrors.aliyun.com/alpine/v3.6/community" >> /etc/apk/repositories \ | ||
&& apk update upgrade \ | ||
&& apk add --no-cache unzip curl bash tzdata \ | ||
&& ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ | ||
&& echo "Asia/Shanghai" > /etc/timezone | ||
|
||
ADD apollo-adminservice-${VERSION}-github.zip /apollo-adminservice/apollo-adminservice-${VERSION}-github.zip | ||
|
||
RUN unzip /apollo-adminservice/apollo-adminservice-${VERSION}-github.zip -d /apollo-adminservice \ | ||
&& rm -rf /apollo-adminservice/apollo-adminservice-${VERSION}-github.zip \ | ||
&& sed -i '$d' /apollo-adminservice/scripts/startup.sh \ | ||
&& echo "tail -f /dev/null" >> /apollo-adminservice/scripts/startup.sh | ||
|
||
EXPOSE 8090 | ||
|
||
CMD ["/apollo-adminservice/scripts/startup.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Dockerfile for apollo-configservice | ||
# Build with: | ||
# docker build -t apollo-configservice . | ||
# Run with: | ||
# docker run -p 8080:8080 -d --name apollo-configservice apollo-configservice | ||
|
||
FROM openjdk:8-jre-alpine | ||
MAINTAINER ameizi <[email protected]> | ||
|
||
ENV VERSION 0.8.0 | ||
|
||
RUN echo "http://mirrors.aliyun.com/alpine/v3.6/main" > /etc/apk/repositories \ | ||
&& echo "http://mirrors.aliyun.com/alpine/v3.6/community" >> /etc/apk/repositories \ | ||
&& apk update upgrade \ | ||
&& apk add --no-cache unzip curl bash tzdata \ | ||
&& ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ | ||
&& echo "Asia/Shanghai" > /etc/timezone | ||
|
||
ADD apollo-configservice-${VERSION}-github.zip /apollo-configservice/apollo-configservice-${VERSION}-github.zip | ||
|
||
RUN unzip /apollo-configservice/apollo-configservice-${VERSION}-github.zip -d /apollo-configservice \ | ||
&& rm -rf /apollo-configservice/apollo-configservice-${VERSION}-github.zip \ | ||
&& sed -i '$d' /apollo-configservice/scripts/startup.sh \ | ||
&& echo "tail -f /dev/null" >> /apollo-configservice/scripts/startup.sh | ||
|
||
EXPOSE 8080 | ||
|
||
CMD ["/apollo-configservice/scripts/startup.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Dockerfile for apollo-portal | ||
# Build with: | ||
# docker build -t apollo-portal . | ||
# Run with: | ||
# docker run -p 9090:8080 -d --name apollo-portal apollo-portal | ||
|
||
FROM openjdk:8-jre-alpine | ||
MAINTAINER ameizi <[email protected]> | ||
|
||
ENV VERSION 0.8.0 | ||
|
||
RUN echo "http://mirrors.aliyun.com/alpine/v3.6/main" > /etc/apk/repositories \ | ||
&& echo "http://mirrors.aliyun.com/alpine/v3.6/community" >> /etc/apk/repositories \ | ||
&& apk update upgrade \ | ||
&& apk add --no-cache unzip curl bash tzdata \ | ||
&& ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ | ||
&& echo "Asia/Shanghai" > /etc/timezone | ||
|
||
ADD apollo-portal-${VERSION}-github.zip /apollo-portal/apollo-portal-${VERSION}-github.zip | ||
|
||
RUN unzip /apollo-portal/apollo-portal-${VERSION}-github.zip -d /apollo-portal \ | ||
&& rm -rf /apollo-portal/apollo-portal-${VERSION}-github.zip \ | ||
&& sed -i '$d' /apollo-portal/scripts/startup.sh \ | ||
&& echo "tail -f /dev/null" >> /apollo-portal/scripts/startup.sh | ||
|
||
EXPOSE 8080 | ||
|
||
CMD ["/apollo-portal/scripts/startup.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
target/ | ||
.mvn | ||
mvnw | ||
mvnw.cmd | ||
|
||
### STS ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
|
||
### IntelliJ IDEA ### | ||
.idea | ||
*.iws | ||
*.iml | ||
*.ipr | ||
|
||
### NetBeans ### | ||
nbproject/private/ | ||
build/ | ||
nbbuild/ | ||
dist/ | ||
nbdist/ | ||
.nb-gradle/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# apollo-spring-boot-sample | ||
Demo project for Spring Boot Apollo | ||
|
||
Spring Boot整合携程Apollo配置中心 | ||
|
||
## 客户端maven配置 | ||
|
||
* apollo-client(必须) | ||
|
||
```xml | ||
<dependency> | ||
<groupId>com.ctrip.framework.apollo</groupId> | ||
<artifactId>apollo-client</artifactId> | ||
<version>0.8.0</version> | ||
</dependency> | ||
``` | ||
* spring-boot-starter-actuator 和 spring-cloud-context | ||
|
||
```xml | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-actuator</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.cloud</groupId> | ||
<artifactId>spring-cloud-context</artifactId> | ||
<version>1.2.2.RELEASE</version> | ||
</dependency> | ||
``` | ||
|
||
注意: | ||
|
||
1、`apollo-client`为必须配置 | ||
|
||
2、`spring-boot-starter-actuator` 和 `spring-cloud-context`为可选配置。仅在使用`Spring Cloud`的`@RefreshScope`时所需 | ||
|
||
# 参考文档 | ||
|
||
https://github.com/ctripcorp/apollo/wiki/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>net.ameizi</groupId> | ||
<artifactId>apollo-spring-boot-sample</artifactId> | ||
<version>1.0</version> | ||
<packaging>jar</packaging> | ||
|
||
<name>Apollo Spring Boot Sample</name> | ||
<description>Demo project for Spring Boot Apollo</description> | ||
|
||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>1.5.4.RELEASE</version> | ||
<relativePath/> <!-- lookup parent from repository --> | ||
</parent> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> | ||
<java.version>1.8</java.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-configuration-processor</artifactId> | ||
<optional>true</optional> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-actuator</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.cloud</groupId> | ||
<artifactId>spring-cloud-context</artifactId> | ||
<version>1.2.2.RELEASE</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.ctrip.framework.apollo</groupId> | ||
<artifactId>apollo-client</artifactId> | ||
<version>0.8.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
<optional>true</optional> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
</plugin> | ||
<plugin> | ||
<groupId>com.spotify</groupId> | ||
<artifactId>docker-maven-plugin</artifactId> | ||
<version>0.4.13</version> | ||
<configuration> | ||
<imageName>${project.artifactId}</imageName> | ||
<dockerDirectory>src/main/docker</dockerDirectory> | ||
<resources> | ||
<resource> | ||
<targetPath>/</targetPath> | ||
<directory>${project.build.directory}</directory> | ||
<include>${project.build.finalName}.jar</include> | ||
</resource> | ||
</resources> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
FROM openjdk:8-jre-alpine | ||
MAINTAINER ameizi <[email protected]> | ||
VOLUME /tmp | ||
RUN echo "http://mirrors.aliyun.com/alpine/v3.6/main" > /etc/apk/repositories \ | ||
&& echo "http://mirrors.aliyun.com/alpine/v3.6/community" >> /etc/apk/repositories \ | ||
&& apk update upgrade \ | ||
&& apk add --no-cache tzdata \ | ||
&& ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ | ||
&& echo "Asia/Shanghai" > /etc/timezone | ||
ADD *.jar app.jar | ||
RUN sh -c 'touch /app.jar' \ | ||
&& mkdir -p /opt/settings \ | ||
&& echo "env=DEV" > /opt/settings/server.properties | ||
ENV JAVA_OPTS="" | ||
EXPOSE 9090 | ||
ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar" ] |
24 changes: 24 additions & 0 deletions
24
apollo-spring-boot-sample/src/main/java/net/ameizi/ApolloConfigSample.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package net.ameizi; | ||
|
||
import com.ctrip.framework.apollo.spring.annotation.EnableApolloConfig; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
/** | ||
* @EnableApolloConfig要和@Configuration一起使用,不然不会生效。 | ||
*/ | ||
@Configuration | ||
@EnableApolloConfig | ||
public class ApolloConfigSample { | ||
|
||
@Bean | ||
public JavaConfigSample javaConfigSample(){ | ||
return new JavaConfigSample(); | ||
} | ||
|
||
@Bean | ||
public ConfigurationPropertiesSample configurationPropertiesSample() { | ||
return new ConfigurationPropertiesSample(); | ||
} | ||
|
||
} |
Oops, something went wrong.