api3dao / api3-dao-dashboard

API3 DAO dashboard
api3.eth/
14 stars 10 forks source link

Docker build fails for production branch #352

Closed dcroote closed 2 years ago

dcroote commented 2 years ago

Three issues. Since we advertise users should be able to build the production image, what about adding a Docker build CI Action for production push / PR / cron to alert us of Docker build issues?

Issue 1

Relates to #328. I'm on WSL2 and received the below error when trying to build the latest production branch image. I was able to fix this issue by borrowing from the current line in the main branch and using:

RUN apk add --update --no-cache git python3 make g++

Error:

> docker build --tag api3-dao-dashboard .
[+] Building 347.9s (11/13)
 => [internal] load build definition from Dockerfile                                                 0.1s
 => => transferring dockerfile: 38B                                                                  0.0s
 => [internal] load .dockerignore                                                                    0.1s
 => => transferring context: 34B                                                                     0.0s
 => [internal] load metadata for docker.io/library/nginx:alpine                                     21.6s
 => [internal] load metadata for docker.io/library/node:lts-alpine                                  28.4s
 => [builder 1/6] FROM docker.io/library/node:lts-alpine@sha256:1f09c210a17508d34277971b19541a47a26  0.0s
 => CACHED [stage-1 1/2] FROM docker.io/library/nginx:alpine@sha256:2452715dd322b3273419652b7721b64  0.0s
 => [internal] load build context                                                                    0.1s
 => => transferring context: 19.42kB                                                                 0.0s
 => CACHED [builder 2/6] RUN apk add --no-cache git                                                  0.0s
 => CACHED [builder 3/6] WORKDIR /usr/src/app                                                        0.0s
 => CACHED [builder 4/6] ADD . .                                                                     0.0s
 => ERROR [builder 5/6] RUN yarn                                                                   319.2s
------
 > [builder 5/6] RUN yarn:
