-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Dockerfile and build instruction
- Loading branch information
Showing
4 changed files
with
98 additions
and
0 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,9 @@ | ||
__pycache__ | ||
.mypy_cache | ||
.pytest_cache | ||
.vscode | ||
cvdupdate.egg-info | ||
/build | ||
/dist | ||
/tests | ||
.github |
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,7 @@ | ||
FROM python:3-slim | ||
RUN apt-get -y update \ | ||
&& apt-get -y --no-install-recommends install cron gosu \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
COPY . /dist | ||
RUN pip install --no-cache-dir /dist | ||
ENTRYPOINT [ "/dist/scripts/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
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,41 @@ | ||
#!/bin/bash | ||
USER_ID="${USER_ID:-0}" | ||
SCRIPT_PATH=$(readlink -f "$0") | ||
echo "ClamAV Private Database Mirror Updater Cron ${SCRIPT_PATH}" | ||
if [ "${USER_ID}" -ne "0" ]; then | ||
echo "Creating user with ID ${USER_ID}" | ||
useradd --create-home --home-dir /cvdupdate --uid "${USER_ID}" cvdupdate | ||
chown -R "${USER_ID}" /cvdupdate | ||
gosu cvdupdate cvdupdate config set --logdir /cvdupdate/logs | ||
gosu cvdupdate cvdupdate config set --dbdir /cvdupdate/database | ||
else | ||
mkdir -p /cvdupdate/{logs,database} | ||
cvdupdate config set --logdir /cvdupdate/logs | ||
cvdupdate config set --dbdir /cvdupdate/database | ||
fi | ||
|
||
if [ $# -eq 0 ]; then | ||
set -e | ||
|
||
echo "Adding crontab entry" | ||
if [ "${USER_ID}" -ne "0" ]; then | ||
crontab -l | { | ||
cat | ||
echo "${CRON:-"30 */4 * * *"} /usr/sbin/gosu cvdupdate /usr/local/bin/cvdupdate update >/proc/1/fd/1 2>/proc/1/fd/2" | ||
echo "@reboot /usr/sbin/gosu cvdupdate /usr/local/bin/cvdupdate update >/proc/1/fd/1 2>/proc/1/fd/2" | ||
} | crontab - | ||
else | ||
crontab -l | { | ||
cat | ||
echo "${CRON:-"30 */4 * * *"} /usr/local/bin/cvdupdate update >/proc/1/fd/1 2>/proc/1/fd/2" | ||
echo "@reboot /usr/local/bin/cvdupdate update >/proc/1/fd/1 2>/proc/1/fd/2" | ||
} | crontab - | ||
fi | ||
cron -f | ||
else | ||
if [ "${USER_ID}" -ne "0" ]; then | ||
exec gosu cvdupdate "$@" | ||
else | ||
exec "$@" | ||
fi | ||
fi |