Skip to content

Commit

Permalink
chore: fix docker smoke test
Browse files Browse the repository at this point in the history
  • Loading branch information
tatomyr committed Feb 18, 2025
1 parent 7e6ff71 commit 0d092b7
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 46 deletions.
42 changes: 13 additions & 29 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,36 +1,20 @@
FROM node:alpine

WORKDIR /build

# Copy files required for npm install only
COPY package.json package-lock.json /build/
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 && \
COPY . .
RUN apk add --no-cache jq git && \
npm ci --no-optional --ignore-scripts && \
npm run prepare && \
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 && \
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
npm install --global redocly-cli.tgz && \
cp packages/cli/src/commands/preview-docs/preview-server/default.hbs \
packages/cli/src/commands/preview-docs/preview-server/hot.js \
/usr/local/lib/node_modules/@redocly/cli/lib/commands/preview-docs/preview-server/ && \
cp packages/cli/src/commands/build-docs/template.hbs \
/usr/local/lib/node_modules/@redocly/cli/lib/commands/build-docs/ && \
# Clean up to reduce image size
npm cache clean --force && rm -rf /build

WORKDIR /spec

ENTRYPOINT [ "redocly" ]

ENTRYPOINT ["redocly"]
ENV REDOCLY_ENVIRONMENT=docker
4 changes: 4 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"description": "",
"license": "MIT",
"bin": {
"openapi": "bin/cli.js",
"redocly": "bin/cli.js"
"redocly": "bin/cli.js",
"openapi": "bin/cli.js"
},
"engines": {
"node": ">=18.17.0",
Expand Down
6 changes: 1 addition & 5 deletions packages/respect-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,5 @@
},
"files": [
"lib"
],
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
}
]
}
13 changes: 3 additions & 10 deletions scripts/local-pack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,23 @@ cp packages/core/package.json packages/core/package.json.bak
cp packages/respect-core/package.json packages/respect-core/package.json.bak
cp packages/cli/package.json packages/cli/package.json.bak

# Generate timestamp-based version
TIMESTAMP=$(date +%s)
VERSION="0.0.0-snapshot.$TIMESTAMP"

# Build and pack core package
cd packages/core
jq ".version = \"$VERSION\"" package.json > tmp.json && mv tmp.json package.json
core=$(npm pack | tail -n 1)
mv $core ../../openapi-core.tgz
cd ../../

# Update and pack respect-core package
cd packages/respect-core
jq ".version = \"$VERSION\"" package.json > tmp.json && mv tmp.json package.json
jq ".dependencies[\"@redocly/openapi-core\"] = \"./openapi-core.tgz\"" package.json > tmp.json && mv tmp.json package.json
jq '.dependencies["@redocly/openapi-core"] = "./openapi-core.tgz"' package.json > tmp.json && mv tmp.json package.json
respect_core=$(npm pack | tail -n 1)
mv $respect_core ../../respect-core.tgz
cd ../../

# Update and pack cli package
cd packages/cli
jq ".version = \"$VERSION\"" package.json > tmp.json && mv tmp.json package.json
jq ".dependencies[\"@redocly/openapi-core\"] = \"./openapi-core.tgz\"" package.json > tmp.json && mv tmp.json package.json
jq ".dependencies[\"@redocly/respect-core\"] = \"./respect-core.tgz\"" package.json > tmp.json && mv tmp.json package.json
jq '.dependencies["@redocly/openapi-core"] = "./openapi-core.tgz"' package.json > tmp.json && mv tmp.json package.json
jq '.dependencies["@redocly/respect-core"] = "./respect-core.tgz"' package.json > tmp.json && mv tmp.json package.json
cli=$(npm pack | tail -n 1)
mv $cli ../../redocly-cli.tgz
cd ../../
Expand Down

0 comments on commit 0d092b7

Please sign in to comment.