Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running on Docker for arm64 #590

Open
beaverden opened this issue May 29, 2021 · 11 comments
Open

Running on Docker for arm64 #590

beaverden opened this issue May 29, 2021 · 11 comments

Comments

@beaverden
Copy link

I tried to create a working build for resume export, so it also works on arm64 (where chrome fails to download), here is how I made it work

https://gist.github.com/beaverden/e8e9dead457eeb224afd71d86b032b00

# syntax=docker/dockerfile:1
FROM debian:buster as base0
RUN apt update -y
RUN apt upgrade -y
RUN apt install chromium -y
RUN apt install npm -y
RUN npm update -g

FROM base0 as base
# Ugly workaround for M1 ARM64
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser
ENV RESUME_PUPPETEER_NO_SANDBOX=1
RUN npm install -g resume-cli --unsafe-perm=true --allow-root
RUN npm install jsonresume-theme-even
RUN ln /usr/bin/chromium /usr/bin/chromium-browser

# Generate an initial resume.json
FROM base as init-base
WORKDIR /resume-init
RUN yes | resume init 

FROM scratch as init 
COPY --from=init-base /resume-init/resume.json resume.json

# Copy resume.json and build a pdf
FROM base as build-base
WORKDIR /resume 
COPY ./resume.json .
RUN resume export resume.pdf

FROM scratch as build-pdf
COPY --from=build-base /resume/resume.pdf resume.pdf 
@paskal
Copy link

paskal commented Jun 9, 2021

Here is Dockerfile for arm64 which works for me, I don't know for sure that build-pdf works but I assume it does, and it's less ugly.

@beaverden
Copy link
Author

beaverden commented Jun 9, 2021

@paskal I'm not sure why do you think it's less ugly, since you have, alongside your dockerfile, a docker-compose file that's twice the length, with hardcoded paths which does not properly represent services, but commands. And a sed to top it all up

I posted the Dockerfile since I spent a significant amount of time making chromium work on arm64 and the export option actually uses chromium to create a pdf. If you know a solution that makes the export command work under arm64 or have actual working (and tested) solutions that are better and more readable, please contribute by sharing them.

@thomasdavis
Copy link
Member

Thanks @beaverden, looks great, do you want to throw it up in a PR and we can continue discussion there?

@beaverden
Copy link
Author

I think this is a temporary solution since chromium builds should be available out of the box for arm64 at some point. I could make a PR for some documentation update as a temporary solution. CC @thomasdavis

@riccio82
Copy link

Thanks @beaverden !
I build the image with the command docker build . -t [name].
Now how can I use it?
Thank you for your help!

@beaverden
Copy link
Author

beaverden commented Jun 18, 2021

Hello, @riccio82

I am using the following makefile

clean:
	rm -rf build

init:
	docker build --target init -o build  .

pdf:
	docker build --target build-pdf --build-arg THEME=$(THEME) -o build .

server:
	docker build --target serve --build-arg THEME=$(THEME) -t resume-server .
	docker run --rm -p 4000:4000 -it resume-server

I am from my phone so can't check it, but the theme option might not be included in the dockerfile mentioned above, but the general gist is clear

Details here: https://github.com/beaverden/resume

@caraar12345
Copy link

Hey - it seems as though Chromium ARM64 builds are now available 👀

Updating Homebrew...
==> Auto-updated Homebrew!
Updated Homebrew from 5c602003f to 48bbc53fb.
Updated 9 taps (cloudflare/cloudflare, homebrew/core, homebrew/cask, homebrew/bundle, homebrew/cask-fonts, homebrew/services, dart-lang/dart, sass/sass and twilio/brew).
==> New Formulae
bat-extras                      jpdfbookmarks                   microsocks                      selene                          vespa-cli
dart-lang/dart/dart@2.13        librist                         osc-cli                         solana                          viu
==> Updated Formulae
Updated 394 formulae.
==> New Casks
epilogue-operator                       mathcha-notebook                        nimblenote                              remotion
==> Updated Casks
Updated 209 casks.

==> Downloading https://commondatastorage.googleapis.com/chromium-browser-snapshots/Mac_Arm/920567/chrome-mac.zip
######################################################################## 100.0%
==> Installing Cask chromium
==> Moving App 'Chromium.app' to '/Applications/Chromium.app'
==> Linking Binary 'chromium.wrapper.sh' to '/opt/homebrew/bin/chromium'
🍺  chromium was successfully installed!

Still doesn't work with npm install -g resume-cli however 😞

npm WARN deprecated nomnom@1.8.1: Package no longer supported. Contact support@npmjs.com for more info.
npm ERR! code 1
npm ERR! path /Users/aaroncarson/.nvm/versions/node/v14.17.6/lib/node_modules/resume-cli/node_modules/puppeteer
npm ERR! command failed
npm ERR! command sh -c node install.js
npm ERR! The chromium binary is not available for arm64:
npm ERR! If you are on Ubuntu, you can install with:
npm ERR!
npm ERR!  apt-get install chromium-browser
npm ERR!
npm ERR! /Users/aaroncarson/.nvm/versions/node/v14.17.6/lib/node_modules/resume-cli/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserFetcher.js:112
npm ERR!             throw new Error();
npm ERR!             ^
npm ERR!
npm ERR! Error
npm ERR!     at /Users/aaroncarson/.nvm/versions/node/v14.17.6/lib/node_modules/resume-cli/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserFetcher.js:112:19
npm ERR!     at FSReqCallback.oncomplete (fs.js:192:21)

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/aaroncarson/.npm/_logs/2021-09-14T23_19_03_527Z-debug.log```

@JohnMcSpedon
Copy link

I think updating the puppeteer dependency resolves this

puppeteer/puppeteer#6622 (comment)

@adrienjoly
Copy link

adrienjoly commented Apr 29, 2022

FYI, in order to solve this issue on my M1 Mac, I nvm use a version of Node that I have installed with rosetta2.

Cf https://gist.github.com/adrienjoly/e29a6e73fb7e701eefd80ff9bde9abeb#solution for instructions.

@DbCrWk
Copy link

DbCrWk commented Jul 6, 2022

I think updating the puppeteer dependency resolves this

puppeteer/puppeteer#6622 (comment)

Bump on this: because puppeteer/puppeteer#7099 is closed, I think you would just need to update:

"puppeteer": "^5.2.1",

to the latest version

@tonypapousek
Copy link
Contributor

tonypapousek commented Oct 20, 2022

#730 might fix this, when merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants