Page MenuHomePhabricator

[chronik-docs] Patch dockerfile so that chronik links are not broken
ClosedPublic

Authored by bytesofman on Apr 22 2024, 20:12.

Details

Summary

Testing CI deployments, docusaurus throws build errors in npm run build step as chronik links to chronik-client generated files are broken. This is because chronik-client did not build first. Missed bc was built locally.

Also get rid of the .abclatestversion.sample convention, and just keep a templated 0.0.0 .abclatestversion in the monorepo. This will be overwritten in CI for deployment. But, if we want to preview the site without adding any custom scripts, should have some kind of default file in place.

Test Plan

To test preview,

./contrib/teamcity/build-configurations.py preview-chronik.e.cash

To test prod,

create .abclatestversion in docs/chronik.e.cash with contents 0.29.2

Edit line 25 of modules/Dockerfile to read ARG NGINX_CONF=nginx-preview.conf, then

docker build -t chronik-docs_local .
docker run --rm -p 8080:80 --name chronik-docs chronik-docs_local

site is available at localhost:8080, links are not broken (the build will fail if there are broken links), and download & install links use 0.29.2

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

remove accidentally-generated files

Tail of the build log:

#16 13.15 npm WARN deprecated gulp-header@1.8.12: Removed event-stream from gulp-header
#16 13.23 npm WARN deprecated @babel/plugin-proposal-class-properties@7.18.6: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead.
#16 13.27 npm WARN deprecated stable@0.1.8: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility
#16 13.33 npm WARN deprecated @npmcli/move-file@2.0.1: This functionality has been moved to @npmcli/fs
#16 13.34 npm WARN deprecated @npmcli/move-file@1.1.2: This functionality has been moved to @npmcli/fs
#16 13.38 npm WARN deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated
#16 13.42 npm WARN deprecated acorn-dynamic-import@4.0.0: This is probably built in to whatever tool you're using. If you still need it... idk
#16 13.55 npm WARN deprecated sourcemap-codec@1.4.8: Please use @jridgewell/sourcemap-codec instead
#16 13.68 npm WARN deprecated source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated
#16 14.09 npm WARN deprecated @babel/plugin-proposal-object-rest-spread@7.20.7: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-object-rest-spread instead.
#16 14.22 npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
#16 14.82 npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
#16 15.02 npm WARN deprecated @babel/polyfill@7.12.1: 🚨 This package has been deprecated in favor of separate inclusion of a polyfill and regenerator-runtime (when needed). See the @babel/polyfill docs (https://babeljs.io/docs/en/babel-polyfill) for more information.
#16 15.17 npm WARN deprecated coffee-script@1.12.7: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)
#16 15.60 npm WARN deprecated svgo@1.3.2: This SVGO version is no longer supported. Upgrade to v2.x.x.
#16 15.62 npm WARN deprecated svgo@1.3.2: This SVGO version is no longer supported. Upgrade to v2.x.x.
#16 16.87 npm WARN deprecated highlight.js@9.18.5: Support has ended for 9.x series. Upgrade to @latest
#16 17.71 npm WARN deprecated core-js@2.6.12: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.
#16 19.78 
#16 19.78 added 2246 packages, and audited 2247 packages in 19s
#16 19.78 
#16 19.78 396 packages are looking for funding
#16 19.78   run `npm fund` for details
#16 19.81 
#16 19.81 75 vulnerabilities (47 moderate, 24 high, 4 critical)
#16 19.81 
#16 19.81 To address issues that do not require attention, run:
#16 19.81   npm audit fix
#16 19.81 
#16 19.81 To address all issues (including breaking changes), run:
#16 19.81   npm audit fix --force
#16 19.81 
#16 19.81 Run `npm audit` for details.
#16 DONE 20.3s

#17 [builder 10/11] COPY docs/chronik.e.cash/ .
#17 sha256:39ff3b8a695d03a60f2ee8def01ff635e67347f1ea280ce1de7eb1687fd2491e
#17 DONE 0.1s

