-
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.
Co-authored-by: Tom <TommyE123@users.noreply.github.com> Co-authored-by: Eric Nemchik <eric@nemchik.com>
- Loading branch information
Showing
22 changed files
with
130 additions
and
97 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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
quiet: true | ||
skip-check: | ||
- CKV_DOCKER_3 | ||
- CKV_DOCKER_3 # lsio images run containers as non-root by default |
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 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 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,37 +1,32 @@ | ||
# 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 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 | ||
RUN \ | ||
echo "**** install runtime packages ****" && \ | ||
apk add --no-cache \ | ||
python3 && \ | ||
echo "**** install app ****" && \ | ||
python3 -m ensurepip && \ | ||
pip3 install -U --no-cache-dir \ | ||
pip \ | ||
wheel \ | ||
packt==1.8.0 && \ | ||
echo "**** cleanup ****" && \ | ||
rm -rf \ | ||
/tmp/* \ | ||
"$HOME/.cache" | ||
|
||
# Add a health check command to ensure the container is running correctly | ||
HEALTHCHECK --interval=1m \ | ||
--timeout=3s \ | ||
CMD ps -ef | grep cron || exit 1 | ||
|
||
# Specify the entrypoint | ||
ENTRYPOINT ["/opt/docker-entrypoint.sh"] | ||
# copy local files | ||
COPY root/ / | ||
|
||
# ports and volumes | ||
VOLUME /config |
Empty file.
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,2 @@ | ||
0 8 * * * packt-cli -gd -c /config/configFile.cfg 2>&1 | tee /config/logFile.log | ||
# min hour day month weekday command | ||
0 8 * * * packt-cli -gd -c /config/configFile.cfg 2>&1 | tee /config/logFile.log |
Empty file.
Empty file.
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,38 @@ | ||
#!/usr/bin/with-contenv bash | ||
# shellcheck shell=bash | ||
|
||
# make folders | ||
mkdir -p \ | ||
/config/crontabs | ||
|
||
## root | ||
# if crontabs do not exist in config | ||
if [[ ! -f /config/crontabs/root ]]; then | ||
# copy crontab from system | ||
if crontab -l -u root; then | ||
crontab -l -u root >/config/crontabs/root | ||
fi | ||
|
||
# if crontabs still do not exist in config (were not copied from system) | ||
# copy crontab from included defaults (using -n, do not overwrite an existing file) | ||
cp -n /etc/crontabs/root /config/crontabs/ | ||
fi | ||
# set permissions and import user crontabs | ||
lsiown root:root /config/crontabs/root | ||
crontab -u root /config/crontabs/root | ||
|
||
## abc | ||
# if crontabs do not exist in config | ||
if [[ ! -f /config/crontabs/abc ]]; then | ||
# copy crontab from system | ||
if crontab -l -u abc; then | ||
crontab -l -u abc >/config/crontabs/abc | ||
fi | ||
|
||
# if crontabs still do not exist in config (were not copied from system) | ||
# copy crontab from included defaults (using -n, do not overwrite an existing file) | ||
cp -n /etc/crontabs/abc /config/crontabs/ | ||
fi | ||
# set permissions and import user crontabs | ||
lsiown abc:abc /config/crontabs/abc | ||
crontab -u abc /config/crontabs/abc |
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 @@ | ||
oneshot |
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 @@ | ||
/etc/s6-overlay/s6-rc.d/init-crontabs-config/run |
Empty file.
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,56 @@ | ||
#!/usr/bin/with-contenv bash | ||
# shellcheck shell=bash | ||
|
||
CFG="/config/configFile.cfg" | ||
|
||
# Downloads and copies a new configfile template if one is not present in the config dir. | ||
if [[ ! -f "$CFG" ]]; then | ||
echo "No config file, providing sample" | ||
wget -O "$CFG" https://gitlab.com/packt-cli/packt-cli/-/raw/master/configFileTemplate.cfg | ||
fi | ||
|
||
# If environment arguments have been provided, switch the values in the config to these. | ||
if [[ -n "$PACKT_EMAIL" ]]; then | ||
echo "ENV PACKT_EMAIL provided" | ||
sed -i "s/email=.*/email=\"$PACKT_EMAIL\"/" "$CFG" | ||
else | ||
echo "ENV PACKT_EMAIL not set" | ||
fi | ||
|
||
if [[ -n "$PACKT_PASSWORD" ]]; then | ||
echo "ENV PACKT_PASSWORD provided" | ||
sed -i "s/password=.*/password=\"$PACKT_PASSWORD\"/" "$CFG" | ||
else | ||
echo "ENV PACKT_PASSWORD not set" | ||
fi | ||
|
||
if [[ -n "$PACKT_DOWNLOAD_FORMATS" ]]; then | ||
echo "ENV PACKT_DOWNLOAD_FORMATS provided as \"$PACKT_DOWNLOAD_FORMATS\"" | ||
sed -i "s/download_formats:.*/download_formats:\ \"$PACKT_DOWNLOAD_FORMATS\"/" "$CFG" | ||
else | ||
echo "ENV PACKT_DOWNLOAD_FORMATS not set" | ||
fi | ||
|
||
if [[ -n "$PACKT_DOWNLOAD_BOOK_TITLES" ]]; then | ||
echo "ENV PACKT_DOWNLOAD_BOOK_TITLES provided as \"$PACKT_DOWNLOAD_BOOK_TITLES\"" | ||
sed -i "s/download_book_titles:.*/download_book_titles:\ \"$PACKT_DOWNLOAD_BOOK_TITLES\"/" "$CFG" | ||
else | ||
echo "ENV PACKT_DOWNLOAD_BOOK_TITLES not set" | ||
sed -i "s/download_book_titles:.*/download_book_titles:/" "$CFG" | ||
fi | ||
|
||
if [[ -n "$PACKT_ANTICAPTCHA_KEY" ]]; then | ||
echo "ENV PACKT_ANTICAPTCHA_Key provided" | ||
sed -i "s/key:.*/key:\ \"$PACKT_ANTICAPTCHA_KEY\"/" "$CFG" | ||
else | ||
echo "ENV PACKT_ANTICAPTCHA_KEY not set" | ||
fi | ||
|
||
echo "Replacing path with /data" | ||
sed -i "s@download_folder_path:.*@download_folder_path:\ \\/data@" "$CFG" | ||
|
||
echo "Set logfile path to /data" | ||
sed -i "s@ebook_extra_info_log_file_path:.*@ebook_extra_info_log_file_path:\ \\/data\\/eBookMetadata.log@" "$CFG" | ||
|
||
# set permissions | ||
lsiown -R abc:abc /config |
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 @@ | ||
oneshot |
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 @@ | ||
/etc/s6-overlay/s6-rc.d/init-packt-cli-config/run |
Empty file.
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,4 @@ | ||
#!/usr/bin/with-contenv bash | ||
# shellcheck shell=bash | ||
|
||
exec /usr/sbin/crond -f -S -l 5 |
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 @@ | ||
longrun |
Empty file.
Empty file.
Empty file.
This file was deleted.
Oops, something went wrong.