Skip to content

Commit

Permalink
support registry
Browse files Browse the repository at this point in the history
  • Loading branch information
robberphex committed May 4, 2022
1 parent 33f1285 commit edd9eb4
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 5 deletions.
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
FROM eclipse-temurin:11-jdk-alpine

LABEL org.opencontainers.image.source https://github.com/opensergo/example-opensergo-sca


RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories
RUN apk add curl vim iproute2 tcpdump

Expand Down
3 changes: 2 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/sh

mvn clean package -DskipTests
docker build . -t registry.cn-huhehaote.aliyuncs.com/luyanbo-msc/opensergo-sca:0.0.1-SNAPSHOT
docker build . -t ghcr.io/opensergo/example-opensergo-sca:main

8 changes: 7 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,18 @@
<version>1.44.1</version>
</dependency>

<dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-opensergo</artifactId>
<version>2021.0.1.1-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
<version>2021.0.1.1-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/example/springboot/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;

@SpringBootApplication
@EnableDiscoveryClient
public class Application {

public static void main(String[] args) {
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/com/example/springboot/HelloController.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
package com.example.springboot;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {

@Autowired(required = false)
private ServiceInstance serviceInstance;

@GetMapping("/index")
public String index() {
return "Greetings from Spring Boot!\n";
return "Greetings from Spring Boot!\n" + serviceInstance.getInstanceId() + "\n";
}

@GetMapping("/hello")
Expand Down
6 changes: 4 additions & 2 deletions src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ server:
spring:
application:
name: "example-spring-cloud"

management:
cloud:
nacos:
discovery:
server-addr: mse-xxxxx-p.nacos-ans.mse.aliyuncs.com:8848
endpoint:
info:
enabled: true
Expand Down

0 comments on commit edd9eb4

Please sign in to comment.