Pārlūkot izejas kodu

add docker

master
yedajiang44 pirms 1 gada
vecāks
revīzija
ce6ed8a10e
6 mainītis faili ar 165 papildinājumiem un 21 dzēšanām
  1. +37
    -0
      .vscode/launch.json
  2. +73
    -0
      .vscode/tasks.json
  3. +6
    -0
      Dockerfile
  4. +34
    -17
      README.md
  5. +15
    -0
      docker-compose.yml
  6. +0
    -4
      simples/pipeline.props

+ 37
- 0
.vscode/launch.json Parādīt failu

@@ -0,0 +1,37 @@
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/simples/JT808.Gateway.SimpleServer/bin/Debug/net8.0/JT808.Gateway.SimpleServer.dll",
"args": [],
"cwd": "${workspaceFolder}/simples/JT808.Gateway.SimpleServer",
"stopAtEntry": false,
// Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/Views"
},
"console": "internalConsole"
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
]
}

+ 73
- 0
.vscode/tasks.json Parādīt failu

@@ -0,0 +1,73 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"group": {
"kind": "build",
"isDefault": true
},
"args": [
"build",
"${workspaceFolder}/simples/JT808.Gateway.SimpleServer/JT808.Gateway.SimpleServer.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/simples/JT808.Gateway.SimpleServer/JT808.Gateway.SimpleServer.csproj",
"/p:Configuration=Release",
"/p:PublishDir=${workspaceFolder}/.output/linux-x64",
"/p:RuntimeIdentifier=linux-x64",
"/p:PublishSingleFile=true",
"/p:PublishTrimmed=true",
"/p:IncludeNativeLibrariesForSelfExtract=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "build docker",
"command": "dotnet",
"hide": true,
"type": "process",
"args": [
"publish",
"${workspaceFolder}/simples/JT808.Gateway.SimpleServer/JT808.Gateway.SimpleServer.csproj",
"/p:Configuration=Release",
"/p:PublishDir=${workspaceFolder}/.output/docker",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "build docker image",
"detail": "打包示例网关镜像",
"type": "shell",
"command": "docker compose build --no-cache",
"dependsOn": ["build docker"],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"${workspaceFolder}/simples/JT808.Gateway.SimpleServer/JT808.Gateway.SimpleServer.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
}
]
}

+ 6
- 0
Dockerfile Parādīt failu

@@ -0,0 +1,6 @@
FROM mcr.microsoft.com/dotnet/aspnet:8.0
WORKDIR /app
COPY .output/docker/ .
EXPOSE 80 808
ENV LANG=en_US.UTF-8 TZ=Asia/Shanghai
ENTRYPOINT ["dotnet", "JT808.Gateway.SimpleServer.dll"]

+ 34
- 17
README.md Parādīt failu

@@ -6,14 +6,14 @@

## 集成接口功能

| 接口名称 | 接口说明 | 使用场景 |
| :--------------------------- | :-------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |
| IJT808SessionProducer | 会话通知(在线/离线)数据生产接口 | 有些超长待机的设备,不会实时保持连接,那么通过平台下发的命令是无法到达的,这时候就需要设备一上线,就即时通知服务去处理,然后在即时的下发消息到设备。 |
| IJT808SessionConsumer | 会话通知(在线/离线)数据消费接口 | - |
| IJT808MsgProducer | 数据生产接口 | 网关将接收到的数据发送到队列 |
| IJT808MsgConsumer | 数据消费接口 | 将数据进行对应的消息业务处理(例:设备流量统计、第三方平台数据转发、消息日志等) |
| IJT808MsgReplyProducer | 应答数据生产接口 | 将生产的数据解析为对应的消息Id应答发送到队列 |
| IJT808MsgReplyConsumer | 应答数据消费接口 | 将接收到的应答数据下发给设备 |
| 接口名称 | 接口说明 | 使用场景 |
| :---------------------------- | :-------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |
| IJT808SessionProducer | 会话通知(在线/离线)数据生产接口 | 有些超长待机的设备,不会实时保持连接,那么通过平台下发的命令是无法到达的,这时候就需要设备一上线,就即时通知服务去处理,然后在即时的下发消息到设备。 |
| IJT808SessionConsumer | 会话通知(在线/离线)数据消费接口 | - |
| IJT808MsgProducer | 数据生产接口 | 网关将接收到的数据发送到队列 |
| IJT808MsgConsumer | 数据消费接口 | 将数据进行对应的消息业务处理(例:设备流量统计、第三方平台数据转发、消息日志等) |
| IJT808MsgReplyProducer | 应答数据生产接口 | 将生产的数据解析为对应的消息Id应答发送到队列 |
| IJT808MsgReplyConsumer | 应答数据消费接口 | 将接收到的应答数据下发给设备 |
| IJT808MsgReplyLoggingProducer | 网关应答数据日志生产接口 | 将网关能解析到直接能下发的数据发送到队列 |
| IJT808MsgReplyLoggingConsumer | 网关应答数据日志消费接口 | 将网关能解析到直接能下发的数据发送到日志系统 |

@@ -36,13 +36,13 @@ Pipeline分为两种方式使用,一种是使用队列的方式,一种是网

### Pipeline的NuGet安装

| Package Name | Version | Preview Version | Downloads |
| ------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- |
| Install-Package JT808.Gateway.Abstractions | ![JT808.Gateway.Abstractions](https://img.shields.io/nuget/v/JT808.Gateway.Abstractions.svg) | ![JT808.Gateway.Abstractions](https://img.shields.io/nuget/vpre/JT808.Gateway.Abstractions.svg) | ![JT808.Gateway.Abstractions](https://img.shields.io/nuget/dt/JT808.Gateway.Abstractions.svg) | ![JT808.Gateway.Abstractions](https://img.shields.io/nuget/dt/JT808.Gateway.Abstractions.svg) |
| Install-Package JT808.Gateway | ![JT808.Gateway](https://img.shields.io/nuget/v/JT808.Gateway.svg) | ![JT808.Gateway](https://img.shields.io/nuget/vpre/JT808.Gateway.svg) | ![JT808.Gateway](https://img.shields.io/nuget/dt/JT808.Gateway.svg) |
| Install-Package JT808.Gateway.WebApiClientTool | ![JT808.Gateway.WebApiClientTool](https://img.shields.io/nuget/v/JT808.Gateway.WebApiClientTool.svg) | ![JT808.Gateway.WebApiClientTool](https://img.shields.io/nuget/vpre/JT808.Gateway.WebApiClientTool.svg) | ![JT808.Gateway.WebApiClientTool](https://img.shields.io/nuget/dt/JT808.Gateway.WebApiClientTool.svg) |
| Install-Package JT808.Gateway.Client | ![JT808.Gateway.Client](https://img.shields.io/nuget/v/JT808.Gateway.Client.svg) | ![JT808.Gateway.Client](https://img.shields.io/nuget/vpre/JT808.Gateway.Client.svg) | ![JT808.Gateway.Client](https://img.shields.io/nuget/dt/JT808.Gateway.Client.svg) |
| Install-Package JT808.Gateway.Kafka | ![JT808.Gateway.Kafka](https://img.shields.io/nuget/v/JT808.Gateway.Kafka.svg) | ![JT808.Gateway.Kafka](https://img.shields.io/nuget/vpre/JT808.Gateway.Kafka.svg) | ![JT808.Gateway.MsgIdHandler](https://img.shields.io/nuget/dt/JT808.Gateway.MsgIdHandler.svg) |
| Package Name | Version | Preview Version | Downloads |
| ---------------------------------------------- | ---------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- |
| Install-Package JT808.Gateway.Abstractions | ![JT808.Gateway.Abstractions](https://img.shields.io/nuget/v/JT808.Gateway.Abstractions.svg) | ![JT808.Gateway.Abstractions](https://img.shields.io/nuget/vpre/JT808.Gateway.Abstractions.svg) | ![JT808.Gateway.Abstractions](https://img.shields.io/nuget/dt/JT808.Gateway.Abstractions.svg) | ![JT808.Gateway.Abstractions](https://img.shields.io/nuget/dt/JT808.Gateway.Abstractions.svg) |
| Install-Package JT808.Gateway | ![JT808.Gateway](https://img.shields.io/nuget/v/JT808.Gateway.svg) | ![JT808.Gateway](https://img.shields.io/nuget/vpre/JT808.Gateway.svg) | ![JT808.Gateway](https://img.shields.io/nuget/dt/JT808.Gateway.svg) |
| Install-Package JT808.Gateway.WebApiClientTool | ![JT808.Gateway.WebApiClientTool](https://img.shields.io/nuget/v/JT808.Gateway.WebApiClientTool.svg) | ![JT808.Gateway.WebApiClientTool](https://img.shields.io/nuget/vpre/JT808.Gateway.WebApiClientTool.svg) | ![JT808.Gateway.WebApiClientTool](https://img.shields.io/nuget/dt/JT808.Gateway.WebApiClientTool.svg) |
| Install-Package JT808.Gateway.Client | ![JT808.Gateway.Client](https://img.shields.io/nuget/v/JT808.Gateway.Client.svg) | ![JT808.Gateway.Client](https://img.shields.io/nuget/vpre/JT808.Gateway.Client.svg) | ![JT808.Gateway.Client](https://img.shields.io/nuget/dt/JT808.Gateway.Client.svg) |
| Install-Package JT808.Gateway.Kafka | ![JT808.Gateway.Kafka](https://img.shields.io/nuget/v/JT808.Gateway.Kafka.svg) | ![JT808.Gateway.Kafka](https://img.shields.io/nuget/vpre/JT808.Gateway.Kafka.svg) | ![JT808.Gateway.MsgIdHandler](https://img.shields.io/nuget/dt/JT808.Gateway.MsgIdHandler.svg) |

## 举个栗子

@@ -57,7 +57,7 @@ Pipeline分为两种方式使用,一种是使用队列的方式,一种是网
3.进入JT808.Gateway.SimpleClient项目下的Debug目录运行客户端

如图所示:
![demo3](https://github.com/SmallChi/JT808Gateway/blob/master/doc/img/demo3.png)
![demo3](doc/img/demo3.png)

#### 使用队列方式

@@ -75,7 +75,24 @@ Pipeline分为两种方式使用,一种是使用队列的方式,一种是网
> 注意:需要安装kafka和zookeeper

如图所示:
![demo4](https://github.com/SmallChi/JT808Gateway/blob/master/doc/img/demo4.png)
![demo4](doc/img/demo4.png)

## Docker

此处以`vscode`为例,使用`vscode`打开当前文件夹

打包镜像

>当前仅打包[`simples/JT808.Gateway.SimpleServer`](simples/JT808.Gateway.SimpleServer),可根据需求自行更改

- 按下`F1`按键
- 选择运行任务
- 选择打包示例网关镜像

运行容器
- 运行`docker compose up`

使用tcp工具或本项目中的示例项目测试本地`808`端口,

## 常见问题



+ 15
- 0
docker-compose.yml Parādīt failu

@@ -0,0 +1,15 @@
services:
gateway:
image: gateway-simple
build:
context: .
dockerfile: Dockerfile
privileged: true
container_name: gateway-simple
ports:
- 5000:80
- 808:808
logging:
driver: "json-file"
options:
max-size: "50m"

+ 0
- 4
simples/pipeline.props Parādīt failu

@@ -1,8 +1,4 @@
<Project>
<PropertyGroup Condition="'$(CompileConfig)' == 'Release'" >
<DebugType>none</DebugType>
<DebugSymbols>false</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\JT808.Gateway.Abstractions\JT808.Gateway.Abstractions.csproj" />
<ProjectReference Include="..\..\src\JT808.Gateway\JT808.Gateway.csproj"/>


Notiek ielāde…
Atcelt
Saglabāt