diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..f4b2862 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,12 @@ +.git/ +.DS_Store +*.mp4 +.idea/ +.vscode/ +downloaded_files/ +.github/ +__pycache__/ +*.py[cod] +*$py.class +test/ +config.yml diff --git a/.github/workflows/image.yml b/.github/workflows/image.yml index 59f32b9..81bb572 100644 --- a/.github/workflows/image.yml +++ b/.github/workflows/image.yml @@ -11,12 +11,16 @@ jobs: build: runs-on: ubuntu-latest steps: - - name: download Dockerfile - run: curl -O https://raw.githubusercontent.com/speedyconzales/series-scraper/master/Dockerfile - name: login to docker hub run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin - name: login to ghcr run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u "${{ github.actor }}" --password-stdin + - name: checkout repository + uses: actions/checkout@v4 + with: + lfs: true + - name: checkout lfs + run: git lfs checkout - name: install buildx id: buildx uses: docker/setup-buildx-action@v3 @@ -27,7 +31,7 @@ jobs: docker buildx build --push \ --tag docker.io/speedyconzales/series-scraper:latest \ --tag ghcr.io/speedyconzales/series-scraper:latest \ - --platform linux/amd64,linux/arm/v7,linux/arm64 . + --platform linux/amd64,linux/arm64 . - name: Setup tmate session if: failure() timeout-minutes: 10 diff --git a/.gitignore b/.gitignore index 34a2a02..92828c7 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ config.yml .vscode/ src/extensions/*/ downloaded_files/ +test/ # Byte-compiled / optimized / DLL files __pycache__/ diff --git a/Dockerfile b/Dockerfile index c3ada03..ffd0b6f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,37 +1,14 @@ -# Stage 1: Checkout repository and prepare environment -FROM python:3.12.3-slim-bookworm AS builder +FROM ghcr.io/linuxserver/baseimage-debian:bookworm +LABEL org.opencontainers.image.source="https://github.com/speedyconzales/series-scraper" -# Set the working directory -WORKDIR /series-scraper +WORKDIR /app -# Install git and git-lfs for cloning the repository -RUN apt-get update && apt-get install -y git git-lfs -RUN git lfs install +COPY . /app/ -# Copy the current directory contents into the container at / -RUN git clone https://github.com/speedyconzales/series-scraper.git /series-scraper +COPY root/ / -RUN mv template.yml config.yml +RUN chmod +x /etc/s6-overlay/s6-rc.d/init-series-scraper-config/run -# Stage 2: Final setup -FROM python:3.12.3-slim-bookworm AS final -LABEL org.opencontainers.image.source="https://github.com/speedyconzales/seroes-scraper" +RUN apt-get update && apt-get install -y chromium chromium-driver ffmpeg python3.11-full python3-pip -WORKDIR /series-scraper - -COPY --from=builder /series-scraper /series-scraper - -# Install any needed packages specified in requirements.txt -RUN pip install -r requirements.txt - -# Install Chromium -RUN apt-get update && apt-get install -y chromium - -# Install Chromium driver -RUN apt-get install -y chromium-driver - -# Install FFmpeg -RUN apt-get install -y ffmpeg - -# Set main.py as entrypoint -ENTRYPOINT ["python", "main.py"] +RUN python3 -m pip install -r requirements.txt --break-system-packages diff --git a/README.md b/README.md index 088bed3..948c4fd 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ ## Usage 1. if you are familiar with docker just use: 1. `docker pull speedyconzales/series-scraper` - 2. `docker run --rm -v :/series-scraper/anime -v :/series-scraper/series speedyconzales/series-scraper` followed by the arguments you want to provide + 2. `docker run --rm -e PUID= -e PGID= -v :/app/anime -v :/app/series speedyconzales/series-scraper s6-setuidgid abc python main.py` followed by the arguments you want to provide 2. if you don't want to use docker or there is no suitable docker image available for your architecture, you can use the following steps to run the scraper: 1. clone the repository 2. install the dependencies diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index f56bdce..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,7 +0,0 @@ -services: - series-scraper: - container_name: series-scraper - image: speedyconzales/series-scraper - volumes: - - ./Animes:/series-scraper/Animes - - ./Series:/series-scraper/Series diff --git a/root/etc/s6-overlay/s6-rc.d/init-series-scraper-config/dependencies.d/init-config b/root/etc/s6-overlay/s6-rc.d/init-series-scraper-config/dependencies.d/init-config new file mode 100644 index 0000000..e69de29 diff --git a/root/etc/s6-overlay/s6-rc.d/init-series-scraper-config/run b/root/etc/s6-overlay/s6-rc.d/init-series-scraper-config/run new file mode 100644 index 0000000..b8abcdf --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-series-scraper-config/run @@ -0,0 +1,9 @@ +#!/usr/bin/with-contenv bash +# shellcheck shell=bash + +if [[ ! -f /app/config.yml ]]; then + mv /app/template.yml /app/config.yml +fi +# permissions +lsiown -R abc:abc /app +lsiown -R abc:abc /usr/local/lib/python3.11 diff --git a/root/etc/s6-overlay/s6-rc.d/init-series-scraper-config/type b/root/etc/s6-overlay/s6-rc.d/init-series-scraper-config/type new file mode 100644 index 0000000..bdd22a1 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-series-scraper-config/type @@ -0,0 +1 @@ +oneshot diff --git a/root/etc/s6-overlay/s6-rc.d/init-series-scraper-config/up b/root/etc/s6-overlay/s6-rc.d/init-series-scraper-config/up new file mode 100644 index 0000000..09fa2d9 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-series-scraper-config/up @@ -0,0 +1 @@ +/etc/s6-overlay/s6-rc.d/init-series-scraper-config/run diff --git a/root/etc/s6-overlay/s6-rc.d/user/contents.d/init-series-scraper-config b/root/etc/s6-overlay/s6-rc.d/user/contents.d/init-series-scraper-config new file mode 100644 index 0000000..e69de29