generated from QubitPi/jersey-webservice-template
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add production deployment * update
- Loading branch information
Showing
3 changed files
with
344 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
--- | ||
sidebar_position: 5 | ||
title: Deployment | ||
description: Astraios deployment guide | ||
--- | ||
|
||
[//]: # (Copyright 2024 Paion Data) | ||
|
||
[//]: # (Licensed 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.) | ||
[//]: # (See the License for the specific language governing permissions and) | ||
[//]: # (limitations under the License.) | ||
|
||
This section discusses deploying [Astraios] in production. | ||
|
||
Prepare for Production Development | ||
---------------------------------- | ||
|
||
### Installing Java (on Ubuntu) | ||
|
||
```bash | ||
sudo apt update | ||
sudo apt install openjdk-17-jdk | ||
``` | ||
|
||
At the end of the last command prompt, something like the below will show up: | ||
|
||
```bash | ||
The following additional packages will be installed: | ||
... | ||
Suggested packages: | ||
... | ||
The following NEW packages will be installed: | ||
... | ||
Need to get 170 MB of archives. | ||
After this operation, 877 MB of additional disk space will be used. | ||
Do you want to continue? [Y/n] | ||
``` | ||
|
||
Enter `Y` to complete the installation. | ||
|
||
::: | ||
|
||
If we see something similar after typing the command with the version flag below we're good to go | ||
|
||
```bash | ||
$ java -version | ||
openjdk version "17.0.11" 2024-04-16 | ||
OpenJDK Runtime Environment (build 17.0.11+9-Ubuntu-120.04.2) | ||
OpenJDK 64-Bit Server VM (build 17.0.11+9-Ubuntu-120.04.2, mixed mode, sharing) | ||
``` | ||
|
||
### Installing Maven | ||
|
||
```bash | ||
sudo apt install maven | ||
``` | ||
|
||
At the end of the last command prompt, something like the below will show up: | ||
|
||
```bash | ||
The following additional packages will be installed: | ||
... | ||
Suggested packages: | ||
... | ||
The following NEW packages will be installed: | ||
... | ||
Need to get 9,657 kB of archives. | ||
After this operation, 12.6 MB of additional disk space will be used. | ||
Do you want to continue? [Y/n] | ||
``` | ||
|
||
Enter `Y` to complete the installation. | ||
|
||
::: | ||
|
||
If we see something similar after typing the command with the version flag below we're good to go | ||
|
||
```bash | ||
$ mvn -version | ||
Apache Maven 3.6.3 | ||
Maven home: /usr/share/maven | ||
Java version: 17.0.11, vendor: Ubuntu, runtime: /usr/lib/jvm/java-17-openjdk-amd64 | ||
Default locale: en_US, platform encoding: UTF-8 | ||
OS name: "linux", version: "5.4.0-182-generic", arch: "amd64", family: "unix" | ||
``` | ||
|
||
In the example, Maven is obviously using the correct JDK, so there is no need to set the JAVA_HOME environment variable | ||
extra. However, if you want to explicitly set JAVA_HOME, or in some cases (for example, when there are multiple JDK | ||
installations) make sure Maven always uses a specific JDK 17, You can add the following lines to your shell | ||
configuration file (such as.bashrc,.zshrc, or.profile) : | ||
|
||
```bash | ||
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64 | ||
``` | ||
|
||
### Loading Data Models | ||
|
||
```bash | ||
git clone git@github.com:paion-data/astraios-data-models-example.git | ||
cd astraios-data-models-example | ||
mvn clean install | ||
``` | ||
|
||
Now that we have the model installed locally, we need to get astraios to load the model through the maven configuration | ||
file, add the following configuration information via **~/.m2/settings.xml** ~/.m2/settings.xml: | ||
|
||
```xml | ||
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 | ||
http://maven.apache.org/xsd/settings-1.0.0.xsd"> | ||
|
||
<profiles> | ||
<profile> | ||
<id>astraios-data-models</id> | ||
<properties> | ||
<model.package.jar.group.id>com.paiondata</model.package.jar.group.id> | ||
<model.package.jar.artifact.id>astraios-data-models-example</model.package.jar.artifact.id> | ||
<model.package.jar.version>1.0.0</model.package.jar.version> | ||
</properties> | ||
</profile> | ||
</profiles> | ||
|
||
<activeProfiles> | ||
<activeProfile>astraios-data-models</activeProfile> | ||
</activeProfiles> | ||
</settings> | ||
``` | ||
|
||
### Packaging Astraios | ||
|
||
```bash | ||
git clone git@github.com:paion-data/astraios.git | ||
export MODEL_PACKAGE_NAME=com.paiondata.astraios.data.models | ||
export DB_USER=YOUR_DB_USER | ||
export DB_PASSWORD=YOUR_DB_PASSWORD | ||
export DB_URL=YOUR_DB_URL | ||
export DB_DRIVER=YOUR_DB_DRIVER | ||
export DB_DIALECT=YOUR_DB_DIALECT | ||
mvn clean package | ||
``` | ||
|
||
[Astraios] is built on [Springboot](https://spring.io/projects/spring-boot) and has a built-in web container, which we | ||
used maven to package into a jar file. | ||
|
||
### Running the JAR Package | ||
|
||
```bash | ||
java -jar target/astraios-1.0-SNAPSHOT.jar | ||
``` | ||
|
||
The webservice will run on port **8080**, and you will be able to see the data you inserted. | ||
|
||
[Astraios]: https://paion-data.github.io/astraios/ |
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
159 changes: 159 additions & 0 deletions
159
docs/i18n/zh-cn/docusaurus-plugin-content-docs/current/deployment.md
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,159 @@ | ||
--- | ||
sidebar_position: 5 | ||
title: 部署 | ||
description: Astraios 部署指南 | ||
--- | ||
|
||
[//]: # (Copyright 2024 Paion Data) | ||
|
||
[//]: # (Licensed 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.) | ||
[//]: # (See the License for the specific language governing permissions and) | ||
[//]: # (limitations under the License.) | ||
|
||
本节讨论如何在生产环境中部署[Astraios]。 | ||
|
||
准备在生产环境上开发 | ||
----------------- | ||
|
||
### 安装Java(在Ubuntu上) | ||
|
||
```bash | ||
sudo apt update | ||
sudo apt install openjdk-17-jdk | ||
``` | ||
|
||
在最后一个命令提示符的末尾,将显示如下内容: | ||
|
||
```bash | ||
The following additional packages will be installed: | ||
... | ||
Suggested packages: | ||
... | ||
The following NEW packages will be installed: | ||
... | ||
Need to get 170 MB of archives. | ||
After this operation, 877 MB of additional disk space will be used. | ||
Do you want to continue? [Y/n] | ||
``` | ||
|
||
输入`Y`完成安装。 | ||
|
||
::: | ||
|
||
如果在输入查看版本的命令后看到类似内容,则表示一切正常 | ||
|
||
```bash | ||
$ java -version | ||
openjdk version "17.0.11" 2024-04-16 | ||
OpenJDK Runtime Environment (build 17.0.11+9-Ubuntu-120.04.2) | ||
OpenJDK 64-Bit Server VM (build 17.0.11+9-Ubuntu-120.04.2, mixed mode, sharing) | ||
``` | ||
|
||
### 安装Maven | ||
|
||
```bash | ||
sudo apt install maven | ||
``` | ||
|
||
在最后一个命令提示符的末尾,将显示如下内容: | ||
|
||
```bash | ||
The following additional packages will be installed: | ||
... | ||
Suggested packages: | ||
... | ||
The following NEW packages will be installed: | ||
... | ||
Need to get 9,657 kB of archives. | ||
After this operation, 12.6 MB of additional disk space will be used. | ||
Do you want to continue? [Y/n] | ||
``` | ||
|
||
输入`Y`完成安装。 | ||
|
||
::: | ||
|
||
如果在输入查看版本的命令后看到类似内容,则表示一切正常 | ||
|
||
```bash | ||
$ mvn -version | ||
Apache Maven 3.6.3 | ||
Maven home: /usr/share/maven | ||
Java version: 17.0.11, vendor: Ubuntu, runtime: /usr/lib/jvm/java-17-openjdk-amd64 | ||
Default locale: en_US, platform encoding: UTF-8 | ||
OS name: "linux", version: "5.4.0-182-generic", arch: "amd64", family: "unix" | ||
``` | ||
|
||
在这个的例子中,Maven 显然正在使用正确的 JDK,因此不需要额外设置 JAVA_HOME 环境变量。然而,如果你希望明确设置 JAVA_HOME,或者在某些情况下 | ||
(例如,当有多个 JDK 安装时)确保 Maven 总是使用特定的 JDK 17,你可以在你的 shell 配置文件(如 .bashrc, .zshrc 或 .profile)中添加以 | ||
下行: | ||
|
||
```bash | ||
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64 | ||
``` | ||
|
||
### 加载数据模型 | ||
|
||
```bash | ||
git clone git@github.com:paion-data/astraios-data-models-example.git | ||
cd astraios-data-models-example | ||
mvn clean install | ||
``` | ||
|
||
现在我们已经将model安装到了本地,我们需要让astraios 通过maven配置文件来读取安装的model,在 **~/.m2/settings.xml** 下添加以下配置信息: | ||
|
||
```xml | ||
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 | ||
http://maven.apache.org/xsd/settings-1.0.0.xsd"> | ||
|
||
<profiles> | ||
<profile> | ||
<id>astraios-data-models</id> | ||
<properties> | ||
<model.package.jar.group.id>com.paiondata</model.package.jar.group.id> | ||
<model.package.jar.artifact.id>astraios-data-models-example</model.package.jar.artifact.id> | ||
<model.package.jar.version>1.0.0</model.package.jar.version> | ||
</properties> | ||
</profile> | ||
</profiles> | ||
|
||
<activeProfiles> | ||
<activeProfile>astraios-data-models</activeProfile> | ||
</activeProfiles> | ||
</settings> | ||
``` | ||
|
||
### 打包Astraios | ||
|
||
```bash | ||
git clone git@github.com:paion-data/astraios.git | ||
export MODEL_PACKAGE_NAME=com.paiondata.astraios.data.models | ||
export DB_USER=YOUR_DB_USER | ||
export DB_PASSWORD=YOUR_DB_PASSWORD | ||
export DB_URL=YOUR_DB_URL | ||
export DB_DRIVER=YOUR_DB_DRIVER | ||
export DB_DIALECT=YOUR_DB_DIALECT | ||
mvn clean package | ||
``` | ||
|
||
[Astraios]由[Springboot](https://spring.io/projects/spring-boot)构建,并具有内置Web容器,我们使用maven将其打包成jar文件。 | ||
|
||
### 运行JAR包 | ||
|
||
```bash | ||
java -jar target/astraios-1.0-SNAPSHOT.jar | ||
``` | ||
|
||
服务将在端口**8080**上运行,您将能够看到您插入的数据。 | ||
|
||
[Astraios]: https://paion-data.github.io/astraios/ |