#18 [builder 11/11] RUN npm run build
#18 sha256:7f20b44c5722184f311de5ad6400df1432071c8d14b765a6467bc8f47b61993a
#18 0.744 
#18 0.744 > chronik-docs@0.1.0 build
#18 0.744 > docusaurus build
#18 0.744 
#18 1.651 [INFO] [en] Creating an optimized production build...
#18 2.133 [info] Loaded plugin typedoc-plugin-markdown
#18 2.137 [warning] The entrypoint glob /chronik-client did not match any directories containing package.json.
#18 2.137 [error] Failed to find any packages, ensure you have provided at least one directory as an entry point containing package.json
#18 2.607 ℹ Compiling Client
#18 2.626 ℹ Compiling Server
#18 15.21 ✔ Client: Compiled with some errors in 12.61s
#18 15.22 [ERROR] Client bundle compiled with errors therefore further build is impossible.
#18 15.22 Module not found: Error: Can't resolve '../../.abclatestversion' in '/app/chronik.e.cash/docs/0-chronik-setup'
#18 ERROR: executor failed running [/bin/sh -c npm run build]: exit code: 1
------
 > [builder 11/11] RUN npm run build:
------
executor failed running [/bin/sh -c npm run build]: exit code: 1
Build preview-chronik.e.cash failed with exit code 1

keep .abclatestversion in the monorepo to support preview builds, update README and gitignore

Tail of the build log:

