This commit is contained in:
Tony Tam 2017-03-18 13:58:30 -07:00
Родитель adf4fa854c
Коммит 9afe6802db
3 изменённых файлов: 78 добавлений и 0 удалений

19
Dockerfile Normal file
Просмотреть файл

@ -0,0 +1,19 @@
FROM alpine:3.4
MAINTAINER fehguy
RUN apk add --update nginx
RUN mkdir -p /run/nginx
COPY nginx.conf /etc/nginx/
# copy swagger files to the `/js` folder
ADD ./dist/ /usr/share/nginx/html/js
ADD ./public/index.html /usr/share/nginx/html
# change the folder structure
RUN sed -i 's/\.\.\/dist/js/g' /usr/share/nginx/html/index.html
EXPOSE 8080
CMD exec nginx -g 'daemon off;'

Просмотреть файл

@ -23,6 +23,16 @@ Swagger UI Version | Release Date | OpenAPI Spec compatibility | Notes | Status
### How to run
##### Easy start! Docker
You can pull a pre-built docker image of the swagger-ui directly from Dockerhub:
```
docker pull swaggerapi/swagger-ui
docker run -p 80:8080 swaggerapi/swagger-ui
```
Will start nginx with swagger-ui on port 80.
##### Prerequisites
- Node 6.x
- NPM 3.x

49
nginx.conf Normal file
Просмотреть файл

@ -0,0 +1,49 @@
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 8080;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
#
# Custom headers and headers various browsers *should* be OK with but aren't
#
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
#
# Tell client that this pre-flight info is valid for 20 days
#
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
if ($request_method = 'POST') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
}
if ($request_method = 'GET') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
}
}
}
}