-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
258 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
|
||
# Common settings that generally should always be used with your language specific settings | ||
|
||
# Auto detect text files and perform LF normalization | ||
* text=auto | ||
|
||
# | ||
# The above will handle all files NOT found below | ||
# | ||
|
||
# Documents | ||
*.bibtex text diff=bibtex | ||
*.doc diff=astextplain | ||
*.DOC diff=astextplain | ||
*.docx diff=astextplain | ||
*.DOCX diff=astextplain | ||
*.dot diff=astextplain | ||
*.DOT diff=astextplain | ||
*.pdf diff=astextplain | ||
*.PDF diff=astextplain | ||
*.rtf diff=astextplain | ||
*.RTF diff=astextplain | ||
*.md text diff=markdown | ||
*.mdx text diff=markdown | ||
*.tex text diff=tex | ||
*.adoc text | ||
*.textile text | ||
*.mustache text | ||
*.csv text eol=crlf | ||
*.tab text | ||
*.tsv text | ||
*.txt text | ||
*.sql text | ||
*.epub diff=astextplain | ||
|
||
# Graphics | ||
*.png binary | ||
*.jpg binary | ||
*.jpeg binary | ||
*.gif binary | ||
*.tif binary | ||
*.tiff binary | ||
*.ico binary | ||
# SVG treated as text by default. | ||
*.svg text | ||
# If you want to treat it as binary, | ||
# use the following line instead. | ||
# *.svg binary | ||
*.eps binary | ||
|
||
# Scripts | ||
*.bash text eol=lf | ||
*.fish text eol=lf | ||
*.sh text eol=lf | ||
*.zsh text eol=lf | ||
# These are explicitly windows files and should use crlf | ||
*.bat text eol=crlf | ||
*.cmd text eol=crlf | ||
*.ps1 text eol=crlf | ||
|
||
# Serialisation | ||
*.json text | ||
*.toml text | ||
*.xml text | ||
*.yaml text | ||
*.yml text | ||
|
||
# Archives | ||
*.7z binary | ||
*.gz binary | ||
*.tar binary | ||
*.tgz binary | ||
*.zip binary | ||
|
||
# Text files where line endings should be preserved | ||
*.patch -text | ||
|
||
# | ||
# Exclude files from exporting | ||
# | ||
|
||
.gitattributes export-ignore | ||
.gitignore export-ignore | ||
.gitkeep export-ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Based on the issue template | ||
name: Bug report | ||
description: Create a report to help us improve | ||
title: "[BUG] <title>" | ||
labels: [Bug] | ||
body: | ||
- type: checkboxes | ||
attributes: | ||
label: Is there an existing issue for this? | ||
description: Please search to see if an issue already exists for the bug you encountered. | ||
options: | ||
- label: I have searched the existing issues | ||
required: true | ||
- type: textarea | ||
attributes: | ||
label: Current Behavior | ||
description: Tell us what happens instead of the expected behavior. | ||
validations: | ||
required: true | ||
- type: textarea | ||
attributes: | ||
label: Expected Behavior | ||
description: Tell us what should happen. | ||
validations: | ||
required: false | ||
- type: textarea | ||
attributes: | ||
label: Steps To Reproduce | ||
description: Steps to reproduce the behavior. | ||
placeholder: | | ||
1. In this environment... | ||
2. With this config... | ||
3. Run '...' | ||
4. See error... | ||
validations: | ||
required: true | ||
- type: textarea | ||
attributes: | ||
label: Docker creation | ||
description: | | ||
Command used to create docker container | ||
Provide your docker create/run command or compose yaml snippet, or a screenshot of settings if using a gui to create the container | ||
render: bash | ||
validations: | ||
required: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Based on the issue template | ||
name: Feature request | ||
description: Suggest an idea for this project | ||
title: "[FEAT] <title>" | ||
labels: [enhancement] | ||
body: | ||
- type: checkboxes | ||
attributes: | ||
label: Is this a new feature request? | ||
description: Please search to see if a feature request already exists. | ||
options: | ||
- label: I have searched the existing issues | ||
required: true | ||
- type: textarea | ||
attributes: | ||
label: Wanted change | ||
description: Tell us what you want to happen. | ||
validations: | ||
required: true | ||
- type: textarea | ||
attributes: | ||
label: Reason for change | ||
description: Justify your request, why do you want it, what is the benefit. | ||
validations: | ||
required: true | ||
- type: textarea | ||
attributes: | ||
label: Proposed code change | ||
description: Do you have a potential code change in mind? | ||
validations: | ||
required: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Pull Request | ||
|
||
<!-- - [ ] I have read the [contributing](https://github.com/ghostwriters/docker-packt-cli/blob/main/.github/CONTRIBUTING.md) guideline and understand that I have made the correct modifications. | ||
--- --> | ||
|
||
## Description | ||
|
||
- | ||
|
||
## Benefits of this PR and context | ||
|
||
- | ||
|
||
## How Has This Been Tested? | ||
|
||
- | ||
|
||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: Greetings | ||
|
||
permissions: read-all | ||
|
||
on: [pull_request_target, issues] | ||
|
||
jobs: | ||
greeting: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/first-interaction@1d8459ca65b335265f1285568221e229d45a995e # v1.1.1 | ||
with: | ||
issue-message: "Thanks for opening your first issue here! Be sure to follow the relevant issue templates, or risk having this issue marked as invalid." | ||
pr-message: "Thanks for opening this pull request! Be sure to follow the [pull request template](https://github.com/GhostWriters/docker-packt-cli/blob/main/.github/PULL_REQUEST_TEMPLATE.md)!" | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,37 @@ | ||
# Set the base image | ||
FROM ghcr.io/linuxserver/baseimage-alpine:3.17 | ||
|
||
# Set the timezone | ||
ARG TZ=Europe/London | ||
ENV TZ=$TZ | ||
|
||
# Set the maintainer | ||
LABEL maintainer="GhostWriters" | ||
|
||
# Copy files from host to container | ||
COPY root / | ||
|
||
# Install required packages and application dependencies | ||
RUN apk add --no-cache py3-pip && \ | ||
pip3 install --no-cache-dir -r /opt/requirements.txt | ||
RUN apk update && apk add --no-cache py3-pip tzdata && \ | ||
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && \ | ||
echo $TZ > /etc/timezone && \ | ||
pip3 install --no-cache-dir packt==1.7.0 | ||
|
||
# Update UID and GID of existing user "abc" to match PUID and PGID if supplied | ||
ARG PUID=1000 | ||
ARG PGID=1000 | ||
RUN if [ "$PUID" -ne 1000 ] || [ "$PGID" -ne 1000 ]; then \ | ||
usermod -u $PUID abc && \ | ||
groupmod -g $PGID abc; \ | ||
fi | ||
|
||
# Set user "abc" as default user | ||
USER abc | ||
|
||
# Add a health check command to ensure the container is running correctly | ||
HEALTHCHECK --interval=1m \ | ||
--timeout=3s \ | ||
CMD ps -ef | grep cron || exit 1 | ||
--timeout=3s \ | ||
CMD ps -ef | grep cron || exit 1 | ||
|
||
# Specify the entrypoint | ||
ENTRYPOINT ["/opt/docker-entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,49 @@ | ||
# Container for Packt daily download script | ||
# docker-packt-cli | ||
|
||
[![GitHub contributors](https://img.shields.io/github/contributors/GhostWriters/docker-packt-cli.svg?style=flat-square&color=607D8B)](https://github.com/GhostWriters/docker-packt-cli/graphs/contributors) | ||
[![GitHub last commit main](https://img.shields.io/github/last-commit/GhostWriters/docker-packt-cli/main.svg?style=flat-square&color=607D8B&label=code%20committed)](https://github.com/GhostWriters/docker-packt-cli/commits/main) | ||
[![GitHub license](https://img.shields.io/github/license/GhostWriters/docker-packt-cli.svg?style=flat-square&color=607D8B)](https://github.com/GhostWriters/docker-packt-cli/blob/main/LICENSE) | ||
[![Renovate](https://img.shields.io/badge/renovate-enabled-brightgreen.svg?style=flat-square&color=607D8B)](https://github.com/renovatebot/renovate) | ||
|
||
These instructions detail how to set up a docker container that includes a scheduled cron job to automatically claim the daily free | ||
book from Packt at 1am each night. Packt offers free learning e-books each day, and you can find more information about this service | ||
at <https://www.packtpub.com/packt/offers/free-learning>. | ||
To learn more about docker, please visit the official documentation at <https://docs.docker.com/get-started/overview/>. | ||
If you're new to cron jobs, you can learn more about them on the Unix/Linux manpages at <https://help.ubuntu.com/community/CronHowto>. | ||
For more information about the code used in this container, please see the | ||
project page at <https://gitlab.com/packt-cli/packt-cli>. | ||
A Docker container for automatically downloading a free eBook each day from Packt publishing using the `packt-cli` tool. | ||
|
||
## Run | ||
## Usage | ||
|
||
Run with: | ||
To run the `docker-packt-cli` container, use the following `docker run` command: | ||
|
||
```docker | ||
docker run -d \ | ||
--name=packt --rm \ | ||
-e PACKT_EMAIL=<xxx@xxx.xxx> \ | ||
-e PACKT_PASSWORD=<password> \ | ||
-e PACKT_DOWNLOAD_FORMATS=pdf, epub, mobi, code \ | ||
-e PACKT_ANTICAPTCHA_KEY=<key> \ | ||
-e PUID=<UID> \ | ||
-e PGID=<GID> \ | ||
-e TZ=<timezone> \ | ||
-v /home/user/packt/config:/config \ | ||
-v /home/user/packt/books:/data \ | ||
--restart unless-stopped \ | ||
ghostwriters/docker-packt-cli:latest | ||
--name=packt --rm \ | ||
-e PACKT_EMAIL=<xxx@xxx.xxx> \ | ||
-e PACKT_PASSWORD=<password> \ | ||
-e PACKT_DOWNLOAD_FORMATS=pdf,epub,mobi,code \ | ||
-e PACKT_ANTICAPTCHA_KEY=<key> \ | ||
-e PUID=<UID> \ | ||
-e PGID=<GID> \ | ||
-e TZ=<timezone> \ | ||
-v /home/user/packt/config:/config \ | ||
-v /home/user/packt/books:/data \ | ||
--restart unless-stopped | ||
ghcr.io/ghostwriters/docker-packt-cli/docker-packt-cli:latest | ||
``` | ||
|
||
## Volumes and variables | ||
You will need to replace `<xxx@xxx.xxx>` and `<password>` with your Packt account email and password, respectively. Additionally, you can customize the output formats of the downloaded books by modifying the `PACKT_DOWNLOAD_FORMATS` environment variable. The default formats are `pdf`, `epub`, `mobi`, and `code`. | ||
|
||
Volumes: | ||
To automatically solve the CAPTCHA, you will need an AntiCaptcha API key, which you can set by attaching the `-e PACKT_ANTICAPTCHA_KEY=<key>` flag to your docker run command. | ||
|
||
- /config, where the configFile.cfg and log file are placed | ||
- /data, where files are downloaded to | ||
You can mount two volumes to persist the Packt credentials and store the downloaded books in a directory on your host system. The `/config` directory will store your Packt credentials, and the `/data` directory will store the downloaded books. You can change the paths of the host directories by modifying the values after the `-v` flag. | ||
|
||
OPTIONAL: Variables: | ||
Once you run the container, it will automatically download a free eBook each day from Packt publishing and store the files in the `/home/user/packt/books` directory on your host system. | ||
|
||
- PACKT_EMAIL - email address registered with Packt account | ||
- PACKT_PASSWORD - password for Packt account | ||
- PACKT_DOWNLOAD_FORMATS - pdf, epub, mobi, code | ||
- PACKT_ANTICAPTCHA_KEY - get an api key from [anti-captcha.com](https://anti-captcha.com) | ||
- PACKT_DOWNLOAD_BOOK_TITLES - specify individual books | ||
## Contributing | ||
|
||
If variables are set, they overwrite what is already in the configFile.cfg file | ||
at container startup. If not set, the config file will be left alone. | ||
|
||
**NOTE:** Anticaptcha key required to download the daily book. | ||
If you have any feedback or run into issues with the container, please open an [issue](https://github.com/GhostWriters/docker-packt-cli/issues/new) on the GitHub repository. If you would like to contribute to this project, you can submit a [pull request](https://github.com/GhostWriters/docker-packt-cli/pulls). | ||
|
||
## Special Thanks | ||
|
||
- [packt-cli](https://gitlab.com/packt-cli/packt-cli) for maintaining the package to handle the downloading. | ||
- [LinuxServer.io](https://www.linuxserver.io) for maintaining most Docker images used in this project. | ||
- [LinuxServer.io](https://www.linuxserver.io) for maintaining the Docker image used in this project. | ||
|
||
## License | ||
|
||
This project is licensed under the MIT License. See the [LICENSE](https://github.com/GhostWriters/docker-packt-cli/blob/main/LICENSE) file for more details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0 1 * * * packt-cli -gd -c /config/configFile.cfg 2>&1 | tee /config/logFile.log | ||
0 8 * * * packt-cli -gd -c /config/configFile.cfg 2>&1 | tee /config/logFile.log |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.