#11 0.698 yarn install v1.22.19
#11 0.966 [1/4] Resolving packages...
#11 3.059 [2/4] Fetching packages...
#11 125.1 [3/4] Linking dependencies...
#11 125.1 warning "@walletconnect/web3-provider > web3-provider-engine > eth-block-tracker > @babel/plugin-transform-runtime@7.13.15" has unmet peer dependency "@babel/core@^7.0.0-0".
#11 125.1 warning "@walletconnect/web3-provider > web3-provider-engine > eth-block-tracker > @babel/plugin-transform-runtime > babel-plugin-polyfill-corejs2 > @babel/helper-define-polyfill-provider@0.2.0" has unme
t peer dependency "@babel/core@^7.4.0-0".
#11 125.1 warning "web3modal > styled-components@5.3.3" has unmet peer dependency "react-is@>= 16.8.0".
#11 125.1 warning " > @testing-library/user-event@13.5.0" has unmet peer dependency "@testing-library/dom@>=7.21.4".
#11 125.1 warning " > @typechain/ethers-v5@8.0.5" has unmet peer dependency "@ethersproject/bytes@^5.0.0".
#11 125.1 warning " > @typechain/ethers-v5@8.0.5" has unmet peer dependency "@ethersproject/providers@^5.0.0".
#11 125.1 warning " > @typechain/ethers-v5@8.0.5" has unmet peer dependency "@ethersproject/abi@^5.0.0".
#11 246.8 warning abbrev@1.1.0: Invalid bin field for "abbrev".
#11 246.8 warning ansicolors@0.3.2: Invalid bin field for "ansicolors".
#11 246.8 warning ansistyles@0.1.3: Invalid bin field for "ansistyles".
#11 246.8 warning archy@1.0.0: Invalid bin field for "archy".
#11 246.8 warning call-limit@1.1.0: Invalid bin field for "call-limit".
#11 246.8 warning bluebird@3.5.0: Invalid bin field for "bluebird".
#11 246.8 warning chownr@1.0.1: Invalid bin field for "chownr".
#11 246.8 warning cmd-shim@2.0.2: Invalid bin field for "cmd-shim".
#11 246.8 warning columnify@1.5.4: Invalid bin field for "columnify".
#11 246.9 warning config-chain@1.1.11: Invalid bin field for "config-chain".
#11 246.9 warning debuglog@1.0.1: Invalid bin field for "debuglog".
#11 246.9 warning detect-indent@5.0.0: Invalid bin field for "detect-indent".
#11 246.9 warning dezalgo@1.0.3: Invalid bin field for "dezalgo".
#11 246.9 warning editor@1.0.0: Invalid bin field for "editor".
#11 246.9 warning fs-vacuum@1.2.10: Invalid bin field for "fs-vacuum".
#11 246.9 warning fs-write-stream-atomic@1.0.10: Invalid bin field for "fs-write-stream-atomic".
#11 246.9 warning fstream@1.0.11: Invalid bin field for "fstream".
#11 246.9 warning graceful-fs@4.1.11: Invalid bin field for "graceful-fs".
#11 246.9 warning has-unicode@2.0.1: Invalid bin field for "has-unicode".
#11 246.9 warning iferr@0.1.5: Invalid bin field for "iferr".
#11 246.9 warning imurmurhash@0.1.4: Invalid bin field for "imurmurhash".
#11 246.9 warning inflight@1.0.6: Invalid bin field for "inflight".
#11 246.9 warning inherits@2.0.3: Invalid bin field for "inherits".
#11 246.9 warning ini@1.3.4: Invalid bin field for "ini".
#11 246.9 warning init-package-json@1.10.1: Invalid bin field for "init-package-json".
#11 246.9 warning lazy-property@1.0.0: Invalid bin field for "lazy-property".
#11 246.9 warning lockfile@1.0.3: Invalid bin field for "lockfile".
#11 246.9 warning lodash._baseindexof@3.1.0: Invalid bin field for "lodash._baseindexof".
#11 246.9 warning lodash._baseuniq@4.6.0: Invalid bin field for "lodash._baseuniq".
#11 246.9 warning lodash._bindcallback@3.0.1: Invalid bin field for "lodash._bindcallback".
#11 246.9 warning lodash._cacheindexof@3.0.2: Invalid bin field for "lodash._cacheindexof".
#11 246.9 warning lodash._createcache@3.1.2: Invalid bin field for "lodash._createcache".
#11 246.9 warning lodash._getnative@3.9.1: Invalid bin field for "lodash._getnative".
#11 246.9 warning lodash.clonedeep@4.5.0: Invalid bin field for "lodash.clonedeep".
#11 246.9 warning lodash.restparam@3.6.1: Invalid bin field for "lodash.restparam".
#11 246.9 warning lodash.union@4.6.0: Invalid bin field for "lodash.union".
#11 246.9 warning lodash.uniq@4.5.0: Invalid bin field for "lodash.uniq".
#11 246.9 warning lodash.without@4.4.0: Invalid bin field for "lodash.without".
#11 246.9 warning mississippi@1.3.0: Invalid bin field for "mississippi".
#11 246.9 warning move-concurrently@1.0.1: Invalid bin field for "move-concurrently".
#11 247.0 warning npm-cache-filename@1.0.2: Invalid bin field for "npm-cache-filename".
#11 247.0 warning npm-install-checks@3.0.0: Invalid bin field for "npm-install-checks".
#11 247.0 warning once@1.4.0: Invalid bin field for "once".
#11 247.0 warning osenv@0.1.4: Invalid bin field for "osenv".
#11 247.0 warning path-is-inside@1.0.2: Invalid bin field for "path-is-inside".
#11 247.0 warning promise-inflight@1.0.1: Invalid bin field for "promise-inflight".
#11 247.0 warning read@1.0.7: Invalid bin field for "read".
#11 247.0 warning read-cmd-shim@1.0.1: Invalid bin field for "read-cmd-shim".
#11 247.0 warning read-installed@4.0.3: Invalid bin field for "read-installed".
#11 247.0 warning readdir-scoped-modules@1.0.2: Invalid bin field for "readdir-scoped-modules".
#11 247.0 warning retry@0.10.1: Invalid bin field for "retry".
#11 247.1 warning sha@2.0.1: Invalid bin field for "sha".
#11 247.1 warning slide@1.1.6: Invalid bin field for "slide".
#11 247.1 warning sorted-object@2.0.1: Invalid bin field for "sorted-object".
#11 247.1 warning sorted-union-stream@2.1.3: Invalid bin field for "sorted-union-stream".
#11 247.1 warning tar@2.2.1: Invalid bin field for "tar".
#11 247.1 warning text-table@0.2.0: Invalid bin field for "text-table".
#11 247.1 warning uid-number@0.0.6: Invalid bin field for "uid-number".
#11 247.1 warning umask@1.1.0: Invalid bin field for "umask".
#11 247.1 warning unique-filename@1.1.0: Invalid bin field for "unique-filename".
#11 247.1 warning unpipe@1.0.0: Invalid bin field for "unpipe".
#11 247.1 warning validate-npm-package-license@3.0.1: Invalid bin field for "validate-npm-package-license".
#11 247.1 warning validate-npm-package-name@3.0.0: Invalid bin field for "validate-npm-package-name".
#11 247.1 warning wrappy@1.0.2: Invalid bin field for "wrappy".
#11 248.7 [4/4] Building fresh packages...
#11 287.0 error /usr/src/app/node_modules/node-sass: Command failed.
#11 287.0 Exit code: 1
#11 287.0 Command: node scripts/build.js
#11 287.0 Arguments:
#11 287.0 Directory: /usr/src/app/node_modules/node-sass
#11 287.0 Output:
#11 287.0 Building: /usr/local/bin/node /usr/src/app/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
#11 287.0 gyp info it worked if it ends with ok
#11 287.0 gyp verb cli [
#11 287.0 gyp verb cli   '/usr/local/bin/node',
#11 287.0 gyp verb cli   '/usr/src/app/node_modules/node-gyp/bin/node-gyp.js',
#11 287.0 gyp verb cli   'rebuild',
#11 287.0 gyp verb cli   '--verbose',
#11 287.0 gyp verb cli   '--libsass_ext=',
#11 287.0 gyp verb cli   '--libsass_cflags=',
#11 287.0 gyp verb cli   '--libsass_ldflags=',
#11 287.0 gyp verb cli   '--libsass_library='
#11 287.0 gyp verb cli ]
#11 287.0 gyp info using node-gyp@8.4.1
#11 287.0 gyp info using node@18.12.0 | linux | x64
#11 287.0 gyp verb command rebuild []
#11 287.0 gyp verb command clean []
#11 287.0 gyp verb clean removing "build" directory
#11 287.0 gyp verb command configure []
#11 287.0 gyp verb find Python Python is not set from command line or npm configuration
#11 287.0 gyp verb find Python Python is not set from environment variable PYTHON
#11 287.0 gyp verb find Python checking if "python3" can be used
#11 287.0 gyp verb find Python - executing "python3" to get executable path
#11 287.0 gyp verb find Python - "python3" is not in PATH or produced an error
#11 287.0 gyp verb find Python checking if "python" can be used
#11 287.0 gyp verb find Python - executing "python" to get executable path
#11 287.0 gyp verb find Python - "python" is not in PATH or produced an error
#11 287.0 gyp ERR! find Python
#11 287.0 gyp ERR! find Python Python is not set from command line or npm configuration
#11 287.0 gyp ERR! find Python Python is not set from environment variable PYTHON
#11 287.0 gyp ERR! find Python checking if "python3" can be used
#11 287.0 gyp ERR! find Python - "python3" is not in PATH or produced an error
#11 287.0 gyp ERR! find Python checking if "python" can be used
#11 287.0 gyp ERR! find Python - "python" is not in PATH or produced an error
#11 287.0 gyp ERR! find Python
#11 287.0 gyp ERR! find Python **********************************************************
#11 287.0 gyp ERR! find Python You need to install the latest version of Python.
#11 287.0 gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
#11 287.0 gyp ERR! find Python you can try one of the following options:
#11 287.0 gyp ERR! find Python - Use the switch --python="/path/to/pythonexecutable"
#11 287.0 gyp ERR! find Python   (accepted by both node-gyp and npm)
#11 287.0 gyp ERR! find Python - Set the environment variable PYTHON
#11 287.0 gyp ERR! find Python - Set the npm configuration variable python:
#11 287.0 gyp ERR! find Python   npm config set python "/path/to/pythonexecutable"
#11 287.0 gyp ERR! find Python For more information consult the documentation at:
#11 287.0 gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
#11 287.0 gyp ERR! find Python **********************************************************
#11 287.0 gyp ERR! find Python
#11 287.0 gyp ERR! configure error
#11 287.0 gyp ERR! stack Error: Could not find any Python installation to use
#11 287.0 gyp ERR! stack     at PythonFinder.fail (/usr/src/app/node_modules/node-gyp/lib/find-python.js:330:47)
#11 287.0 gyp ERR! stack     at PythonFinder.runChecks (/usr/src/app/node_modules/node-gyp/lib/find-python.js:159:21)
#11 287.0 gyp ERR! stack     at PythonFinder.<anonymous> (/usr/src/app/node_modules/node-gyp/lib/find-python.js:202:16)
#11 287.0 gyp ERR! stack     at PythonFinder.execFileCallback (/usr/src/app/node_modules/node-gyp/lib/find-python.js:294:16)
#11 287.0 gyp ERR! stack     at exithandler (node:child_process:420:5)
#11 287.0 gyp ERR! stack     at ChildProcess.errorhandler (node:child_process:432:5)
#11 287.0 gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
#11 287.0 gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:289:12)
#11 287.0 gyp ERR! stack     at onErrorNT (node:internal/child_process:476:16)
#11 287.0 gyp ERR! stack     at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
#11 287.0 gyp ERR! System Linux 4.19.104-microsoft-standard
#11 287.0 gyp ERR! command "/usr/local/bin/node" "/usr/src/app/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
#11 287.0 gyp ERR! cwd /usr/src/app/node_modules/node-sass
#11 287.0 gyp ERR! node -v v18.12.0
#11 287.0 gyp ERR! node-gyp -v v8.4.1
#11 287.0 gyp ERR! not ok
#11 287.0 Build failed with error code: 1
#11 287.0 info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
------
executor failed running [/bin/sh -c yarn]: exit code: 1

Issue 2

Then I encountered an issue with webpack / openssl that was solved with the following yarn build line adjusted (Solution 3 here):

RUN export NODE_OPTIONS=--openssl-legacy-provider && yarn build

Error:

 > [builder 6/6] RUN yarn build:
#12 0.579 yarn run v1.22.19
#12 0.640 $ react-scripts build
#12 16.82 Creating an optimized production build...
#12 26.28 Error: error:0308010C:digital envelope routines::unsupported
#12 26.28     at new Hash (node:internal/crypto/hash:71:19)
#12 26.28     at Object.createHash (node:crypto:133:10)
#12 26.28     at module.exports (/usr/src/app/node_modules/webpack/lib/util/createHash.js:135:53)
#12 26.28     at NormalModule._initBuildHash (/usr/src/app/node_modules/webpack/lib/NormalModule.js:417:16)
#12 26.28     at handleParseError (/usr/src/app/node_modules/webpack/lib/NormalModule.js:471:10)
#12 26.28     at /usr/src/app/node_modules/webpack/lib/NormalModule.js:503:5
#12 26.28     at /usr/src/app/node_modules/webpack/lib/NormalModule.js:358:12
#12 26.28     at /usr/src/app/node_modules/loader-runner/lib/LoaderRunner.js:373:3
#12 26.28     at iterateNormalLoaders (/usr/src/app/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
#12 26.28     at iterateNormalLoaders (/usr/src/app/node_modules/loader-runner/lib/LoaderRunner.js:221:10)
#12 26.28     at /usr/src/app/node_modules/loader-runner/lib/LoaderRunner.js:236:3
#12 26.28     at runSyncOrAsync (/usr/src/app/node_modules/loader-runner/lib/LoaderRunner.js:130:11)
#12 26.28     at iterateNormalLoaders (/usr/src/app/node_modules/loader-runner/lib/LoaderRunner.js:232:2)
#12 26.28     at Array.<anonymous> (/usr/src/app/node_modules/loader-runner/lib/LoaderRunner.js:205:4)
#12 26.28     at Storage.finished (/usr/src/app/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:55:16)
#12 26.28     at /usr/src/app/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:91:9
#12 26.30 /usr/src/app/node_modules/react-scripts/scripts/build.js:19
#12 26.30   throw err;
#12 26.30   ^
#12 26.30
#12 26.30 Error: error:0308010C:digital envelope routines::unsupported
#12 26.30     at new Hash (node:internal/crypto/hash:71:19)
#12 26.30     at Object.createHash (node:crypto:133:10)
#12 26.30     at module.exports (/usr/src/app/node_modules/webpack/lib/util/createHash.js:135:53)
#12 26.30     at NormalModule._initBuildHash (/usr/src/app/node_modules/webpack/lib/NormalModule.js:417:16)
#12 26.30     at /usr/src/app/node_modules/webpack/lib/NormalModule.js:452:10
#12 26.30     at /usr/src/app/node_modules/webpack/lib/NormalModule.js:323:13
#12 26.30     at /usr/src/app/node_modules/loader-runner/lib/LoaderRunner.js:367:11
#12 26.30     at /usr/src/app/node_modules/loader-runner/lib/LoaderRunner.js:233:18
#12 26.30     at context.callback (/usr/src/app/node_modules/loader-runner/lib/LoaderRunner.js:111:13)
#12 26.30     at /usr/src/app/node_modules/react-scripts/node_modules/babel-loader/lib/index.js:59:103 {
#12 26.30   opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
#12 26.30   library: 'digital envelope routines',
#12 26.30   reason: 'unsupported',
#12 26.30   code: 'ERR_OSSL_EVP_UNSUPPORTED'
#12 26.30 }
#12 26.30
#12 26.30 Node.js v18.12.0
#12 26.91 error Command failed with exit code 1.
#12 26.91 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
------
executor failed running [/bin/sh -c yarn build]: exit code: 1

Issue 3

I then hit

...
#11 439.1 Command: "cd src/contract-deployments && cp localhost-dao.example.json localhost-dao.json"
#11 439.3 Fixing contract imports...
#11 439.3 Command: "yarn replace-in-file @api3-dao/pool/contracts ../pool-contracts-symlink hardhat/contracts/voting-contracts-symlink/Api3Voting.sol"
#11 439.7 Command: "yarn replace-in-file @api3-dao/pool/contracts ../pool-contracts-symlink hardhat/contracts/convenience-contracts-symlink/Convenience.sol"
#11 440.2 Command: "yarn replace-in-file @api3-dao/api3-voting/interfaces ../voting-interfaces-symlink hardhat/contracts/convenience-contracts-symlink/Convenience.sol"
#11 440.6 Command: "yarn replace-in-file 0.6.12 0.8.4 $(find hardhat/contracts -type f -follow)"
#11 441.1 Fixing timelock manager issues...
#11 441.1 Replacing "../interfaces/v0.8.4..." with "../api3-pool-interfa..."
#11 441.1 Replacing "@openzeppelin/contra..." with "@openzeppelin/contra..."
#11 441.1 Replacing "/now/g" with "block.timestamp"
#11 441.1 Compiling contracts...
#11 441.1 Command: "cd /usr/src/app/hardhat && npx hardhat compile"
#11 463.1 Generating typechain wrappers...
#11 463.1 Command: "yarn typechain --target ethers-v5 --out-dir ./src/generated-contracts './hardhat/artifacts/contracts/**/!(*.dbg).json'"
#11 464.3 Error: Command failed: yarn typechain --target ethers-v5 --out-dir ./src/generated-contracts './hardhat/artifacts/contracts/**/!(*.dbg).json'
#11 464.3 Error occured:  No files passed.
#11 464.3 `./hardhat/artifacts/contracts/**/!(*.dbg).json` didn't match any input files in /usr/src/app
#11 464.3 Run with --show-stack-traces to see the full stacktrace
#11 464.3 error Command failed with exit code 1.
#11 464.3
#11 464.3 error Command failed with exit code 1.
#11 464.3 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
#11 464.4 error Command failed with exit code 1.
#11 464.4 info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
------
executor failed running [/bin/sh -c yarn]: exit code: 1
mcoetzee commented 2 years ago

I took a quick look and I think the original problem is that node-sass isn't installing on node 18: https://stackoverflow.com/questions/72474004/node-sass-install-error-with-node-18-version

node-sass is deprecated so we've replaced it with sass already, but that change is sitting on the main branch. Have you tried using node 16? The fleek/create-react-app docker image uses node 16 so we should probably stick to 16 in our Dockerfile as well.

I think you might have success if you:

  1. clone main instead of production (@Siegrift 's Dockerfile fixes in https://github.com/api3dao/api3-dao-dashboard/pull/328 haven't merged into production)
    git clone --depth=1 --branch main https://github.com/api3dao/api3-dao-dashboard.git
  2. use node 16 in the Dockerfile (node:16-alpine)
  3. docker build --tag api3-dao-dashboard .

If I do the above I no longer get a node-sass install error, but I do get stuck on => # [4/4] Building fresh packages... for some reason.

dcroote commented 2 years ago

I have good news: all it took was pinning to node:16-alpine- no switching to main, no addition of python3 make g++, and no export NODE_OPTIONS=--openssl-legacy-provider hack. Great suggestion.

mcoetzee commented 2 years ago

Excellent 👍

dcroote commented 2 years ago

Closed by #353