mirror of
https://github.com/openstf/stf
synced 2025-10-06 03:50:04 +02:00
Merge pull request #1176 from denis99999/patch-2
Add swagger UI support in DEPLOYMENT.md
This commit is contained in:
commit
217c2c6dda
1 changed files with 43 additions and 3 deletions
|
@ -715,7 +715,7 @@ The groups-engine unit is the core of the device booking/partitioning system, it
|
||||||
|
|
||||||
- users’ watcher: relied on changefeeds mechanism of rethinkdb database, so taking actions on user creation, updating and removing: notifies front-end UI, etc.
|
- users’ watcher: relied on changefeeds mechanism of rethinkdb database, so taking actions on user creation, updating and removing: notifies front-end UI, etc.
|
||||||
|
|
||||||
Note that it doesn't make sense to have more than one groups-engine unit running at once.
|
Note that it doesn't make sense to have more than one `groups-engine.service` unit running at once.
|
||||||
|
|
||||||
```ini
|
```ini
|
||||||
[Unit]
|
[Unit]
|
||||||
|
@ -869,6 +869,35 @@ ExecStart=/usr/bin/docker run --rm \
|
||||||
ExecStop=-/usr/bin/docker stop -t 10 %p-%i
|
ExecStop=-/usr/bin/docker stop -t 10 %p-%i
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### `swagger-ui@.service`
|
||||||
|
|
||||||
|
**Requires** the main HTTP server on the same host.
|
||||||
|
|
||||||
|
If you want to play with STF API against your STF platform using swagger UI tool through a web access, then you can use this optional unit. In this example, the unit requires to put the STF swagger file `api_v1.yaml` to the `/opt/stf/swagger` folder of the host. You can have multiple instances running on the same host by using different ports.
|
||||||
|
|
||||||
|
```ini
|
||||||
|
[Unit]
|
||||||
|
Description=Swagger UI (runs on %i port)
|
||||||
|
After=docker.service
|
||||||
|
BindsTo=docker.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
EnvironmentFile=/etc/environment
|
||||||
|
TimeoutStartSec=0
|
||||||
|
Restart=always
|
||||||
|
ExecStartPre=/usr/bin/docker pull swaggerapi/swagger-ui:latest
|
||||||
|
ExecStartPre=-/usr/bin/docker kill %p-%i
|
||||||
|
ExecStartPre=-/usr/bin/docker rm %p-%i
|
||||||
|
ExecStart=/usr/bin/docker run --rm \
|
||||||
|
--name %p-%i \
|
||||||
|
-e "VALIDATOR_URL=null" \
|
||||||
|
-e "SWAGGER_JSON=/foo/api_v1.yaml" \
|
||||||
|
-p %i:8080 \
|
||||||
|
-v /opt/stf/swagger:/foo \
|
||||||
|
swaggerapi/swagger-ui:latest
|
||||||
|
ExecStop=/usr/bin/docker stop -t 2 %p-%i
|
||||||
|
```
|
||||||
|
|
||||||
## Nginx configuration
|
## Nginx configuration
|
||||||
|
|
||||||
Now that you've got all the units ready, it's time to set up [nginx](http://nginx.org/) to tie all the processes together with a clean URL.
|
Now that you've got all the units ready, it's time to set up [nginx](http://nginx.org/) to tie all the processes together with a clean URL.
|
||||||
|
@ -884,6 +913,7 @@ So, to recap, our example setup is as follows:
|
||||||
| [stf-storage-temp@3500.service](#stf-storage-tempservice) | 192.168.255.100 | 3500 |
|
| [stf-storage-temp@3500.service](#stf-storage-tempservice) | 192.168.255.100 | 3500 |
|
||||||
| [stf-websocket@3600.service](#stf-websocketservice) | 192.168.255.100 | 3600 |
|
| [stf-websocket@3600.service](#stf-websocketservice) | 192.168.255.100 | 3600 |
|
||||||
| [stf-api@3700.service](#stf-apiservice) | 192.168.255.100 | 3700 |
|
| [stf-api@3700.service](#stf-apiservice) | 192.168.255.100 | 3700 |
|
||||||
|
| [swagger-ui@.service](#swagger-uiservice) | 192.168.255.100 | 3800 |
|
||||||
|
|
||||||
Furthermore, let's assume that we have the following providers set up:
|
Furthermore, let's assume that we have the following providers set up:
|
||||||
|
|
||||||
|
@ -931,6 +961,10 @@ http {
|
||||||
server 192.168.255.100:3700 max_fails=0;
|
server 192.168.255.100:3700 max_fails=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
upstream swagger_ui {
|
||||||
|
server 192.168.255.100:3800 max_fails=0;
|
||||||
|
}
|
||||||
|
|
||||||
types {
|
types {
|
||||||
application/javascript js;
|
application/javascript js;
|
||||||
image/gif gif;
|
image/gif gif;
|
||||||
|
@ -1026,6 +1060,12 @@ http {
|
||||||
proxy_set_header X-Real-IP $http_x_real_ip;
|
proxy_set_header X-Real-IP $http_x_real_ip;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
location /swaggerui/ {
|
||||||
|
proxy_pass http://swagger_ui/;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Real-IP $http_x_real_ip;
|
||||||
|
}
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
proxy_pass http://stf_app;
|
proxy_pass http://stf_app;
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
@ -1052,7 +1092,7 @@ ConditionPathExists=/srv/nginx/nginx.conf
|
||||||
EnvironmentFile=/etc/environment
|
EnvironmentFile=/etc/environment
|
||||||
TimeoutStartSec=0
|
TimeoutStartSec=0
|
||||||
Restart=always
|
Restart=always
|
||||||
ExecStartPre=/usr/bin/docker pull nginx:1.7.10
|
ExecStartPre=/usr/bin/docker pull nginx:1.17.4
|
||||||
ExecStartPre=-/usr/bin/docker kill %p
|
ExecStartPre=-/usr/bin/docker kill %p
|
||||||
ExecStartPre=-/usr/bin/docker rm %p
|
ExecStartPre=-/usr/bin/docker rm %p
|
||||||
ExecStart=/usr/bin/docker run --rm \
|
ExecStart=/usr/bin/docker run --rm \
|
||||||
|
@ -1062,7 +1102,7 @@ ExecStart=/usr/bin/docker run --rm \
|
||||||
-v /srv/ssl/stf.example.org.key:/etc/nginx/ssl/cert.key:ro \
|
-v /srv/ssl/stf.example.org.key:/etc/nginx/ssl/cert.key:ro \
|
||||||
-v /srv/ssl/dhparam.pem:/etc/nginx/ssl/dhparam.pem:ro \
|
-v /srv/ssl/dhparam.pem:/etc/nginx/ssl/dhparam.pem:ro \
|
||||||
-v /srv/nginx/nginx.conf:/etc/nginx/nginx.conf:ro \
|
-v /srv/nginx/nginx.conf:/etc/nginx/nginx.conf:ro \
|
||||||
nginx:1.7.10 \
|
nginx:1.17.4 \
|
||||||
nginx
|
nginx
|
||||||
ExecStop=/usr/bin/docker stop -t 2 %p
|
ExecStop=/usr/bin/docker stop -t 2 %p
|
||||||
```
|
```
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue