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

chore(docker-clamav): update Dockerfile and entrypoint.sh #23

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ body:
label: "🏢 Have you read the Code of Conduct?"
options:
- label: "I have read the [Code of Conduct](https://github.com/appwrite/appwrite/blob/HEAD/CODE_OF_CONDUCT.md)"
required: true
required: true
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/documentation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ body:
label: "🏢 Have you read the Code of Conduct?"
options:
- label: "I have read the [Code of Conduct](https://github.com/appwrite/appwrite/blob/HEAD/CODE_OF_CONDUCT.md)"
required: true
required: true
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ body:
label: "🏢 Have you read the Code of Conduct?"
options:
- label: "I have read the [Code of Conduct](https://github.com/appwrite/appwrite/blob/HEAD/CODE_OF_CONDUCT.md)"
required: true
required: true
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
notifications:
email:
- team@appwrite.io
- team@appwrite.io

language: minimal

Expand All @@ -10,7 +9,7 @@ arch:
- arm64

os: linux
dist: focal
dist: jammy

before_install:
- curl -fsSL https://get.docker.com | sh
Expand Down
18 changes: 8 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
FROM alpine:3.16
FROM alpine:3.18

LABEL maintainer="team@appwrite.io"

RUN apk add --no-cache \
clamav=0.104.3-r0 \
su-exec=0.2-r1 \
RUN apk add --no-cache clamav=1.1.2-r0 su-exec=0.2-r3 && \
rm -rf /var/cache/apk/* && \
install -d -o clamav -g clamav -m 700 /run/clamav; \
sed -i 's/^#\(Foreground\)/\1/' /etc/clamav/freshclam.conf; \
sed -i 's/^#\(Foreground \).*/\1yes/' /etc/clamav/clamd.conf; \
sed -i 's/^#\(TCPSocket \)/\1/' /etc/clamav/clamd.conf; \
sed -i 's/^#\(CompressLocalDatabase \).*/\1yes/' /etc/clamav/freshclam.conf; \
tar -cvjf /etc/_clamav.tar.bz2 etc/clamav
install -d -o clamav -g clamav -m 700 /run/clamav && \
sed -i 's/^#\(Foreground\)/\1/' /etc/clamav/freshclam.conf && \
sed -i 's/^#\(Foreground \).*/\1yes/' /etc/clamav/clamd.conf && \
sed -i 's/^#\(TCPSocket \)/\1/' /etc/clamav/clamd.conf && \
sed -i 's/^#\(CompressLocalDatabase \).*/\1yes/' /etc/clamav/freshclam.conf && \
tar -cvjf /etc/_clamav.tar.bz2 etc/clamav

COPY entrypoint.sh /start.sh
COPY health.sh /health.sh
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ A ClamAV docker image with auto database updates by the [Appwrite team](https://

## Getting Started

These instructions will cover usage information to help your run ClamAV docker image
These instructions will cover usage information to help your run ClamAV docker image

### Prerequisities
### Prerequisites

In order to run this image you'll need docker installed.

* [Windows](https://docs.docker.com/windows/started)
* [OS X](https://docs.docker.com/mac/started/)
* [Linux](https://docs.docker.com/linux/started/)
- [Windows](https://docs.docker.com/windows/started)
- [OS X](https://docs.docker.com/mac/started/)
- [Linux](https://docs.docker.com/linux/started/)

### Usage

Expand All @@ -28,11 +28,11 @@ docker run appwrite/clamav

#### Environment Variables

This image has no environment variables.
This image has no environment variables.

#### Volumes

You can mount any volume you need to allow the image to scan its files.
You can mount any volume you need to allow the image to scan its files.

### Build / Release

Expand All @@ -50,9 +50,9 @@ docker buildx build --platform linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64

## Find Us

* [GitHub](https://github.com/appwrite)
* [Discord](https://appwrite.io/discord)
* [Twitter](https://twitter.com/appwrite_io)
- [GitHub](https://github.com/appwrite)
- [Discord](https://appwrite.io/discord)
- [Twitter](https://twitter.com/appwrite_io)

## Copyright and license

Expand Down
9 changes: 4 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
---
version: '3.7'
version: "3.8"

services:
freshclam:
build: .
environment:
MODE: freshclam
volumes:
- conf:/etc/clamav
- data:/var/lib/clamav
- conf:/etc/clamav
- data:/var/lib/clamav

clamav:
build: .
depends_on:
- freshclam
build: .
environment:
MODE: clamd
ulimits:
Expand Down
45 changes: 23 additions & 22 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,35 @@

set -e

if [ ! "$(ls -A /etc/clamav)" ]; then
# Check if /etc/clamav is empty
if [ -z "$(ls -A /etc/clamav)" ]; then
echo "Extracting ClamAV configurations..."
tar -xvjf /etc/_clamav.tar.bz2 /

sed -i 's/^#\(TCPSocket \)/\1/' /etc/clamav/clamd.conf
sed -i 's/^#\(Foreground \).*/\1yes/' /etc/clamav/clamd.conf
sed -i 's/^#\(Foreground \).*/\1yes/' /etc/clamav/freshclam.conf
sed -i 's/^#\(CompressLocalDatabase \).*/\1yes/' /etc/clamav/freshclam.conf

echo "Configuring ClamAV..."
sed -i 's/^#\(Foreground\)/\1/; s/^#\(TCPSocket \)/\1/; s/^#\(CompressLocalDatabase \).*/\1yes/' /etc/clamav/freshclam.conf /etc/clamav/clamd.conf
fi

# Check for initial definitions
if [ ! -f /var/lib/clamav/main.cvd ]; then
echo "Starting initial definition download"
echo "Starting initial definition download..."
/usr/bin/freshclam
fi

if [ "$#" -eq 0 ] || [ "${1#-}" != "$1" ]; then
case $MODE in
clamd)
echo "Starting clamav daemon"
set -- /usr/sbin/clamd $@
;;
freshclam)
echo "Starting the update daemon"
set -- /usr/bin/freshclam -d -p "/run/clamav/freshclam.pid" $@
;;
*)
set -- /bin/sh
;;
esac
fi
# Determine mode of operation
case $MODE in
clamd)
echo "Starting ClamAV daemon..."
set -- /usr/sbin/clamd "$@"
;;
freshclam)
echo "Starting ClamAV update daemon..."
set -- /usr/bin/freshclam -d -p "/run/clamav/freshclam.pid" "$@"
;;
*)
echo "Starting shell..."
set -- /bin/sh
;;
esac

exec su-exec clamav "$@"