#18 15.32 ✔ Client: Compiled successfully in 12.75s
#18 17.83 ✔ Server: Compiled successfully in 15.24s
#18 17.83 [WARNING] {"moduleIdentifier":"/app/chronik.e.cash/node_modules/ws/lib/buffer-util.js","moduleName":"./node_modules/ws/lib/buffer-util.js","loc":"117:23-44","message":"Module not found: Error: Can't resolve 'bufferutil' in '/app/chronik.e.cash/node_modules/ws/lib'","compilerPath":"server"}
#18 17.83 [WARNING] {"moduleIdentifier":"/app/chronik.e.cash/node_modules/ws/lib/validation.js","moduleName":"./node_modules/ws/lib/validation.js","loc":"122:24-49","message":"Module not found: Error: Can't resolve 'utf-8-validate' in '/app/chronik.e.cash/node_modules/ws/lib'","compilerPath":"server"}
#18 20.52 
#18 20.53 
#18 20.53 Error: Unable to build website for locale en.
#18 20.53     at tryToBuildLocale (/app/chronik.e.cash/node_modules/@docusaurus/core/lib/commands/build.js:55:19)
#18 20.53     at async mapAsyncSequential (/app/chronik.e.cash/node_modules/@docusaurus/utils/lib/jsUtils.js:44:24)
#18 20.53     at async Command.build (/app/chronik.e.cash/node_modules/@docusaurus/core/lib/commands/build.js:82:21) {
#18 20.53   [cause]: Error: Docusaurus found broken links!
#18 20.53   
#18 20.53   Please check the pages of your site in the list below, and make sure you don't reference any path that does not exist.
#18 20.53   Note: it's possible to ignore broken links with the 'onBrokenLinks' Docusaurus configuration, and let the build pass.
#18 20.53   
#18 20.53   Exhaustive list of all broken links found:
#18 20.53   - Broken link on source page path = /chronik-js/addresses:
#18 20.53      -> linking to api/classes/ChronikClientNode#address (resolved as: /chronik-js/api/classes/ChronikClientNode#address)
#18 20.53      -> linking to api/classes/ChronikClientNode#script (resolved as: /chronik-js/api/classes/ChronikClientNode#script)
#18 20.53      -> linking to api/classes/ScriptEndpointInNode#history (resolved as: /chronik-js/api/classes/ScriptEndpointInNode#history)
#18 20.53      -> linking to api/classes/ScriptEndpointInNode#utxos (resolved as: /chronik-js/api/classes/ScriptEndpointInNode#utxos)
#18 20.53   - Broken link on source page path = /chronik-js/blockchain:
#18 20.53      -> linking to api/classes/ChronikClientNode#blockchaininfo (resolved as: /chronik-js/api/classes/ChronikClientNode#blockchaininfo)
#18 20.53      -> linking to api/classes/ChronikClientNode#chronikinfo (resolved as: /chronik-js/api/classes/ChronikClientNode#chronikinfo)
#18 20.53   - Broken link on source page path = /chronik-js/blocks:
#18 20.53      -> linking to api/classes/ChronikClientNode#blocks (resolved as: /chronik-js/api/classes/ChronikClientNode#blocks)
#18 20.53      -> linking to api/classes/ChronikClientNode#blocktxs (resolved as: /chronik-js/api/classes/ChronikClientNode#blocktxs)
#18 20.53   - Broken link on source page path = /chronik-js/broadcast-tx:
#18 20.53      -> linking to api/classes/ChronikClientNode#broadcasttx (resolved as: /chronik-js/api/classes/ChronikClientNode#broadcasttx)
#18 20.53      -> linking to api/classes/ChronikClientNode#broadcasttxs (resolved as: /chronik-js/api/classes/ChronikClientNode#broadcasttxs)
#18 20.53   - Broken link on source page path = /chronik-js/tokens:
#18 20.53      -> linking to api/classes/ChronikClientNode#token (resolved as: /chronik-js/api/classes/ChronikClientNode#token)
#18 20.53      -> linking to api/classes/ChronikClientNode#tokenid (resolved as: /chronik-js/api/classes/ChronikClientNode#tokenid)
#18 20.53      -> linking to api/classes/TokenIdEndpoint#history (resolved as: /chronik-js/api/classes/TokenIdEndpoint#history)
#18 20.53      -> linking to api/classes/TokenIdEndpoint#confirmedtxs (resolved as: /chronik-js/api/classes/TokenIdEndpoint#confirmedtxs)
#18 20.53      -> linking to api/classes/TokenIdEndpoint#unconfirmedtxs (resolved as: /chronik-js/api/classes/TokenIdEndpoint#unconfirmedtxs)
#18 20.53      -> linking to api/classes/TokenIdEndpoint#utxos (resolved as: /chronik-js/api/classes/TokenIdEndpoint#utxos)
#18 20.53   - Broken link on source page path = /chronik-js/txs:
#18 20.53      -> linking to api/classes/ChronikClientNode#tx (resolved as: /chronik-js/api/classes/ChronikClientNode#tx)
#18 20.53      -> linking to api/classes/ChronikClientNode#rawtx (resolved as: /chronik-js/api/classes/ChronikClientNode#rawtx)
#18 20.53   - Broken link on source page path = /chronik-js/websocket:
#18 20.53      -> linking to api/classes/ChronikClientNode#ws (resolved as: /chronik-js/api/classes/ChronikClientNode#ws)
#18 20.53      -> linking to api/classes/WsEndpoint_InNode#methods (resolved as: /chronik-js/api/classes/WsEndpoint_InNode#methods)
#18 20.53   
#18 20.53       at throwError (/app/chronik.e.cash/node_modules/@docusaurus/logger/lib/index.js:79:11)
#18 20.53       at reportBrokenLinks (/app/chronik.e.cash/node_modules/@docusaurus/core/lib/server/brokenLinks.js:242:47)
#18 20.53       at handleBrokenLinks (/app/chronik.e.cash/node_modules/@docusaurus/core/lib/server/brokenLinks.js:274:5)
#18 20.53       at buildLocale (/app/chronik.e.cash/node_modules/@docusaurus/core/lib/commands/build.js:192:47)
#18 20.53       at async tryToBuildLocale (/app/chronik.e.cash/node_modules/@docusaurus/core/lib/commands/build.js:46:20)
#18 20.53       at async mapAsyncSequential (/app/chronik.e.cash/node_modules/@docusaurus/utils/lib/jsUtils.js:44:24)
#18 20.53       at async Command.build (/app/chronik.e.cash/node_modules/@docusaurus/core/lib/commands/build.js:82:21)
#18 20.53 }
#18 20.53 [INFO] Docusaurus version: 3.1.1
#18 20.53 Node version: v20.12.2
#18 ERROR: executor failed running [/bin/sh -c npm run build]: exit code: 1
------
 > [builder 11/11] RUN npm run build:
------
executor failed running [/bin/sh -c npm run build]: exit code: 1
Build preview-chronik.e.cash failed with exit code 1

Tail of the build log:

