jsonresume / resume-cli

CLI tool to easily setup a new resume 📑
https://jsonresume.org
MIT License
4.52k stars 379 forks source link

Running on Docker for arm64 #590

Open beaverden opened 3 years ago

beaverden commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

@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 commented 3 years ago

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

beaverden commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 2 years ago

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 commented 2 years ago

I think updating the puppeteer dependency resolves this

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

adrienjoly commented 2 years ago

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 commented 2 years ago

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

tonypapousek commented 1 year ago

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