docker
This commit is contained in:
73
pom.xml
73
pom.xml
@@ -1,23 +1,40 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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"
|
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
<version>3.0.3</version>
|
<version>3.0.5</version>
|
||||||
<relativePath /> <!-- lookup parent from repository -->
|
<relativePath /> <!-- lookup parent from repository -->
|
||||||
</parent>
|
</parent>
|
||||||
<groupId>com.flagnote</groupId>
|
<groupId>com.flagnote</groupId>
|
||||||
<artifactId>flagnote-service</artifactId>
|
<artifactId>flagnote-service</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1</version>
|
||||||
<name>flagnote-service</name>
|
<name>flagnote-service</name>
|
||||||
<description>Demo project for Spring Boot</description>
|
<description>Demo project for Spring Boot</description>
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>17</java.version>
|
<java.version>17</java.version>
|
||||||
<spring-cloud.version>2022.0.1</spring-cloud.version>
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
<maven.compiler.compilerVersion>17</maven.compiler.compilerVersion>
|
||||||
|
<spring-cloud.version>2022.0.2</spring-cloud.version>
|
||||||
|
<docker.image.prefix>flagnote</docker.image.prefix>
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-zookeeper-discovery</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-config-client</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-bootstrap</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||||
@@ -38,16 +55,10 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-aop</artifactId>
|
<artifactId>spring-boot-starter-aop</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-starter-config</artifactId>
|
|
||||||
</dependency>
|
|
||||||
-->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.hutool</groupId>
|
<groupId>cn.hutool</groupId>
|
||||||
<artifactId>hutool-all</artifactId>
|
<artifactId>hutool-all</artifactId>
|
||||||
<version>5.8.10</version>
|
<version>5.8.18</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
@@ -73,6 +84,27 @@
|
|||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<source>17</source>
|
||||||
|
<target>17</target>
|
||||||
|
<encoding>UTF-8</encoding>
|
||||||
|
<showWarnings>true</showWarnings>
|
||||||
|
<fork>true</fork>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<skip>true</skip>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
@@ -85,6 +117,25 @@
|
|||||||
</excludes>
|
</excludes>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
<plugin>
|
||||||
|
<groupId>com.spotify</groupId>
|
||||||
|
<artifactId>docker-maven-plugin</artifactId>
|
||||||
|
<version>1.2.2</version>
|
||||||
|
<configuration>
|
||||||
|
<dockerHost>http://rancher:42375</dockerHost>
|
||||||
|
<imageName>
|
||||||
|
${docker.image.prefix}/${project.artifactId}:${project.version}</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>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
8
src/main/docker/dockerfile
Normal file
8
src/main/docker/dockerfile
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
FROM openjdk:17-slim
|
||||||
|
VOLUME /tmp
|
||||||
|
ADD flagnote-service-0.0.1.jar app.jar
|
||||||
|
RUN sh -c 'touch /app.jar'
|
||||||
|
RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone
|
||||||
|
RUN apt-get update && apt-get install -y curl
|
||||||
|
ENV JAVA_OPTS=""
|
||||||
|
ENTRYPOINT [ "sh", "-c", "exec java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar" ]
|
||||||
@@ -3,10 +3,12 @@ package com.flagnote.note;
|
|||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@EnableAutoConfiguration
|
@EnableAutoConfiguration
|
||||||
|
@EnableDiscoveryClient
|
||||||
@RestController
|
@RestController
|
||||||
public class NoteApplication {
|
public class NoteApplication {
|
||||||
|
|
||||||
|
|||||||
@@ -1,50 +0,0 @@
|
|||||||
server:
|
|
||||||
address: 127.0.0.1
|
|
||||||
port: 20000
|
|
||||||
|
|
||||||
spring:
|
|
||||||
application:
|
|
||||||
name: flagnote-service
|
|
||||||
profiles:
|
|
||||||
active: dev
|
|
||||||
codec:
|
|
||||||
max-in-memory-size: 10MB
|
|
||||||
# config:
|
|
||||||
# import: 'optional:configserver:http://localhost:9999'
|
|
||||||
data:
|
|
||||||
mongodb:
|
|
||||||
authentication-database: flagnote
|
|
||||||
database: flagnote
|
|
||||||
host: service.flagnote.com
|
|
||||||
port: 37017
|
|
||||||
username: flagnote
|
|
||||||
password: flagnote1qazx
|
|
||||||
autoConnectRetry: true
|
|
||||||
socketKeepAlive: true
|
|
||||||
socketTimeout: 10000
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
management:
|
|
||||||
# server:
|
|
||||||
# address: 127.0.0.1
|
|
||||||
# port: 29000
|
|
||||||
endpoint:
|
|
||||||
shutdown:
|
|
||||||
enabled: true
|
|
||||||
health:
|
|
||||||
enabled: true
|
|
||||||
endpoints:
|
|
||||||
web:
|
|
||||||
base-path: /f2w8u47ie56edc93/actuator
|
|
||||||
exposure:
|
|
||||||
include: shutdown,health
|
|
||||||
|
|
||||||
logging:
|
|
||||||
level:
|
|
||||||
org:
|
|
||||||
springframework:
|
|
||||||
data:
|
|
||||||
mongodb:
|
|
||||||
core:
|
|
||||||
MongoTemplate: DEBUG
|
|
||||||
11
src/main/resources/bootstrap.yml
Normal file
11
src/main/resources/bootstrap.yml
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
spring:
|
||||||
|
application:
|
||||||
|
name: flagnote-service
|
||||||
|
cloud:
|
||||||
|
config:
|
||||||
|
name: flagnote-service
|
||||||
|
profile: prd
|
||||||
|
uri: http://flagnote-config-01:8080/flagnote-config,http://flagnote-config-02:8080/flagnote-config
|
||||||
|
config:
|
||||||
|
import: optional:configserver:http://flagnote-config-01:8080/,optional:configserver:http://flagnote-config-02:8080/
|
||||||
|
|
||||||
Reference in New Issue
Block a user