#18 15.32 ✔ Client: Compiled successfully in 12.75s
#18 17.83 ✔ Server: Compiled successfully in 15.24s
#18 17.83 [WARNING] {"moduleIdentifier":"/app/chronik.e.cash/node_modules/ws/lib/buffer-util.js","moduleName":"./node_modules/ws/lib/buffer-util.js","loc":"117:23-44","message":"Module not found: Error: Can't resolve 'bufferutil' in '/app/chronik.e.cash/node_modules/ws/lib'","compilerPath":"server"}
#18 17.83 [WARNING] {"moduleIdentifier":"/app/chronik.e.cash/node_modules/ws/lib/validation.js","moduleName":"./node_modules/ws/lib/validation.js","loc":"122:24-49","message":"Module not found: Error: Can't resolve 'utf-8-validate' in '/app/chronik.e.cash/node_modules/ws/lib'","compilerPath":"server"}
#18 20.52 
#18 20.53 
#18 20.53 Error: Unable to build website for locale en.
#18 20.53     at tryToBuildLocale (/app/chronik.e.cash/node_modules/@docusaurus/core/lib/commands/build.js:55:19)
#18 20.53     at async mapAsyncSequential (/app/chronik.e.cash/node_modules/@docusaurus/utils/lib/jsUtils.js:44:24)
#18 20.53     at async Command.build (/app/chronik.e.cash/node_modules/@docusaurus/core/lib/commands/build.js:82:21) {
#18 20.53   [cause]: Error: Docusaurus found broken links!
#18 20.53   
#18 20.53   Please check the pages of your site in the list below, and make sure you don't reference any path that does not exist.
#18 20.53   Note: it's possible to ignore broken links with the 'onBrokenLinks' Docusaurus configuration, and let the build pass.
#18 20.53   
#18 20.53   Exhaustive list of all broken links found:
#18 20.53   - Broken link on source page path = /chronik-js/addresses:
#18 20.53      -> linking to api/classes/ChronikClientNode#address (resolved as: /chronik-js/api/classes/ChronikClientNode#address)
#18 20.53      -> linking to api/classes/ChronikClientNode#script (resolved as: /chronik-js/api/classes/ChronikClientNode#script)
#18 20.53      -> linking to api/classes/ScriptEndpointInNode#history (resolved as: /chronik-js/api/classes/ScriptEndpointInNode#history)
#18 20.53      -> linking to api/classes/ScriptEndpointInNode#utxos (resolved as: /chronik-js/api/classes/ScriptEndpointInNode#utxos)
#18 20.53   - Broken link on source page path = /chronik-js/blockchain:
#18 20.53      -> linking to api/classes/ChronikClientNode#blockchaininfo (resolved as: /chronik-js/api/classes/ChronikClientNode#blockchaininfo)
#18 20.53      -> linking to api/classes/ChronikClientNode#chronikinfo (resolved as: /chronik-js/api/classes/ChronikClientNode#chronikinfo)
#18 20.53   - Broken link on source page path = /chronik-js/blocks:
#18 20.53      -> linking to api/classes/ChronikClientNode#blocks (resolved as: /chronik-js/api/classes/ChronikClientNode#blocks)
#18 20.53      -> linking to api/classes/ChronikClientNode#blocktxs (resolved as: /chronik-js/api/classes/ChronikClientNode#blocktxs)
#18 20.53   - Broken link on source page path = /chronik-js/broadcast-tx:
#18 20.53      -> linking to api/classes/ChronikClientNode#broadcasttx (resolved as: /chronik-js/api/classes/ChronikClientNode#broadcasttx)
#18 20.53      -> linking to api/classes/ChronikClientNode#broadcasttxs (resolved as: /chronik-js/api/classes/ChronikClientNode#broadcasttxs)
#18 20.53   - Broken link on source page path = /chronik-js/tokens:
#18 20.53      -> linking to api/classes/ChronikClientNode#token (resolved as: /chronik-js/api/classes/ChronikClientNode#token)
#18 20.53      -> linking to api/classes/ChronikClientNode#tokenid (resolved as: /chronik-js/api/classes/ChronikClientNode#tokenid)
#18 20.53      -> linking to api/classes/TokenIdEndpoint#history (resolved as: /chronik-js/api/classes/TokenIdEndpoint#history)
#18 20.53      -> linking to api/classes/TokenIdEndpoint#confirmedtxs (resolved as: /chronik-js/api/classes/TokenIdEndpoint#confirmedtxs)
#18 20.53      -> linking to api/classes/TokenIdEndpoint#unconfirmedtxs (resolved as: /chronik-js/api/classes/TokenIdEndpoint#unconfirmedtxs)
#18 20.53      -> linking to api/classes/TokenIdEndpoint#utxos (resolved as: /chronik-js/api/classes/TokenIdEndpoint#utxos)
#18 20.53   - Broken link on source page path = /chronik-js/txs:
#18 20.53      -> linking to api/classes/ChronikClientNode#tx (resolved as: /chronik-js/api/classes/ChronikClientNode#tx)
#18 20.53      -> linking to api/classes/ChronikClientNode#rawtx (resolved as: /chronik-js/api/classes/ChronikClientNode#rawtx)
#18 20.53   - Broken link on source page path = /chronik-js/websocket:
#18 20.53      -> linking to api/classes/ChronikClientNode#ws (resolved as: /chronik-js/api/classes/ChronikClientNode#ws)
#18 20.53      -> linking to api/classes/WsEndpoint_InNode#methods (resolved as: /chronik-js/api/classes/WsEndpoint_InNode#methods)
#18 20.53   
#18 20.53       at throwError (/app/chronik.e.cash/node_modules/@docusaurus/logger/lib/index.js:79:11)
#18 20.53       at reportBrokenLinks (/app/chronik.e.cash/node_modules/@docusaurus/core/lib/server/brokenLinks.js:242:47)
#18 20.53       at handleBrokenLinks (/app/chronik.e.cash/node_modules/@docusaurus/core/lib/server/brokenLinks.js:274:5)
#18 20.53       at buildLocale (/app/chronik.e.cash/node_modules/@docusaurus/core/lib/commands/build.js:192:47)
#18 20.53       at async tryToBuildLocale (/app/chronik.e.cash/node_modules/@docusaurus/core/lib/commands/build.js:46:20)
#18 20.53       at async mapAsyncSequential (/app/chronik.e.cash/node_modules/@docusaurus/utils/lib/jsUtils.js:44:24)
#18 20.53       at async Command.build (/app/chronik.e.cash/node_modules/@docusaurus/core/lib/commands/build.js:82:21)
#18 20.53 }
#18 20.53 [INFO] Docusaurus version: 3.1.1
#18 20.53 Node version: v20.12.2
#18 ERROR: executor failed running [/bin/sh -c npm run build]: exit code: 1
------
 > [builder 11/11] RUN npm run build:
