mirror of
https://github.com/Redocly/redoc.git
synced 2025-08-01 02:49:52 +03:00
Delete config directoryspan
This commit is contained in:
parent
d193dd2627
commit
d8bd1e3330
|
@ -1,55 +0,0 @@
|
|||
# To run:
|
||||
# docker build -t redoc .
|
||||
# docker run -it --rm -p 80:80 -e SPEC_URL='http://localhost:8000/swagger.yaml' redoc
|
||||
# Ensure http://localhost:8000/swagger.yaml is served with cors. A good solution is:
|
||||
# npm i -g http-server
|
||||
# http-server -p 8000 --cors
|
||||
|
||||
FROM node:18-alpine
|
||||
|
||||
RUN apk update && apk add --no-cache git
|
||||
|
||||
# Install dependencies
|
||||
WORKDIR /build
|
||||
COPY package.json package-lock.json /build/
|
||||
RUN npm ci --no-optional --ignore-scripts
|
||||
|
||||
# copy only required for the build files
|
||||
COPY src /build/src
|
||||
COPY webpack.config.ts tsconfig.json custom.d.ts /build/
|
||||
COPY config/webpack-utils.ts /build/config/
|
||||
COPY typings/styled-patch.d.ts /build/typings/styled-patch.d.ts
|
||||
|
||||
RUN npm run bundle:standalone
|
||||
|
||||
FROM nginx:alpine
|
||||
|
||||
ENV PAGE_TITLE="ReDoc"
|
||||
ENV PAGE_FAVICON="favicon.png"
|
||||
ENV BASE_PATH=
|
||||
ENV SPEC_URL="http://petstore.swagger.io/v2/swagger.json"
|
||||
ENV PORT=80
|
||||
ENV REDOC_OPTIONS=
|
||||
|
||||
# copy files to the nginx folder
|
||||
COPY --from=0 build/bundles /usr/share/nginx/html
|
||||
COPY config/docker/index.tpl.html /usr/share/nginx/html/index.html
|
||||
COPY demo/favicon.png /usr/share/nginx/html/
|
||||
COPY config/docker/nginx.conf /etc/nginx/
|
||||
COPY config/docker/docker-run.sh /usr/local/bin
|
||||
|
||||
# Provide rights to the root group to write to nginx repositories (needed to run in OpenShift)
|
||||
RUN chgrp -R 0 /etc/nginx && \
|
||||
chgrp -R 0 /usr/share/nginx/html && \
|
||||
chgrp -R 0 /var/cache/nginx && \
|
||||
chgrp -R 0 /var/log/nginx && \
|
||||
chgrp -R 0 /var/run && \
|
||||
chmod -R g+rwX /etc/nginx && \
|
||||
chmod -R g+rwX /usr/share/nginx/html && \
|
||||
chmod -R g+rwX /var/cache/nginx && \
|
||||
chmod -R g+rwX /var/log/nginx && \
|
||||
chmod -R g+rwX /var/run
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
CMD ["sh", "/usr/local/bin/docker-run.sh"]
|
|
@ -1,55 +0,0 @@
|
|||
# Official ReDoc Docker Image
|
||||
|
||||
## Usage
|
||||
|
||||
### Docker
|
||||
|
||||
Serve remote spec by URL:
|
||||
|
||||
docker run -it --rm -p 80:80 \
|
||||
-e SPEC_URL='http://localhost:8000/swagger.yaml' redocly/redoc
|
||||
|
||||
Serve local file:
|
||||
|
||||
docker run -it --rm -p 80:80 \
|
||||
-v $(pwd)/demo/swagger.yaml:/usr/share/nginx/html/swagger.yaml \
|
||||
-e SPEC_URL=swagger.yaml redocly/redoc
|
||||
|
||||
Serve local file and watch for updates:
|
||||
|
||||
docker run -it --rm -p 80:80 \
|
||||
-v $(pwd)/demo/:/usr/share/nginx/html/swagger/ \
|
||||
-e SPEC_URL=swagger/swagger.yaml redocly/redoc
|
||||
|
||||
### OpenShift
|
||||
|
||||
To quote [OpenShift Container Platform-Specific Guidelines](https://docs.openshift.com/container-platform/3.11/creating_images/guidelines.html#openshift-specific-guidelines):
|
||||
|
||||
> Support Arbitrary User IDs
|
||||
>
|
||||
> By default, OpenShift Container Platform runs containers using an arbitrarily assigned user ID. This provides additional security against processes escaping the container due to a container engine vulnerability and thereby achieving escalated permissions on the host node.
|
||||
>
|
||||
> For an image to support running as an arbitrary user, directories and files that may be written to by processes in the image should be owned by the root group and be read/writable by that group. Files to be executed should also have group execute permissions.
|
||||
|
||||
To comply with those requirements the `Dockerfile` contains instructions to adapt the rights for the folders:
|
||||
|
||||
- `/etc/nginx` because the `docker-run.sh` script modifies it at startup time
|
||||
- `/usr/share/nginx/html` because the `docker-run.sh` script modifies it at startup time
|
||||
- `/var/cache/nginx` because the Nginx process writes to it
|
||||
- `/var/log/nginx` because the Nginx process writes to it
|
||||
- `/var/run` because the Nginx process writes to it
|
||||
|
||||
Another issue with OpenShift is that the default exposed port `80` cannot be used as it is restricted. So one needs to use another port like `8080` (using the `PORT` configuration as described below), and then to configure the `container spec` accordingly.
|
||||
|
||||
## Runtime configuration options
|
||||
|
||||
- `PAGE_TITLE` (default `"ReDoc"`) - page title
|
||||
- `PAGE_FAVICON` (default `"favicon.png"`) - URL to page favicon
|
||||
- `BASE_PATH` (optional) - prepend favicon & standalone bundle with this path
|
||||
- `SPEC_URL` (default `"http://petstore.swagger.io/v2/swagger.json"`) - URL to spec
|
||||
- `PORT` (default `80`) - nginx port
|
||||
- `REDOC_OPTIONS` (optional) - [`<redoc>` tag attributes](https://github.com/Redocly/redoc#redoc-tag-attributes)
|
||||
|
||||
## Build
|
||||
|
||||
docker build -t redocly/redoc .
|
|
@ -1,12 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
sed -i -e "s|%PAGE_TITLE%|$PAGE_TITLE|g" /usr/share/nginx/html/index.html
|
||||
sed -i -e "s|%PAGE_FAVICON%|$PAGE_FAVICON|g" /usr/share/nginx/html/index.html
|
||||
sed -i -e "s|%BASE_PATH%|$BASE_PATH|g" /usr/share/nginx/html/index.html
|
||||
sed -i -e "s|%SPEC_URL%|$SPEC_URL|g" /usr/share/nginx/html/index.html
|
||||
sed -i -e "s|%REDOC_OPTIONS%|${REDOC_OPTIONS}|g" /usr/share/nginx/html/index.html
|
||||
sed -i -e "s|\(listen\s*\) [0-9]*|\1 ${PORT}|g" /etc/nginx/nginx.conf
|
||||
|
||||
exec nginx -g 'daemon off;'
|
|
@ -1,6 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# DockerHub cd into Dockerfile location before build
|
||||
# So we have to undo this.
|
||||
cd ../..
|
||||
docker build -f config/docker/Dockerfile -t $IMAGE_NAME .
|
|
@ -1,28 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>%PAGE_TITLE%</title>
|
||||
<link rel="icon" href="%BASE_PATH%%PAGE_FAVICON%" />
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
redoc {
|
||||
display: block;
|
||||
}
|
||||
</style>
|
||||
<link
|
||||
href="https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:300,400,700"
|
||||
rel="stylesheet"
|
||||
/>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<redoc spec-url="%SPEC_URL%" %REDOC_OPTIONS%></redoc>
|
||||
<script src="%BASE_PATH%redoc.standalone.js"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -1,71 +0,0 @@
|
|||
worker_processes 1;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
include mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
sendfile on;
|
||||
|
||||
keepalive_timeout 65;
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
index index.html index.htm;
|
||||
|
||||
location / {
|
||||
alias /usr/share/nginx/html/;
|
||||
|
||||
if ($request_method = 'OPTIONS') {
|
||||
# Add security headers
|
||||
add_header 'X-Frame-Options' 'deny always';
|
||||
add_header 'X-XSS-Protection' '"1; mode=block" always';
|
||||
add_header 'X-Content-Type-Options' 'nosniff always';
|
||||
add_header 'Referrer-Policy' 'strict-origin-when-cross-origin';
|
||||
|
||||
# Set access control header
|
||||
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 security headers
|
||||
add_header 'X-Frame-Options' 'deny always';
|
||||
add_header 'X-XSS-Protection' '"1; mode=block" always';
|
||||
add_header 'X-Content-Type-Options' 'nosniff always';
|
||||
add_header 'Referrer-Policy' 'strict-origin-when-cross-origin';
|
||||
|
||||
# Set access control header
|
||||
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 security headers
|
||||
add_header 'X-Frame-Options' 'deny always';
|
||||
add_header 'X-XSS-Protection' '"1; mode=block" always';
|
||||
add_header 'X-Content-Type-Options' 'nosniff always';
|
||||
add_header 'Referrer-Policy' 'strict-origin-when-cross-origin';
|
||||
|
||||
# Set access control header
|
||||
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';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
import * as webpack from 'webpack';
|
||||
|
||||
export function webpackIgnore(regexp) {
|
||||
return new webpack.NormalModuleReplacementPlugin(regexp, require.resolve('lodash.noop'));
|
||||
}
|
Loading…
Reference in New Issue
Block a user