Skip to content

Commit

Permalink
chore(dockerfile): optimize image size
Browse files Browse the repository at this point in the history
Signed-off-by: Igor Beliakov <[email protected]>
  • Loading branch information
weisdd committed Jan 21, 2025
1 parent 648fb6c commit 1e9d2e7
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,22 @@ COPY packages/cli/package.json /build/packages/cli/
COPY packages/core/package.json /build/packages/core/
COPY packages/cli/bin/ /build/packages/cli/bin/

RUN npm ci --no-optional --ignore-scripts

# Copy rest of the files
COPY . /build/
RUN npm run prepare

# Install redocly-cli globally, similar to npm install --global @redocly/cli
# but the local package is used here
RUN apk update && apk add jq && \
apk add git && \
RUN npm ci --no-optional --ignore-scripts && \
npm run prepare && \
# Install redocly-cli globally, similar to npm install --global @redocly/cli
# but the local package is used here
apk add --no-cache jq git && \
npm run pack:prepare && \
npm install --global redocly-cli.tgz

# npm pack in the previous RUN command does not include these assets
RUN cp packages/cli/src/commands/preview-docs/preview-server/default.hbs /usr/local/lib/node_modules/@redocly/cli/lib/commands/preview-docs/preview-server/default.hbs && \
npm install --global redocly-cli.tgz && \
# npm pack in the previous RUN command does not include these assets
cp packages/cli/src/commands/preview-docs/preview-server/default.hbs /usr/local/lib/node_modules/@redocly/cli/lib/commands/preview-docs/preview-server/default.hbs && \
cp packages/cli/src/commands/preview-docs/preview-server/hot.js /usr/local/lib/node_modules/@redocly/cli/lib/commands/preview-docs/preview-server/hot.js && \
cp packages/cli/src/commands/build-docs/template.hbs /usr/local/lib/node_modules/@redocly/cli/lib/commands/build-docs/template.hbs

# Clean up to reduce image size
RUN npm cache clean --force && rm -rf /build
cp packages/cli/src/commands/build-docs/template.hbs /usr/local/lib/node_modules/@redocly/cli/lib/commands/build-docs/template.hbs && \
# Clean up to reduce image size
npm cache clean --force && rm -rf /build

WORKDIR /spec

Expand Down

0 comments on commit 1e9d2e7

Please sign in to comment.