yshalsager / facebook2rss

Turn Facebook feeds into RSS!
GNU General Public License v3.0
34 stars 5 forks source link

Trying containerizing #12

Closed kbzowski closed 3 years ago

kbzowski commented 3 years ago

After my problems with running on Windows, I took a shot at containerizing the application in Docker.

Dockerfile:

FROM ubuntu:20.04
RUN apt-get update && \
    apt-get install --no-install-recommends -y \
          python3.9\
          python3-pip\
          libglib2.0-0\
          libnss3\
          libnspr4\
          libatk1.0-0\
          libatk-bridge2.0-0\
          libcups2\
          libdbus-1-3\
          libxcb1\
          libdrm2\
          libxkbcommon0\
          libx11-6\
          libxcomposite1\
          libxdamage1\
          libxext6\
          libxfixes3\
          libxrandr2\
          libgbm1\
          libgtk-3-0\
          libpango-1.0-0\
          libcairo2\
          libgdk-pixbuf2.0-0\
          libasound2\
          libatspi2.0-0 \
          libxshmfence1 \
          && rm -rf /var/lib/apt/lists/*

WORKDIR /usr/src/app

COPY . .
RUN pip3 install .
RUN playwright install chromium

EXPOSE 8080
RUN chmod +x /usr/src/app/start.sh
ENTRYPOINT ["/usr/src/app/start.sh"]

start.sh:

#!/bin/bash

python3 -m  facebook_rss --login -u [login] -p [pass]
uvicorn facebook_rss.main:api --host 0.0.0.0 --port 8000

Any idea, why application hangs on:

$ docker run -p 8000:8000 facebook2rss
2021-02-20 09:06:24,158 [INFO] facebook_rss.db.session [session.<module>:26]: Feed table not found, creating one

I tried to move "python3 -m facebook_rss --login -u [login] -p [pass]" to RUN in Dockerfile - same thing. Missing playwright dependencies were deduced by trial and errors. Fortunately, playwright reports what it is missing.

yshalsager commented 3 years ago

Nice! I think this happens because of missing sqlite Ubuntu package.

kbzowski commented 3 years ago

Nothing changed after sqlite3 installation via apt in Dockerfile. I think playwright still missing something to work. I will experiment with: https://github.com/ianwalter/playwright-container/blob/main/Dockerfile maybe I will find what is missing.

kbzowski commented 3 years ago

Full success :)

FROM ubuntu:20.04
RUN apt-get update && \
    apt-get install --no-install-recommends -y \
          python3.9\
          python3-pip\
          libglib2.0-0\
          libnss3\
          libnspr4\
          libatk1.0-0\
          libatk-bridge2.0-0\
          libcups2\
          libdbus-1-3\
          libxcb1\
          libdrm2\
          libxkbcommon0\
          libx11-6\
          libxcomposite1\
          libxdamage1\
          libxext6\
          libxfixes3\
          libxrandr2\
          libgbm1\
          libgtk-3-0\
          libpango-1.0-0\
          libcairo2\
          libgdk-pixbuf2.0-0\
          libasound2\
          libatspi2.0-0 \
          libxshmfence1 \
          sqlite3 \
          libwoff1  \
          libopus0 \
          libwebpdemux2 \
          libenchant1c2a \
          libhyphen0 \
          libegl1 \
          libnotify4 \ 
          && rm -rf /var/lib/apt/lists/*

WORKDIR /usr/src/app

COPY . .
RUN pip3 install .

RUN playwright install chromium

#Fixing: https://bugs.launchpad.net/ubuntu/+source/tzdata/+bug/1899343
RUN echo "Etc/UTC" > /etc/timezone

EXPOSE 8080

ENTRYPOINT ["./start.sh"]

I will try to make the image smaller and more "configurable" and make PR

yshalsager commented 3 years ago

Full success :)

FROM ubuntu:20.04
RUN apt-get update && \
    apt-get install --no-install-recommends -y \
        python3.9\
        python3-pip\
        libglib2.0-0\
          libnss3\
          libnspr4\
          libatk1.0-0\
          libatk-bridge2.0-0\
          libcups2\
          libdbus-1-3\
          libxcb1\
          libdrm2\
          libxkbcommon0\
          libx11-6\
          libxcomposite1\
          libxdamage1\
          libxext6\
          libxfixes3\
          libxrandr2\
          libgbm1\
          libgtk-3-0\
          libpango-1.0-0\
          libcairo2\
          libgdk-pixbuf2.0-0\
          libasound2\
          libatspi2.0-0 \
        libxshmfence1 \
        sqlite3 \
        libwoff1  \
        libopus0 \
        libwebpdemux2 \
        libenchant1c2a \
        libhyphen0 \
        libegl1 \
        libnotify4 \ 
        && rm -rf /var/lib/apt/lists/*

WORKDIR /usr/src/app

COPY . .
RUN pip3 install .

RUN playwright install chromium

#Fixing: https://bugs.launchpad.net/ubuntu/+source/tzdata/+bug/1899343
RUN echo "Etc/UTC" > /etc/timezone

EXPOSE 8080

ENTRYPOINT ["./start.sh"]

I will try to make the image smaller and more "configurable" and make PR

Awesome! I have tried to make a working Dockerfile in docker branch but faced many missing dependencies of playwright and didn't find time to do trial and error. Thanks for your contributions!

yshalsager commented 3 years ago

You might find these useful. They was a great help while trying in docker branch. https://github.com/tiangolo/uvicorn-gunicorn-fastapi-docker/ https://github.com/adamwojt/ur_l/blob/master/python_docker/Dockerfile

kbzowski commented 3 years ago

Please feel free to change anything that you wish. I am not a docker expert :)