chore: optimize docker build

This commit is contained in:
Roman Hotsiy 2018-11-06 15:24:12 +02:00
parent e77df0ca07
commit ea5029b52d
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0
3 changed files with 32 additions and 8 deletions

12
.dockerignore Normal file
View File

@ -0,0 +1,12 @@
*
!src/
!config
!demo/favicon.png
!custom.d.ts
!typings/styled-patch.d.ts
!tsconfig.json
!webpack.config.ts
!package.json
!yarn.lock

View File

@ -9,10 +9,16 @@ FROM node:alpine
RUN apk update && apk add --no-cache git
# generate bundle
# Install dependencies
WORKDIR /build
COPY . /build
COPY package.json yarn.lock /build/
RUN yarn install --frozen-lockfile --ignore-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 typings/styled-patch.d.ts /build/typings/styled-patch.d.ts
RUN npm run bundle:standalone
FROM nginx:alpine

View File

@ -17,12 +17,18 @@ const nodeExternals = require('webpack-node-externals')({
});
const VERSION = JSON.stringify(require('./package.json').version);
const REVISION = JSON.stringify(
let REVISION;
try {
REVISION = JSON.stringify(
require('child_process')
.execSync('git rev-parse --short HEAD')
.toString()
.trim(),
);
} catch (e) {
console.error('Skipping REDOC_REVISION');
}
const BANNER = `ReDoc - OpenAPI/Swagger-generated API Reference Documentation
-------------------------------------------------------------