Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker #203

Open
ranrinc opened this issue Jun 3, 2021 · 5 comments
Open

Docker #203

ranrinc opened this issue Jun 3, 2021 · 5 comments

Comments

@ranrinc
Copy link

ranrinc commented Jun 3, 2021

Will you create Dockerfile in the future?

@luk6xff
Copy link
Owner

luk6xff commented Jul 29, 2021

@ranrinc Good idea! maybe you can create it :) ?

@Tokariew
Copy link

Tokariew commented Sep 7, 2021

My little weird setup with podman…
Dockerfile

FROM registry.fedoraproject.org/fedora-minimal:34
RUN microdnf -y update && microdnf -y install python3-pip python3-wheel --nodocs --setopt install_weak_deps=0 && microdnf clean all
RUN pip3 install packt
COPY configFile.cfg /configFile.cfg
COPY init.sh /init.sh
VOLUME /srv/books
VOLUME /srv/log
RUN mkdir -p /srv/books
RUN mkdir -p /srv/log
ENTRYPOINT ./init.sh -DFOREGROUND
ARG CACHEBUST
RUN pip3 install packt --upgrade

and init.sh

#!/bin/bash
# grab new ebooks from site
{ date +%F; packt-cli -gd -f; } >> /srv/log/packt.log

# check if first day of month, and before noon, if so download ebooks
[[ $(date +%-d) -eq 1 ]] && [[ $(date +%-H) -lt 12 ]] && packt-cli -da -f >> /srv/log/packt.log                 

rm LOG_FILE.log

As it is a podman I don't care if it run as root inside a container.

I run that on schedule twice a day in case some error occur with anticaptcha, timeout or no free bots
On first day of month I run command to run full download, in case there was some problem downloading it during earlier.
The configFile.cfg is copied from local directory into container, so no need to give sensitive information inside docker/podman command.

And I locally rebuild image in case there was some update to packt-cli

@ranrinc
Copy link
Author

ranrinc commented Sep 8, 2021

@Tokariew is it working? would love to test it. Is there a way to get away with alpine instead of fedora?

How do you setup to run on docker? Any chances in uploading to Gdrive?

@Tokariew
Copy link

Tokariew commented Sep 8, 2021

Yes it is working for me for the last 1.5 year… Only changed fedora version on which is based.
I will try to rewrite it to alpine, and test how to run it with uploading to Gdrive

I run it with podman instead of docker.

podman build --tag packt-downloader -f Dockerfile --build-arg CACHEBUST=$(date +%s)
podman create -v "/media/btrfs/Hoard/Packt:/srv/books:z" -v "/home/tokariew/logs:/srv/log:z" --name packt localhost/packt-downloader

After running that for the first time I generate systemd service file with

podman generate systemd packt --name

and write systemd timer for it.

@Tokariew
Copy link

Tokariew commented Sep 8, 2021

minimalistic Dockerfile

FROM alpine
RUN apk add --no-cache python3 py3-pip
RUN pip3 install packt
WORKDIR /srv
VOLUME /srv
CMD /bin/sh

example of how to run it:

podman run --rm -it --name packt -v "/home/tokariew/tmp/packt:/srv:z" localhost/packt-downloader:latest packt-cli -gd

configFile.cfg and client_secret.json should be placed in mounted volume, that way it can be publish on registry and not only build locally

to upload to Google Drive you can copy existing working .credentials folder into mounted volume
or run as following for the first time:

podman run --rm -it --name packt -v "/home/tokariew/tmp/packt:/srv:z" localhost/packt-downloader:latest packt-cli -c configFile.cfg -sgd --noauth_local_webserver

after first time it can be run without -c configFile.cfg and --noauth_local_webserver

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants