update compose
This commit is contained in:
parent
4da7049cb5
commit
c778bd5291
|
@ -1,9 +1,9 @@
|
||||||
version: '3.9'
|
version: '3.9'
|
||||||
name: demo01
|
name: demo01-jib
|
||||||
services:
|
services:
|
||||||
demo01:
|
demo01-jib:
|
||||||
image: docker.io/library/demo01:1.0
|
image: svn.youshengyun.com:9924/demo01-jib:1.0
|
||||||
container_name: demo01
|
container_name: demo01-jib
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
extra_hosts:
|
extra_hosts:
|
||||||
- "host.docker.internal:host-gateway"
|
- "host.docker.internal:host-gateway"
|
||||||
|
@ -11,6 +11,8 @@ services:
|
||||||
- y9-share-net
|
- y9-share-net
|
||||||
ports:
|
ports:
|
||||||
- "7055:7055"
|
- "7055:7055"
|
||||||
|
environment:
|
||||||
|
'server.servlet.context-path': '/demo01'
|
||||||
labels:
|
labels:
|
||||||
- "traefik.enable=true"
|
- "traefik.enable=true"
|
||||||
- "traefik.http.routers.demo01.entrypoints=web"
|
- "traefik.http.routers.demo01.entrypoints=web"
|
|
@ -0,0 +1,26 @@
|
||||||
|
version: '3.9'
|
||||||
|
name: demo01-jvm
|
||||||
|
services:
|
||||||
|
demo01-jvm:
|
||||||
|
image: svn.youshengyun.com:9924/demo01-jvm:1.0
|
||||||
|
container_name: demo01-jvm
|
||||||
|
restart: unless-stopped
|
||||||
|
extra_hosts:
|
||||||
|
- "host.docker.internal:host-gateway"
|
||||||
|
networks:
|
||||||
|
- y9-share-net
|
||||||
|
ports:
|
||||||
|
- "17055:7055"
|
||||||
|
environment:
|
||||||
|
'server.servlet.context-path': '/demo02'
|
||||||
|
labels:
|
||||||
|
- "traefik.enable=true"
|
||||||
|
- "traefik.http.routers.demo02.entrypoints=web"
|
||||||
|
- "traefik.http.routers.demo02.rule=PathPrefix(`/demo02`)"
|
||||||
|
#- "traefik.http.services.demo01.loadbalancer.server.scheme=http"
|
||||||
|
#- "traefik.http.services.demo01.loadbalancer.server.port=7055"
|
||||||
|
#- "traefik.docker.network=y9-share-net"
|
||||||
|
|
||||||
|
networks:
|
||||||
|
y9-share-net:
|
||||||
|
external: true
|
|
@ -0,0 +1,26 @@
|
||||||
|
version: '3.9'
|
||||||
|
name: demo01-native
|
||||||
|
services:
|
||||||
|
demo01-native:
|
||||||
|
image: svn.youshengyun.com:9924/demo01-native:1.0
|
||||||
|
container_name: demo01-native
|
||||||
|
restart: unless-stopped
|
||||||
|
extra_hosts:
|
||||||
|
- "host.docker.internal:host-gateway"
|
||||||
|
networks:
|
||||||
|
- y9-share-net
|
||||||
|
ports:
|
||||||
|
- "27055:7055"
|
||||||
|
environment:
|
||||||
|
'server.servlet.context-path': '/demo03'
|
||||||
|
labels:
|
||||||
|
- "traefik.enable=true"
|
||||||
|
- "traefik.http.routers.demo03.entrypoints=web"
|
||||||
|
- "traefik.http.routers.demo03.rule=PathPrefix(`/demo03`)"
|
||||||
|
#- "traefik.http.services.demo01.loadbalancer.server.scheme=http"
|
||||||
|
#- "traefik.http.services.demo01.loadbalancer.server.port=7055"
|
||||||
|
#- "traefik.docker.network=y9-share-net"
|
||||||
|
|
||||||
|
networks:
|
||||||
|
y9-share-net:
|
||||||
|
external: true
|
62
pom.xml
62
pom.xml
|
@ -21,11 +21,6 @@
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
|
||||||
<groupId>com.ecwid.consul</groupId>
|
|
||||||
<artifactId>consul-api</artifactId>
|
|
||||||
<version>1.4.5</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-dependencies</artifactId>
|
<artifactId>spring-cloud-dependencies</artifactId>
|
||||||
|
@ -89,6 +84,7 @@
|
||||||
<groupId>org.graalvm.buildtools</groupId>
|
<groupId>org.graalvm.buildtools</groupId>
|
||||||
<artifactId>native-maven-plugin</artifactId>
|
<artifactId>native-maven-plugin</artifactId>
|
||||||
</plugin>
|
</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>
|
||||||
|
@ -99,12 +95,60 @@
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
</exclude>
|
</exclude>
|
||||||
</excludes>
|
</excludes>
|
||||||
|
<mainClass>net.risesoft.demo.Demo01Application</mainClass>
|
||||||
|
<image>
|
||||||
|
<env>
|
||||||
|
<BP_NATIVE_IMAGE>false</BP_NATIVE_IMAGE>
|
||||||
|
<BP_JVM_VERSION>17</BP_JVM_VERSION>
|
||||||
|
</env>
|
||||||
|
<name>svn.youshengyun.com:9923/${project.artifactId}-jvm:${project.version}</name>
|
||||||
|
<publish>true</publish>
|
||||||
|
</image>
|
||||||
|
<docker>
|
||||||
|
<publishRegistry>
|
||||||
|
<username>publisher</username>
|
||||||
|
<password>83204585</password>
|
||||||
|
</publishRegistry>
|
||||||
|
</docker>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<profiles>
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>jib</id>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>com.google.cloud.tools</groupId>
|
||||||
|
<artifactId>jib-maven-plugin</artifactId>
|
||||||
|
<version>3.4.0</version>
|
||||||
|
<configuration>
|
||||||
|
<skip>false</skip>
|
||||||
|
<to>
|
||||||
|
<image>svn.youshengyun.com:9923/${project.artifactId}-jib</image>
|
||||||
|
<tags>
|
||||||
|
<tag>${project.version}</tag>
|
||||||
|
</tags>
|
||||||
|
<auth>
|
||||||
|
<username>publisher</username>
|
||||||
|
<password>83204585</password>
|
||||||
|
</auth>
|
||||||
|
</to>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>install</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>build</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</profile>
|
||||||
<profile>
|
<profile>
|
||||||
<id>native</id>
|
<id>native</id>
|
||||||
<build>
|
<build>
|
||||||
|
@ -135,7 +179,15 @@
|
||||||
<BP_JVM_VERSION>17.0.9</BP_JVM_VERSION>
|
<BP_JVM_VERSION>17.0.9</BP_JVM_VERSION>
|
||||||
<BP_NATIVE_IMAGE_BUILD_ARGUMENTS>--enable-preview</BP_NATIVE_IMAGE_BUILD_ARGUMENTS>
|
<BP_NATIVE_IMAGE_BUILD_ARGUMENTS>--enable-preview</BP_NATIVE_IMAGE_BUILD_ARGUMENTS>
|
||||||
</env>
|
</env>
|
||||||
|
<name>svn.youshengyun.com:9923/${project.artifactId}-native:${project.version}</name>
|
||||||
|
<publish>true</publish>
|
||||||
</image>
|
</image>
|
||||||
|
<docker>
|
||||||
|
<publishRegistry>
|
||||||
|
<username>publisher</username>
|
||||||
|
<password>83204585</password>
|
||||||
|
</publishRegistry>
|
||||||
|
</docker>
|
||||||
</configuration>
|
</configuration>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
|
|
10
readme.txt
10
readme.txt
|
@ -1,10 +1,16 @@
|
||||||
|
./mvnw.cmd clean install -Pjib -Dmaven.test.skip=true
|
||||||
|
./mvnw.cmd clean spring-boot:build-image -Dmaven.test.skip=true
|
||||||
./mvnw.cmd clean spring-boot:build-image -Pnative -Dmaven.test.skip=true
|
./mvnw.cmd clean spring-boot:build-image -Pnative -Dmaven.test.skip=true
|
||||||
|
|
||||||
docker image ls
|
docker image ls
|
||||||
|
|
||||||
docker run --name demo01 --net y9-share-net -ti -p 7055:7055 demo01:1.0
|
docker run --name demo01-jib --net y9-share-net -ti -p 7055:7055 svn.youshengyun.com:9924/demo01-jib:1.0
|
||||||
|
docker run --name demo01-jvm --net y9-share-net -ti -p 17055:7055 svn.youshengyun.com:9924/demo01-jvm:1.0
|
||||||
|
docker run --name demo01-native --net y9-share-net -ti -p 27055:7055 svn.youshengyun.com:9924/demo01-native:1.0
|
||||||
|
|
||||||
docker compose -f compose-demo01.yml up -d
|
docker compose -f compose-demo01-jib.yml up -d
|
||||||
|
docker compose -f compose-demo01-jvm.yml up -d
|
||||||
|
docker compose -f compose-demo01-native.yml up -d
|
||||||
|
|
||||||
#最好在x64 Native Tools Command Prompt for VS 2022中打开
|
#最好在x64 Native Tools Command Prompt for VS 2022中打开
|
||||||
./mvnw.cmd native:compile -Pnative
|
./mvnw.cmd native:compile -Pnative
|
|
@ -1,11 +1,13 @@
|
||||||
package net.risesoft.demo.controller;
|
package net.risesoft.demo.controller;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import net.risesoft.demo.entity.User;
|
import net.risesoft.demo.entity.User;
|
||||||
import net.risesoft.demo.repository.UserRepository;
|
import net.risesoft.demo.repository.UserRepository;
|
||||||
|
|
||||||
|
@ -20,8 +22,17 @@ public class UserController {
|
||||||
this.userRepository = userRepository;
|
this.userRepository = userRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping({"", "/", "/api/users"})
|
@GetMapping({"", "/"})
|
||||||
public List<User> findAll(){
|
public List<String> hosts(HttpServletRequest request){
|
||||||
|
List<String> list = new ArrayList<String>();
|
||||||
|
list.add("request.getServerName()=" + request.getServerName());
|
||||||
|
list.add("request.getLocalAddr() =" + request.getLocalAddr());
|
||||||
|
list.add("request.getLocalAddr() =" + request.getLocalName());
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping({"/api/users"})
|
||||||
|
public List<User> users(){
|
||||||
return userRepository.findAll();
|
return userRepository.findAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue