Просмотр исходного кода

Merge pull request #43 from paspo/gh_actions

added build workflow
RustDesk лет назад: 3
Родитель
Сommit
6c6dba5a8a

+ 294 - 0
.github/workflows/build.yaml

@@ -0,0 +1,294 @@
1
+name: build
2
+
3
+# ------------- NOTE
4
+# please setup some secrets before running this workflow:
5
+# DOCKER_IMAGE should be the target image name on docker hub (e.g. "rustdesk/rustdesk-server-s6" )
6
+# DOCKER_IMAGE_CLASSIC should be the target image name on docker hub for the old build (e.g. "rustdesk/rustdesk-server" )
7
+# DOCKER_USERNAME is the username you normally use to login at https://hub.docker.com/
8
+# DOCKER_PASSWORD is a token you should create under "account settings / security" with read/write access
9
+
10
+on:
11
+  workflow_dispatch:
12
+  push:
13
+    tags:
14
+      - 'v[0-9]+.[0-9]+.[0-9]+'
15
+      - '[0-9]+.[0-9]+.[0-9]+'
16
+
17
+env:
18
+  CARGO_TERM_COLOR: always
19
+  LATEST_TAG: latest
20
+  
21
+jobs:
22
+
23
+  # binary build
24
+  build:
25
+
26
+    name: Build - ${{ matrix.job.name }}
27
+    runs-on: ubuntu-22.04
28
+    strategy:
29
+      fail-fast: false
30
+      matrix:
31
+        job:
32
+          - { name: "amd64",   target: "x86_64-unknown-linux-musl" }
33
+          - { name: "arm64v8", target: "aarch64-unknown-linux-musl" }
34
+          - { name: "armv7",   target: "armv7-unknown-linux-musleabihf" }
35
+          - { name: "i386",    target: "i686-unknown-linux-musl" }
36
+
37
+    steps:
38
+      
39
+      - name: Checkout
40
+        uses: actions/checkout@v3
41
+
42
+      - name: Install toolchain
43
+        uses: actions-rs/toolchain@v1
44
+        with:
45
+          toolchain: nightly
46
+          override: true
47
+          default: true
48
+          target: ${{ matrix.job.target }}
49
+
50
+      - name: Build
51
+        uses: actions-rs/cargo@v1
52
+        with:
53
+          command: build
54
+          args: --release --all-features --target=${{ matrix.job.target }}
55
+          use-cross: true  
56
+
57
+      # - name: Run tests
58
+      #   run: cargo test --verbose
59
+
60
+      - name: Publish Artifacts
61
+        uses: actions/upload-artifact@v3
62
+        with:
63
+          name: binaries-${{ matrix.job.name }}
64
+          path: |
65
+            target/${{ matrix.job.target }}/release/hbbr
66
+            target/${{ matrix.job.target }}/release/hbbs
67
+          if-no-files-found: error
68
+
69
+  # github (draft) release with all binaries
70
+  release:
71
+
72
+    name: Github release
73
+    needs: build
74
+    runs-on: ubuntu-22.04
75
+
76
+    steps:
77
+
78
+      - name: Download binaries (amd64)
79
+        uses: actions/download-artifact@v3
80
+        with:
81
+          name: binaries-amd64
82
+          path: amd64
83
+
84
+      - name: Download binaries (arm64v8)
85
+        uses: actions/download-artifact@v3
86
+        with:
87
+          name: binaries-arm64v8
88
+          path: arm64v8
89
+
90
+      - name: Download binaries (armv7)
91
+        uses: actions/download-artifact@v3
92
+        with:
93
+          name: binaries-armv7
94
+          path: armv7
95
+
96
+      - name: Download binaries (i386)
97
+        uses: actions/download-artifact@v3
98
+        with:
99
+          name: binaries-i386
100
+          path: i386
101
+
102
+      - name: Rename files
103
+        run: for arch in amd64 arm64v8 armv7 i386 ; do for b in hbbr hbbs ; do mv -v ${arch}/${b} ${arch}/${b}-${arch} ; done ; done 
104
+
105
+      - name: Create Release
106
+        uses: softprops/action-gh-release@v1
107
+        with:
108
+          draft: true
109
+          files: |
110
+            amd64/*
111
+            arm64v8/*
112
+            armv7/*
113
+            i386/*
114
+            
115
+  # docker build and push of single-arch images
116
+  docker:
117
+
118
+    name: Docker push - ${{ matrix.job.name }}
119
+    needs: build
120
+    runs-on: ubuntu-22.04
121
+    strategy:
122
+      fail-fast: false
123
+      matrix:
124
+        job:
125
+          - { name: "amd64",   docker_platform: "linux/amd64" }
126
+          - { name: "arm64v8", docker_platform: "linux/arm64" }
127
+          - { name: "armv7",   docker_platform: "linux/arm/v7" }
128
+          - { name: "i386",    docker_platform: "linux/386" }
129
+
130
+    steps:
131
+
132
+      - name: Checkout
133
+        uses: actions/checkout@v3
134
+        
135
+      - name: Download binaries
136
+        uses: actions/download-artifact@v3
137
+        with:
138
+          name: binaries-${{ matrix.job.name }}
139
+          path: docker/rootfs/usr/bin
140
+
141
+      - name: Make binaries executable
142
+        run: chmod -v a+x docker/rootfs/usr/bin/*
143
+
144
+      - name: Set up QEMU
145
+        uses: docker/setup-qemu-action@v2
146
+      
147
+      - name: Set up Docker Buildx
148
+        uses: docker/setup-buildx-action@v2
149
+
150
+      - name: Log in to Docker Hub
151
+        if: github.event_name != 'pull_request'
152
+        uses: docker/login-action@v2
153
+        with:
154
+          username: ${{ secrets.DOCKER_USERNAME }}
155
+          password: ${{ secrets.DOCKER_PASSWORD }}
156
+        
157
+      - name: Extract metadata (tags, labels) for Docker
158
+        id: meta
159
+        uses: docker/metadata-action@v4
160
+        with:
161
+          images: registry.hub.docker.com/${{ secrets.DOCKER_IMAGE }}
162
+
163
+      - name: Get git tag
164
+        id: vars
165
+        run: |
166
+          T=${GITHUB_REF#refs/*/}
167
+          M=${T%%.*}
168
+          echo "GIT_TAG=$T" >> $GITHUB_ENV
169
+          echo "MAJOR_TAG=$M" >> $GITHUB_ENV
170
+
171
+      - name: Build and push Docker image
172
+        uses: docker/build-push-action@v3
173
+        with:
174
+          context: "./docker"
175
+          platforms: ${{ matrix.job.docker_platform }}
176
+          push: true
177
+          tags: |
178
+            ${{ secrets.DOCKER_IMAGE }}:${{ env.LATEST_TAG }}-${{ matrix.job.name }}
179
+            ${{ secrets.DOCKER_IMAGE }}:${{ env.GIT_TAG }}-${{ matrix.job.name }}
180
+            ${{ secrets.DOCKER_IMAGE }}:${{ env.MAJOR_TAG }}-${{ matrix.job.name }}
181
+          labels: ${{ steps.meta.outputs.labels }}
182
+
183
+  # docker build and push of multiarch images
184
+  docker-manifest:
185
+
186
+    name: Docker manifest
187
+    needs: docker
188
+    runs-on: ubuntu-22.04
189
+
190
+    steps:
191
+
192
+      - name: Log in to Docker Hub
193
+        if: github.event_name != 'pull_request'
194
+        uses: docker/login-action@v2
195
+        with:
196
+          username: ${{ secrets.DOCKER_USERNAME }}
197
+          password: ${{ secrets.DOCKER_PASSWORD }}
198
+
199
+      - name: Get git tag
200
+        id: vars
201
+        run: |
202
+          T=${GITHUB_REF#refs/*/}
203
+          M=${T%%.*}
204
+          echo "GIT_TAG=$T" >> $GITHUB_ENV
205
+          echo "MAJOR_TAG=$M" >> $GITHUB_ENV
206
+
207
+      # manifest for :1.2.3 tag
208
+      - name: Create and push manifest
209
+        uses: Noelware/docker-manifest-action@master
210
+        with:
211
+          base-image: ${{ secrets.DOCKER_IMAGE }}:${{ env.GIT_TAG }}
212
+          extra-images: ${{ secrets.DOCKER_IMAGE }}:${{ env.GIT_TAG }}-amd64,${{ secrets.DOCKER_IMAGE }}:${{ env.GIT_TAG }}-arm64v8,${{ secrets.DOCKER_IMAGE }}:${{ env.GIT_TAG }}-armv7,${{ secrets.DOCKER_IMAGE }}:${{ env.GIT_TAG }}-i386
213
+          push: true
214
+
215
+      # manifest for :1 tag (major release)
216
+      - name: Create and push manifest
217
+        uses: Noelware/docker-manifest-action@master
218
+        with:
219
+          base-image: ${{ secrets.DOCKER_IMAGE }}:${{ env.MAJOR_TAG }}
220
+          extra-images: ${{ secrets.DOCKER_IMAGE }}:${{ env.MAJOR_TAG }}-amd64,${{ secrets.DOCKER_IMAGE }}:${{ env.MAJOR_TAG }}-arm64v8,${{ secrets.DOCKER_IMAGE }}:${{ env.MAJOR_TAG }}-armv7,${{ secrets.DOCKER_IMAGE }}:${{ env.MAJOR_TAG }}-i386
221
+          push: true
222
+
223
+      # manifest for :latest tag
224
+      - name: Create and push manifest
225
+        uses: Noelware/docker-manifest-action@master
226
+        with:
227
+          base-image: ${{ secrets.DOCKER_IMAGE }}:${{ github.ref_name }}
228
+          extra-images: ${{ secrets.DOCKER_IMAGE }}:${{ github.ref_name }}-amd64,${{ secrets.DOCKER_IMAGE }}:${{ github.ref_name }}-arm64v8,${{ secrets.DOCKER_IMAGE }}:${{ github.ref_name }}-armv7,${{ secrets.DOCKER_IMAGE }}:${{ github.ref_name }}-i386
229
+          push: true
230
+
231
+      - name: Create and push manifest
232
+        uses: Noelware/docker-manifest-action@master
233
+        with:
234
+          base-image: ${{ secrets.DOCKER_IMAGE }}:${{ env.LATEST_TAG }}
235
+          extra-images: ${{ secrets.DOCKER_IMAGE }}:${{ env.LATEST_TAG }}-amd64,${{ secrets.DOCKER_IMAGE }}:${{ env.LATEST_TAG }}-arm64v8,${{ secrets.DOCKER_IMAGE }}:${{ env.LATEST_TAG }}-armv7,${{ secrets.DOCKER_IMAGE }}:${{ env.LATEST_TAG }}-i386
236
+          push: true
237
+
238
+
239
+            
240
+  # docker build and push of classic images
241
+  docker-classic:
242
+
243
+    name: Docker push classic - ${{ matrix.job.name }}
244
+    needs: build
245
+    runs-on: ubuntu-22.04
246
+    strategy:
247
+      fail-fast: false
248
+      matrix:
249
+        job:
250
+          - { name: "amd64",   docker_platform: "linux/amd64", tag: "latest" }
251
+          - { name: "arm64v8", docker_platform: "linux/arm64", tag: "latest-arm64v8" }
252
+
253
+    steps:
254
+
255
+      - name: Checkout
256
+        uses: actions/checkout@v3
257
+        
258
+      - name: Download binaries
259
+        uses: actions/download-artifact@v3
260
+        with:
261
+          name: binaries-${{ matrix.job.name }}
262
+          path: docker-classic/
263
+
264
+      - name: Make binaries executable
265
+        run: chmod -v a+x docker-classic/hbb*
266
+
267
+      - name: Set up QEMU
268
+        uses: docker/setup-qemu-action@v2
269
+      
270
+      - name: Set up Docker Buildx
271
+        uses: docker/setup-buildx-action@v2
272
+
273
+      - name: Log in to Docker Hub
274
+        if: github.event_name != 'pull_request'
275
+        uses: docker/login-action@v2
276
+        with:
277
+          username: ${{ secrets.DOCKER_USERNAME }}
278
+          password: ${{ secrets.DOCKER_PASSWORD }}
279
+        
280
+      - name: Extract metadata (tags, labels) for Docker
281
+        id: meta
282
+        uses: docker/metadata-action@v4
283
+        with:
284
+          images: registry.hub.docker.com/${{ secrets.DOCKER_IMAGE_CLASSIC }}
285
+
286
+      - name: Build and push Docker image
287
+        uses: docker/build-push-action@v3
288
+        with:
289
+          context: "./docker-classic"
290
+          platforms: ${{ matrix.job.docker_platform }}
291
+          push: true
292
+          tags: |
293
+            ${{ secrets.DOCKER_IMAGE_CLASSIC }}:${{ matrix.job.tag }}
294
+          labels: ${{ steps.meta.outputs.labels }}

+ 141 - 5
README.md

@@ -1,25 +1,161 @@
1 1
 # RustDesk Server Program
2 2
 
3
+[![build](https://github.com/rustdesk/rustdesk-server/actions/workflows/build.yaml/badge.svg)](https://github.com/rustdesk/rustdesk-server/actions/workflows/build.yaml)
4
+
3 5
 [**Download**](https://github.com/rustdesk/rustdesk-server/releases)
4 6
 
5
-[**Manual**](https://rustdesk.com/docs/en/self-host/) 
7
+[**Manual**](https://rustdesk.com/docs/en/self-host/)
6 8
 
7 9
 [**FAQ**](https://github.com/rustdesk/rustdesk/wiki/FAQ)
8 10
 
9 11
 Self-host your own RustDesk server, it is free and open source.
10 12
 
13
+## How to build manually
14
+
11 15
 ```bash
12 16
 cargo build --release
13 17
 ```
14 18
 
15 19
 Two executables will be generated in target/release.
16
-  - hbbs - RustDesk ID/Rendezvous server
17
-  - hbbr - RustDesk relay server
20
+
21
+- hbbs - RustDesk ID/Rendezvous server
22
+- hbbr - RustDesk relay server
23
+
24
+You can find updated binaries on the [releases](https://github.com/rustdesk/rustdesk-server/releases) page.
18 25
 
19 26
 If you wanna develop your own server, [rustdesk-server-demo](https://github.com/rustdesk/rustdesk-server-demo) might be a better and simpler start for you than this repo.
20 27
 
21
-## docker-compose
28
+## Docker images
29
+
30
+Docker images are automatically generated and published on every github release. We have 2 kind of images.
31
+
32
+### Classic image
33
+
34
+These images are build against `ubuntu-20.04` with the only addition of the binaries (both hbbr and hbbs). They're available on [Docker hub](https://hub.docker.com/r/rustdesk/rustdesk-server/) with these tags:
35
+
36
+| architecture | image:tag |
37
+| --- | --- |
38
+| amd64 | `rustdesk/rustdesk-server:latest` |
39
+| arm64v8 | `rustdesk/rustdesk-server:latest-arm64v8` |
40
+
41
+You can start these images directly with `docker run` with these commands:
42
+
43
+```bash
44
+docker run --name hbbs -p 21115:21115 -p 21116:21116 -p 21116:21116/udp -p 21118:21118 -v "$PWD:/root" -d rustdesk/rustdesk-server:latest hbbs -r <relay-server-ip[:port]> 
45
+docker run --name hbbr -p 21117:21117 -p 21119:21119 -v "$PWD:/root" -d rustdesk/rustdesk-server:latest hbbr 
46
+```
47
+
48
+The `relay-server-ip` parameter is the IP address (or dns name) of the server running these containers. The **optional** `port` parameter has to be used if you use a port different than **21117** for `hbbr`.
49
+
50
+You can also use docker-compose, using this configuration as a template:
51
+
52
+```yaml
53
+version: '3'
54
+
55
+networks:
56
+  rustdesk-net:
57
+    external: false
58
+
59
+services:
60
+  hbbs:
61
+    container_name: hbbs
62
+    ports:
63
+      - 21115:21115
64
+      - 21116:21116
65
+      - 21116:21116/udp
66
+      - 21118:21118
67
+    image: rustdesk/rustdesk-server:latest
68
+    command: hbbs -r rustdesk.example.com:21117
69
+    volumes:
70
+      - ./hbbs:/root
71
+    networks:
72
+      - rustdesk-net
73
+    depends_on:
74
+      - hbbr
75
+    restart: unless-stopped
22 76
 
23
-If you have Docker and would like to use it, an included `docker-compose.yml` file is included. Edit line 16 to point to your relay server (the one listening on port 21117). You can also edit the volume lines (L18 and L33) if you need.
77
+  hbbr:
78
+    container_name: hbbr
79
+    ports:
80
+      - 21117:21117
81
+      - 21119:21119
82
+    image: rustdesk/rustdesk-server:latest
83
+    command: hbbr
84
+    volumes:
85
+      - ./hbbr:/root
86
+    networks:
87
+      - rustdesk-net
88
+    restart: unless-stopped
89
+```
90
+
91
+Edit line 16 to point to your relay server (the one listening on port 21117). You can also edit the volume lines (L18 and L33) if you need.
24 92
 
25 93
 (docker-compose credit goes to @lukebarone and @QuiGonLeong)
94
+
95
+## S6-overlay based images
96
+
97
+These images are build against `busybox:stable` with the addition of the binaries (both hbbr and hbbs) and [S6-overlay](https://github.com/just-containers/s6-overlay). They're available on [Docker hub](https://hub.docker.com/r/rustdesk/rustdesk-server-36/) with these tags:
98
+
99
+| architecture | version | image:tag |
100
+| --- | --- | --- |
101
+| multiarch | latest | `rustdesk/rustdesk-server-s6:latest` |
102
+| amd64 | latest | `rustdesk/rustdesk-server-s6:latest-amd64` |
103
+| i386 | latest | `rustdesk/rustdesk-server-s6:latest-i386` |
104
+| arm64v8 | latest | `rustdesk/rustdesk-server-s6:latest-arm64v8` |
105
+| armv7 | latest | `rustdesk/rustdesk-server-s6:latest-armv7` |
106
+| multiarch | 2 | `rustdesk/rustdesk-server-s6:2` |
107
+| amd64 | 2 | `rustdesk/rustdesk-server-s6:2-amd64` |
108
+| i386 | 2 | `rustdesk/rustdesk-server-s6:2-i386` |
109
+| arm64v8 | 2 | `rustdesk/rustdesk-server-s6:2-arm64v8` |
110
+| armv7 | 2 | `rustdesk/rustdesk-server-s6:2-armv7` |
111
+| multiarch | 2.0.0 | `rustdesk/rustdesk-server-s6:2.0.0` |
112
+| amd64 | 2.0.0 | `rustdesk/rustdesk-server-s6:2.0.0-amd64` |
113
+| i386 | 2.0.0 | `rustdesk/rustdesk-server-s6:2.0.0-i386` |
114
+| arm64v8 | 2.0.0 | `rustdesk/rustdesk-server-s6:2.0.0-arm64v8` |
115
+| armv7 | 2.0.0 | `rustdesk/rustdesk-server-s6:2.0.0-armv7` |
116
+
117
+You're strongly encuraged to use the `multiarch` image either with the `major version` or `latest` tag.
118
+
119
+The S6-overlay acts as a supervisor and keeps both process running, so with this image there's no need to have two separate running containers.
120
+
121
+You can start these images directly with `docker run` with this command:
122
+
123
+```bash
124
+docker run --name rustdesk-server \
125
+  -p 21115:21115 -p 21116:21116 -p 21116:21116/udp \
126
+  -p 21117:21117 -p 21118:21118 -p 21119:21119 \
127
+  -e "RELAY=rustdeskrelay.example.com" \
128
+  -e "ENCRYPTED_ONLY=1" \
129
+  -v "$PWD/data:/data" -d rustdesk/rustdesk-server-s6:latest
130
+```
131
+
132
+Or you can use a docker-compose file:
133
+
134
+```yaml
135
+version: '3'
136
+
137
+services:
138
+  rustdesk-server:
139
+    container_name: rustdesk-server
140
+    ports:
141
+      - 21115:21115
142
+      - 21116:21116
143
+      - 21116:21116/udp
144
+      - 21117:21117
145
+      - 21118:21118
146
+      - 21119:21119
147
+    image: rustdesk/rustdesk-server-s6:latest
148
+    environment:
149
+      - "RELAY=rustdesk.example.com:21117"
150
+      - "ENCRYPTED_ONLY=1"
151
+    volumes:
152
+      - ./data:/data
153
+    restart: unless-stopped
154
+```
155
+
156
+We use these environment variables:
157
+
158
+| variable | optional | description |
159
+| --- | --- | --- |
160
+| RELAY | no | the IP address/DNS name of the machine running this container |
161
+| ENCRYPTED_ONLY | yes | if set to **"1"** unencrypted connection will not be accepted |

+ 4 - 0
docker-classic/Dockerfile

@@ -0,0 +1,4 @@
1
+FROM ubuntu:20.04    
2
+COPY hbbs /usr/bin/hbbs    
3
+COPY hbbr /usr/bin/hbbr    
4
+WORKDIR /root 

+ 1 - 11
docker/Dockerfile

@@ -1,11 +1,3 @@
1
-FROM rust:alpine AS builder
2
-
3
-RUN \
4
-  apk -U add musl-dev git file make && \
5
-  git clone --depth=1 https://github.com/rustdesk/rustdesk-server.git /src && \
6
-  cd /src && \
7
-  cargo build -r --manifest-path /src/Cargo.toml
8
-
9 1
 FROM busybox:stable
10 2
 
11 3
 ARG S6_OVERLAY_VERSION=3.1.0.1
@@ -17,11 +9,9 @@ RUN \
17 9
   rm /tmp/s6-overlay*.tar.xz
18 10
   
19 11
 COPY rootfs /
20
-COPY --from=builder /src/target/release/hbbr /usr/bin/hbbr
21
-COPY --from=builder /src/target/release/hbbs /usr/bin/hbbs
22
-COPY healthcheck.sh /usr/bin/healthcheck.sh
23 12
 
24 13
 ENV RELAY relay.example.com
14
+ENV ENCRYPTED_ONLY 0
25 15
 
26 16
 EXPOSE 21115 21116 21116/udp 21117 21118 21119
27 17
 

+ 5 - 3
docker/rootfs/etc/s6-overlay/s6-rc.d/hbbs/run

@@ -1,3 +1,5 @@
1
-#!/command/execlineb -P
2
-posix-cd /data
3
-/usr/bin/hbbs -r $RELAY
1
+#!/command/with-contenv sh
2
+cd /data
3
+PARAMS=
4
+[ "${ENCRYPTED_ONLY}" = "1" ] && PARAMS="-k _"
5
+/usr/bin/hbbs -r $RELAY $PARAMS

+ 4 - 0
docker/rootfs/usr/bin/healthcheck.sh

@@ -0,0 +1,4 @@
1
+#!/bin/sh
2
+
3
+/package/admin/s6/command/s6-svstat /run/s6-rc/servicedirs/hbbr || exit 1
4
+/package/admin/s6/command/s6-svstat /run/s6-rc/servicedirs/hbbs || exit 1