Skip to content

Commit

Permalink
Add quickstart for website. (#1035)
Browse files Browse the repository at this point in the history
  • Loading branch information
chickenlj authored Dec 26, 2023
1 parent 59f94b6 commit a4e670c
Show file tree
Hide file tree
Showing 20 changed files with 1,038 additions and 5 deletions.
10 changes: 6 additions & 4 deletions .licenserc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ header:
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand Down Expand Up @@ -75,8 +75,10 @@ header:
- '**/dubbo-samples-tengine/dubbo-samples-tengine-provider/src/main/resources/docker/sources.list'
- '**/.run/**'
- '**/*.js'
- '**/Dockerfile'
- '**/Dockerfile.jvm'
- '**/Dockerfile*'
- '**/*.xml'
- '**/*.properties'
- '**/*.yml'

comment: on-failure

Expand Down
2 changes: 2 additions & 0 deletions 11-quickstart/.mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.4/apache-maven-3.9.4-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
22 changes: 22 additions & 0 deletions 11-quickstart/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This is the demo Dockerfile for the generated template project, please change accordingly before building image from it.
# Run the following command to build image: docker build -f ./Dockerfile --build-arg APP_FILE=demo-0.0.1-SNAPSHOT.jar -t demo:latest .
FROM openjdk:17-jdk-alpine

# Set the working directory to /build
WORKDIR /build
COPY . /build

RUN chmod +x ./mvnw
RUN ./mvnw clean package -U

# JAR file will be specified by passing in a build time argument to docker build
ARG APP_FILE

# Remember to change the port according to the RPC protocol you select
EXPOSE 50051

# copy the JAR file into the root and rename
RUN cp ./target/${APP_FILE} app.jar

# Run java with the jar file when the container starts up
CMD ["java","-jar","app.jar"]
12 changes: 12 additions & 0 deletions 11-quickstart/HELP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Getting Started

### Reference Documentation
For further reference, please consider the following sections:

* [Official Apache Maven documentation](https://maven.apache.org/guides/index.html)
* [Spring Boot Maven Plugin Reference Guide](https://docs.spring.io/spring-boot/docs/3.1.2/maven-plugin/reference/html/)
* [Create an OCI image](https://docs.spring.io/spring-boot/docs/3.1.2/maven-plugin/reference/html/#build-image)
* [Dubbo Zookeeper registry configuration reference](https://dubbo.apache.org/zh-cn/overview/mannual/java-sdk/reference-manual/registry/zookeeper/)
* [Dubbo triple protocol reference](https://dubbo.apache.org/zh-cn/overview/mannual/java-sdk/reference-manual/protocol/triple/)
* [Dubbo Zookeeper registry configuration reference](https://docs.spring.io/spring-boot/docs/3.1.2/reference/htmlsingle/#web.servlet.spring-mvc.template-engines)

55 changes: 55 additions & 0 deletions 11-quickstart/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Getting Started
This project is generated by [start.dubbo.apache.org](https://start.dubbo.apache.org/) and used as the demonstration code of the quick-start on our official website [dubbo.apache.org](https://dubbo.apache.org/zh-cn/overview/mannual/java-sdk/quick-start/microservice/starter/).

Check more samples from other directories like [1-basic](../../1-basic), [2-advanced](../../2-advanced), etc.

## How to run

### Install dependencies
Step into '11-quickstart' directory, run the following command:

```shell
$ mvn clean install
```

This will install all the modules especially `quickstart-api` in the local maven repo.

### Run quick start demo
Enter `quickstart-service` directory:
```shell
$ cd 11-quickstart/quickstart-service
```

then, run the following command to start Dubbo process:
```shell
$ mvn compile exec:java -Dexec.mainClass="org.apache.dubbo.samples.quickstart.QuickStartApplication"
```

Run the following command to see server works as expected:
```shell
$ curl \
--header "Content-Type: application/json" \
--data '["Dubbo"]' \
http://localhost:50051/org.apache.dubbo.samples.quickstart.dubbo.api.DemoService/sayHello/
```

## Publish service definition
Publish the Dubbo service definition(java interface) in `quickstart-api` to maven repository so that consumers that need to call this service can import the definition by importing `quickstart-api` maven dependency in their pom.xml.

Enter directory `quickstart-api`
```shell
$ cd 11-quickstart/quickstart-api
$ mvn clean deploy
```

## Reference Documentation
For further reference, please consider the following sections:

* [Official Apache Maven documentation](https://maven.apache.org/guides/index.html)
* [Spring Boot Maven Plugin Reference Guide](https://docs.spring.io/spring-boot/docs/3.1.2/maven-plugin/reference/html/)
* [Create an OCI image](https://docs.spring.io/spring-boot/docs/3.1.2/maven-plugin/reference/html/#build-image)
* [Dubbo Zookeeper registry configuration reference](https://dubbo.apache.org/zh-cn/overview/mannual/java-sdk/reference-manual/registry/zookeeper/)
* [Dubbo triple protocol reference](https://dubbo.apache.org/zh-cn/overview/mannual/java-sdk/reference-manual/protocol/triple/)
* [Dubbo Zookeeper registry configuration reference](https://docs.spring.io/spring-boot/docs/3.1.2/reference/htmlsingle/#web.servlet.spring-mvc.template-engines)


Loading

0 comments on commit a4e670c

Please sign in to comment.