------
executor failed running [/bin/sh -c npm run build]: exit code: 1
Build preview-chronik.e.cash failed with exit code 1

This is the error was seeing in CI before this diff. I'm not sure if it's bc we are still using the old version of this Dockerfile, or bc the preview CI is not using the modules/ Dockerfile.

bytesofman edited the summary of this revision. (Show Details)
Fabien requested changes to this revision.Apr 23 2024, 08:42
Fabien added a subscriber: Fabien.

The port in the build-configurations.yml is set to 3000 but this Dockerfile create a nginx container using the default port (80). You should remove the port line in the build config.

modules/Dockerfile
15 ↗(On Diff #47376)
29 ↗(On Diff #47376)
modules/docs/chronik.e.cash/.abclatestversion
1 ↗(On Diff #47376)

You still don't need to add this file to the repo. Just create it if needed via the Dockerfile (you can use an ARG to get the version, or copy a sample file as a source). Make sure to not override any existing file so the user can create its own.

modules/docs/chronik.e.cash/.gitignore
27 ↗(On Diff #47376)

See above, you can restore

modules/docs/chronik.e.cash/README.md
11 ↗(On Diff #47376)
This revision now requires changes to proceed.Apr 23 2024, 08:42
bytesofman marked 3 inline comments as done.

update Dockerfile, fix preview yaml, test preview and ci prod builds

Fabien requested changes to this revision.Apr 23 2024, 14:19

Noticed during testing: the .abclatestversion.sample file has a newline which is causing a line break in the file name. Remove the line break, and better trim the content as well when generating the content.

contrib/teamcity/build-configurations.yml
947 ↗(On Diff #47379)

Remove, see other comment

modules/Dockerfile
21–26 ↗(On Diff #47379)

You don't need both a file and an env to specify a file. Either use a file or the version in an env.

The suggested change uses the sample file. It copies it as well as any .abclatestversion if it exists, and rename the sample file if no .abclatestversion was copied. That way there is always a version file, either the sample or the user supplied one.

This revision now requires changes to proceed.Apr 23 2024, 14:19
bytesofman marked 2 inline comments as done.

Improve handling of .abclatestversion in docker script (no need for arg)

This revision is now accepted and ready to land.Apr 23 2024, 18:32