Skip to content

Issue building docker container on M1 #26

@camfairchild

Description

@camfairchild

I keep coming across an error building the dockerfile on an M1 Pro.
This was due to not being able to install chromium for arm64.

 => ERROR [polkascan/explorer-ui builder  4/24] RUN npm i                                                          108.3s
------
 > [polkascan/explorer-ui builder  4/24] RUN npm i:
#0 79.88 npm WARN deprecated @npmcli/move-file@2.0.1: This functionality has been moved to @npmcli/fs
#0 107.6 npm notice 
#0 107.6 npm notice New minor version of npm available! 9.5.0 -> 9.6.0
#0 107.6 npm notice Changelog: <https://github.com/npm/cli/releases/tag/v9.6.0>
#0 107.6 npm notice Run `npm install -g npm@9.6.0` to update!
#0 107.6 npm notice 
#0 107.6 npm ERR! code 1
#0 107.6 npm ERR! path /app/polkadapt/node_modules/puppeteer
#0 107.6 npm ERR! command failed
#0 107.6 npm ERR! command sh -c node install.js
#0 107.6 npm ERR! The chromium binary is not available for arm64.
#0 107.6 npm ERR! If you are on Ubuntu, you can install with: 
#0 107.6 npm ERR! 
#0 107.6 npm ERR!  sudo apt install chromium
#0 107.6 npm ERR! 
#0 107.6 npm ERR! 
#0 107.6 npm ERR!  sudo apt install chromium-browser
#0 107.6 npm ERR! 
#0 107.6 npm ERR! ERROR: Failed to set up Chromium r1095492! Set "PUPPETEER_SKIP_DOWNLOAD" env variable to skip download.
#0 107.6 npm ERR! Error
#0 107.6 npm ERR!     at handleArm64 (/app/polkadapt/node_modules/puppeteer-core/lib/cjs/puppeteer/node/BrowserFetcher.js:137:11)
#0 107.6 npm ERR!     at BrowserFetcher.download (/app/polkadapt/node_modules/puppeteer-core/lib/cjs/puppeteer/node/BrowserFetcher.js:284:13)
#0 107.6 npm ERR!     at async downloadBrowser (/app/polkadapt/node_modules/puppeteer/lib/cjs/puppeteer/node/install.js:61:5)
#0 107.6 
#0 107.6 npm ERR! A complete log of this run can be found in:
#0 107.6 npm ERR!     /root/.npm/_logs/2023-03-03T00_30_48_200Z-debug-0.log

See: https://stackoverflow.com/a/72291691/7101091
I was able to fix it using

diff --git a/explorer-ui/Dockerfile b/explorer-ui/Dockerfile
index 4a5c777..29afd6b 100644
--- a/explorer-ui/Dockerfile
+++ b/explorer-ui/Dockerfile
@@ -2,6 +2,12 @@
 
 FROM node:lts as builder
 
+RUN apt update
+RUN apt install -y chromium
+
+# skips puppeteer installing chrome and points to correct binary
+ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
+
 # The application depends on PolkADAPT, so we have to install and build PolkADAPT first.
 
 WORKDIR /app/polkadapt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions