forked from sjeandeaux/docker-swagger-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
29 lines (21 loc) · 1.01 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
FROM node:9.5
MAINTAINER Stéphane Jeandeaux <[email protected]>
RUN npm update npm &&\
npm install http-server replace
RUN mkdir -p /tmp/swagger
ADD https://github.com/swagger-api/swagger-ui/archive/master.tar.gz /tmp/swagger/swaggerui.tar.gz
RUN tar --strip-components 1 -C /tmp/swagger -xzf /tmp/swagger/swaggerui.tar.gz
RUN mkdir -p /swaggerui/dist/swagger-ui &&\
mv /tmp/swagger/dist/* /swaggerui/dist/swagger-ui &&\
rm -rf /tmp/swagger
ENV API_URL http://petstore.swagger.io/v2/swagger.json
RUN echo "'use strict';\
var path = require('path');\
var createServer = require('http-server').createServer;\
var dist = path.join('swaggerui', 'dist');\
var replace = require('replace');\
replace({regex: 'http.*swagger.json', replacement : process.env.API_URL, paths: ['/swaggerui/dist/swagger-ui/index.html'], recursive:false, silent:true,});\
var swaggerUI = createServer({ root: dist, cors: true });\
swaggerUI.listen(8888);" > /swaggerui/index.js
EXPOSE 8888
CMD ["node", "/swaggerui/index.js"]