Skip to content
Snippets Groups Projects
Unverified Commit fa90e142 authored by Martin Weise's avatar Martin Weise
Browse files

Added swagger ui doc image

parent 1af04bc1
No related branches found
No related tags found
No related merge requests found
Pipeline #2842 passed
.PHONY: clean docs .PHONY: clean docs
TAG ?= latest
all: build all: build
clean: clean:
rm -rf ./site rm -rf ./site
docs: install-deps release: release-docs release-dockerhub
python3 ./dockerhub/release.py
install-deps: release-docs:
sudo pip3 install -r ./requirements.txt docker compose build dbrepo-docs
docker tag dbrepo-docs:latest "dbrepo/docs:${TAG}"
docker push "dbrepo/docs:${TAG}"
release: install-deps release-dockerhub:
sudo pip3 install -r ./requirements.txt
python3 ./dockerhub/release.py
verify: verify:
sudo nginx -t sudo nginx -t
......
version: "3.8"
services:
dbrepo-docs:
image: dbrepo-docs
restart: on-failure
build: ./swagger
container_name: dbrepo-docs
hostname: dbrepo-docs
ports:
- "80:80"
\ No newline at end of file
# How to use this image
```console
$ docker run -p 80:80
```
## Customization
No customization.
\ No newline at end of file
...@@ -6,6 +6,6 @@ dockerhub = Dockerhub() ...@@ -6,6 +6,6 @@ dockerhub = Dockerhub()
if __name__ == "__main__": if __name__ == "__main__":
for component in ["analyse-service", "authentication-service", "broker-service", "container-service", for component in ["analyse-service", "authentication-service", "broker-service", "container-service",
"database-service", "discovery-service", "gateway-service", "identifier-service", "database-service", "discovery-service", "gateway-service", "identifier-service",
"metadata-db", "query-service", "search-service", "table-service", "ui", "units-service"]: "metadata-db", "query-service", "search-service", "table-service", "ui", "units-service", "docs"]:
response = dockerhub.modify_description(component) response = dockerhub.modify_description(component)
print(response) print(response)
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
server {
listen 80 default_server;
listen [::]:80 default_server;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
root /usr/share/nginx/html/dbrepo-docs.ossdip.at;
index index.html index.htm;
server_name dbrepo-docs.ossdip.at;
ssl_certificate /etc/letsencrypt/live/dbrepo-docs.ossdip.at/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/dbrepo-docs.ossdip.at/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
location / {
try_files $uri $uri/ =404;
}
}
# server {
# listen 443 ssl http2;
# listen [::]:443 ssl http2;
# root /usr/share/nginx/html/ossdip.at;
# index index.html index.htm;
# server_name ossdip.at;
# ssl_certificate /etc/letsencrypt/live/ossdip.at/fullchain.pem;
# ssl_certificate_key /etc/letsencrypt/live/ossdip.at/privkey.pem;
# include /etc/letsencrypt/options-ssl-nginx.conf;
# ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
#
# location / {
# try_files $uri $uri/ =404;
# }
#
# }
}
FROM nginx:latest AS runtime
MAINTAINER Martin Weise <martin.weise@tuwien.ac.at>
ARG SWAGGER_UI_VERSION=4.15.2
RUN echo 1
# reset
RUN rm -f /usr/share/nginx/html/*
WORKDIR /app
ADD "https://github.com/swagger-api/swagger-ui/archive/refs/tags/v${SWAGGER_UI_VERSION}.tar.gz" /app/tmp.tar.gz
RUN tar xzfv /app/tmp.tar.gz --strip-components 1 && rm -f /app/tmp.tar.gz
COPY ./swagger-initializer.js ./swagger-initializer.js
COPY ./docker-build.sh ./docker-build.sh
RUN chmod +x ./docker-build.sh
WORKDIR /usr/share/nginx/html/
# copy api
COPY ./index.html ./index.html
COPY ./api-analyse.yaml ./analyse/api.yaml
COPY ./api-authentication.yaml ./authentication/api.yaml
COPY ./api-container.yaml ./container/api.yaml
COPY ./api-database.yaml ./database/api.yaml
COPY ./api-identifier.yaml ./identifier/api.yaml
COPY ./api-metadata.yaml ./metadata/api.yaml
COPY ./api-query.yaml ./query/api.yaml
COPY ./api-table.yaml ./table/api.yaml
COPY ./api-units.yaml ./units/api.yaml
# generate
RUN bash /app/docker-build.sh
\ No newline at end of file
#!/bin/bash
declare -A services
services[5000]=analyse
services[5010]=units
services[9091]=container
services[9092]=database
services[9093]=query
services[9094]=table
services[9096]=identifier
services[9097]=authentication
services[9098]=metadata
function copy () {
echo "... copy dist to $1"
cp -r /app/dist/* "./$1"
}
function init () {
echo "... copy initializer to $1"
cp /app/swagger-initializer.js "/usr/share/nginx/html/$1"
}
function replace () {
echo "... replace server url of $1"
sed -i -e "s/localhost.*/dbrepo1.ec.tuwien.ac.at\/api/g" "./$1/api.yaml"
sed -i -e "s/Generated server url/TU Wien DBRepo/g" "./$1/api.yaml"
}
for key in "${!services[@]}"; do
echo "Preparing ${services[$key]} API"
replace "${services[$key]}"
copy "${services[$key]}"
init "${services[$key]}"
done
\ No newline at end of file
#!/bin/bash #!/bin/bash
declare -A services declare -A services
services[5000]=analyse
services[5010]=units services[5010]=units
services[9091]=container services[9091]=container
services[9092]=database services[9092]=database
services[9093]=query services[9093]=query
services[9094]=table services[9094]=table
services[9097]=authentication
services[9096]=identifier services[9096]=identifier
services[9097]=authentication
services[9098]=metadata
function retrieve () { function retrieve () {
echo "... retrieve api" echo "... retrieve api"
......
<!DOCTYPE html>
<head>
<title>DBRepo Endpoint Documentation</title>
</head>
<body>
<h3>DBRepo Endpoint Documentation</h3>
<ul>
<li><a href="/analyse">Analyse Service</a></li>
<li><a href="/authentication">Authentication Service</a></li>
<li><a href="/container">Container Service</a></li>
<li><a href="/database">Database Service</a></li>
<li><a href="/identifier">Identifier Service</a></li>
<li><a href="/metadata">Metadata Service</a></li>
<li><a href="/query">Query Service</a></li>
<li><a href="/table">Table Service</a></li>
<li><a href="/units">Units Service</a></li>
</ul>
</body>
\ No newline at end of file
window.onload = function() {
//<editor-fold desc="Changeable Configuration Block">
// the following lines will be replaced by docker/configurator, when it runs in a docker-container
window.ui = SwaggerUIBundle({
url: "api.yaml",
dom_id: '#swagger-ui',
deepLinking: true,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: "StandaloneLayout"
});
//</editor-fold>
};
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment