leoncvlt / loconotion

📄 Python tool to turn Notion.so pages into lightweight, customizable static websites
838 stars 132 forks source link

Docker build loconotion failed. #137

Open ngbao161199 opened 1 year ago

ngbao161199 commented 1 year ago

Hi @leoncvlt

I setup my yml like this

name: Publish Notion website to GitHub Pages

on:
  # Manual update only.
  workflow_dispatch:

permissions:
  contents: write

jobs:
    deploy:
      runs-on: ubuntu-latest

      steps:
        - name: Checkout loconotion
          uses: actions/checkout@v3
          with:
            repository: leoncvlt/loconotion
            path: loconotion
        - name: Checkout this repo
          uses: actions/checkout@v3
          with:
            path: pages_repo

        - name: Build Loconotion docker image
          run: docker-compose build loconotion
          working-directory: loconotion

        - name: Run Loconotion
          run: |
            docker run \
            -v "$GITHUB_WORKSPACE/pages_repo/dist:/app/loconotion/dist" \
            -v "$GITHUB_WORKSPACE/pages_repo/site.toml:/app/loconotion/site.toml" \
            loconotion "site.toml"
          working-directory: loconotion
        - name: Push to GitHub pages
          run: |
            git config --global user.name "github-actions[bot]"
            git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"

            GIT_DEPLOY_DIR=dist/site \
            GIT_DEPLOY_BRANCH=gh-pages \
            GIT_DEPLOY_REPO="https://${{ github.token }}@github.com/${{ github.repository }}.git" ./deploy.sh
          working-directory: pages_repo

However, I got this error from run: docker-compose build loconotion. Do u know how to fix it?

ERROR: failed to solve: process "/bin/sh -c wget --no-verbose -O /tmp/chrome.deb [https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_${CHROME_VERSION}_amd64.deb](https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_$%7BCHROME_VERSION%7D_amd64.deb)   && apt install -y /tmp/chrome.deb   && rm /tmp/chrome.deb" did not complete successfully: exit code: 8
Service 'loconotion' failed to build : Build failed
Error: Process completed with exit code 1.
Trost123 commented 1 year ago

Looks like this happens because the crome download link is broken (404):

https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_99.0.4844.74-1_amd64.deb

Maybe it's possible to bump the "chrome version" variable.

Trost123 commented 1 year ago

As I understand this is the file where the no longer valid chrome version is set:

https://github.com/leoncvlt/loconotion/blob/eb86257da02c5f540a5336b4bc11b69a038c2633/docker/Dockerfile#L17

ngbao161199 commented 1 year ago

Looks like this happens because the crome download link is broken (404):

https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_99.0.4844.74-1_amd64.deb

Maybe it's possible to bump the "chrome version" variable.

Maybe we can use this alternative link? @Trost123 http://mirror.cs.uchicago.edu/google-chrome/pool/main/g/google-chrome-stable/google-chrome-stable_99.0.4844.51-1_amd64.deb

ngbao161199 commented 1 year ago

Btw @Trost123 , do u know how to fix it?

Trost123 commented 1 year ago

Btw @Trost123 , do u know how to fix it?

I'd probably fork this repo and fix the chrome url or version. But I don't know how to use the forked version in:

docker-compose build loconotion

And I don't have time right now to figure it out. Hopefully the authors of this project can fix it soon.

choux130 commented 1 year ago

I encountered the same issue and spent some time troubleshooting it. Here is the modified Dockerfile which works for me, https://github.com/leoncvlt/loconotion/pull/138. Before the author approves my PR, my workaround is to point to my repo, choux130/loconotion, instead of leoncvlt/loconotion.

This is my code snippet,

      - name: Checkout loconotion
        uses: actions/checkout@v2
        with:
          repository: choux130/loconotion
          path: loconotion

from https://github.com/choux130/myblog-yintingchou-notion/blob/main/.github/workflows/pages_deploy.yml

Hope this help!

InakiRaba91 commented 1 year ago

I encountered the same issue and spent some time troubleshooting it. Here is the modified Dockerfile which works for me, #138. Before the author approves my PR, my workaround is to point to my repo, choux130/loconotion, instead of leoncvlt/loconotion.

This is my code snippet,

      - name: Checkout loconotion
        uses: actions/checkout@v2
        with:
          repository: choux130/loconotion
          path: loconotion

from https://github.com/choux130/myblog-yintingchou-notion/blob/main/.github/workflows/pages_deploy.yml

Hope this help!

Thanks a lot for the contribution @choux130, although this seems to still fail:

image

Bumping it to the latest version "116.0.5845.187-1" seemed to work, but this doesn't look right. I'm not sure why the previous version is not available anymore

ngbao161199 commented 1 year ago

Work in my repo.

`name: Publish Notion website to GitHub Pages

on:

Manual update only.

workflow_dispatch:

permissions: contents: write

jobs: deploy: runs-on: ubuntu-latest

  steps:
    - name: Checkout loconotion
      uses: actions/checkout@v3
      with:
        repository: ngbao161199/loconotion
        path: loconotion

    - name: Checkout this repo
      uses: actions/checkout@v3
      with:
        path: pages_repo

    - name: Build Loconotion docker image
      run: docker-compose build loconotion
      working-directory: loconotion

    - name: Run Loconotion
      run: |
        docker run \
        -v "$GITHUB_WORKSPACE/pages_repo/dist:/app/loconotion/dist" \
        -v "$GITHUB_WORKSPACE/pages_repo/site.toml:/app/loconotion/site.toml" \
        loconotion "site.toml"
      working-directory: loconotion
    - name: Push to GitHub pages
      run: |
        git config --global user.name "github-actions[bot]"
        git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"

        GIT_DEPLOY_DIR=dist/site \
        GIT_DEPLOY_BRANCH=gh-pages \
        GIT_DEPLOY_REPO="https://${{ github.token }}@github.com/${{ github.repository }}.git" ./deploy.sh
      working-directory: pages_repo`
choux130 commented 1 year ago

hey @InakiRaba91 ,

I updated my Dockerfile and it works again. This time, instead of hard coding the version, I always download the latest version of Chrome from the apt, dynamically get the version number, and then assign it as the version of Chrome driver. Here is what my Dockerfile looks like now (https://github.com/choux130/loconotion/blob/master/docker/Dockerfile). Hope this time it will work on your end as well. :)

FROM python:3.8

# ChromeDriver installation from https://gist.github.com/varyonic/dea40abcf3dd891d204ef235c6e8dd79
# We need wget to set up the PPA and xvfb to have a virtual screen and unzip to install the Chromedriver
RUN apt-get update
RUN apt-get install -y libgconf-2-4 wget xvfb unzip

# Install chrome
RUN apt-get update && \
    apt-get install -y gnupg wget curl unzip --no-install-recommends && \
    wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
    echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list && \
    apt-get update -y && \
    apt-get install -y google-chrome-stable

# Install chromedriver
ENV CHROMEDRIVER_DIR /chromedriver
RUN export CHROMEDRIVER_VERSION=$(google-chrome-stable --product-version) && \
    echo "$CHROMEDRIVER_VERSION" && \
    wget -q --continue -P $CHROMEDRIVER_DIR "https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/$CHROMEDRIVER_VERSION/linux64/chromedriver-linux64.zip"
RUN unzip $CHROMEDRIVER_DIR/chromedriver* -d $CHROMEDRIVER_DIR

RUN mv $CHROMEDRIVER_DIR/chromedriver-linux64/chromedriver $CHROMEDRIVER_DIR
RUN chmod 755 $CHROMEDRIVER_DIR

# Put Chromedriver into the PATH
ENV PATH $CHROMEDRIVER_DIR:$PATH

RUN mkdir -p /app/loconotion/
WORKDIR /app/loconotion/
COPY requirements.txt .
RUN pip install -r requirements.txt

COPY . .

# comment out for debugging
ENTRYPOINT [ "python", "loconotion", "--chromedriver", "/chromedriver/chromedriver"]
InakiRaba91 commented 1 year ago

Thanks @choux130, that does the trick! However, I think freezing the version would be more robust. Otherwise, newer Chrome releases might break the workflow. I'll try and figure out why the frozen version was not available anymore after a new release came up.

choux130 commented 1 year ago

hello @InakiRaba91, I agree with you that freezing the version is a better practice that is why my original version of Dockerfile was to hardcode the versions of chrome and chromedrive. If you figure out how we can still get the old version when the new version is out. Please let me know, I would like to change my code to use the fixed version. Thank you!