resume-cli icon indicating copy to clipboard operation
resume-cli copied to clipboard

Running on Docker for arm64

Open beaverden opened this issue 3 years ago • 11 comments

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 

beaverden avatar May 29 '21 18:05 beaverden

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.

paskal avatar Jun 09 '21 12:06 paskal

@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.

beaverden avatar Jun 09 '21 12:06 beaverden

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

thomasdavis avatar Jun 09 '21 13:06 thomasdavis

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

beaverden avatar Jun 09 '21 13:06 beaverden

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

riccio82 avatar Jun 18 '21 18:06 riccio82

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

beaverden avatar Jun 18 '21 18:06 beaverden

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/[email protected]        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 [email protected]: Package no longer supported. Contact [email protected] 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```

caraar12345 avatar Sep 14 '21 23:09 caraar12345

I think updating the puppeteer dependency resolves this

https://github.com/puppeteer/puppeteer/issues/6622#issuecomment-906476717

JohnMcSpedon avatar Dec 06 '21 08:12 JohnMcSpedon

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.

adrienjoly avatar Apr 29 '22 10:04 adrienjoly

I think updating the puppeteer dependency resolves this

puppeteer/puppeteer#6622 (comment)

Bump on this: because https://github.com/puppeteer/puppeteer/pull/7099 is closed, I think you would just need to update: https://github.com/jsonresume/resume-cli/blob/21d15f6feb58b689abdb0c740b07319cf5fc2133/package.json#L44 to the latest version

DbCrWk avatar Jul 06 '22 02:07 DbCrWk

https://github.com/jsonresume/resume-cli/pull/730 might fix this, when merged

tonypapousek avatar Oct 20 '22 21:10 tonypapousek