From 67b7814db9330e5b08b5770f676750b4cea5670c Mon Sep 17 00:00:00 2001 From: Sascha Greuel Date: Sat, 7 Oct 2023 08:23:29 +0200 Subject: [PATCH 1/6] chore(docker-clamav): update Dockerfile and entrypoint.sh - Update base image to alpine:3.18 - Update clamav version to 1.1.2-r0 and su-exec version to 0.2-r3 - Update docker-compose.yml to use version 3.8 - Remove unnecessary services from docker-compose.yml - Applied small optimizations, and style corrections --- .github/ISSUE_TEMPLATE/bug.yaml | 2 +- .github/ISSUE_TEMPLATE/documentation.yaml | 2 +- .github/ISSUE_TEMPLATE/feature.yaml | 2 +- .travis.yml | 2 +- Dockerfile | 18 ++++----- README.md | 20 +++++----- docker-compose.yml | 21 ++++++----- entrypoint.sh | 45 ++++++++++++----------- 8 files changed, 56 insertions(+), 56 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug.yaml b/.github/ISSUE_TEMPLATE/bug.yaml index 83a017a..c7ac0da 100644 --- a/.github/ISSUE_TEMPLATE/bug.yaml +++ b/.github/ISSUE_TEMPLATE/bug.yaml @@ -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 \ No newline at end of file + required: true diff --git a/.github/ISSUE_TEMPLATE/documentation.yaml b/.github/ISSUE_TEMPLATE/documentation.yaml index e0af55f..22ae588 100644 --- a/.github/ISSUE_TEMPLATE/documentation.yaml +++ b/.github/ISSUE_TEMPLATE/documentation.yaml @@ -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 \ No newline at end of file + required: true diff --git a/.github/ISSUE_TEMPLATE/feature.yaml b/.github/ISSUE_TEMPLATE/feature.yaml index 22cc52f..01877cc 100644 --- a/.github/ISSUE_TEMPLATE/feature.yaml +++ b/.github/ISSUE_TEMPLATE/feature.yaml @@ -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 \ No newline at end of file + required: true diff --git a/.travis.yml b/.travis.yml index 87f7db5..844416c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ --- notifications: email: - - team@appwrite.io + - team@appwrite.io language: minimal diff --git a/Dockerfile b/Dockerfile index c47fec0..19a2547 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/README.md b/README.md index ec0c53c..f452a51 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 @@ -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 diff --git a/docker-compose.yml b/docker-compose.yml index 46d02ff..932bacb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,26 +1,27 @@ ---- -version: '3.7' +version: "3.8" services: - freshclam: + base: build: . + volumes: + - conf:/etc/clamav + - data:/var/lib/clamav + + freshclam: + extends: + service: base environment: MODE: freshclam - volumes: - - conf:/etc/clamav - - data:/var/lib/clamav clamav: + extends: + service: base depends_on: - freshclam - build: . environment: MODE: clamd ulimits: stack: 1048576 - volumes: - - conf:/etc/clamav - - data:/var/lib/clamav ports: - "3310:3310" diff --git a/entrypoint.sh b/entrypoint.sh index a90b0ab..ce84c67 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -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 "$@" From b4bbdf06ef8b91ad3a022105e502516075ee094d Mon Sep 17 00:00:00 2001 From: Sascha Greuel Date: Sat, 7 Oct 2023 08:34:42 +0200 Subject: [PATCH 2/6] Use latest software at Travis CI --- .travis.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 844416c..a04ceee 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,3 @@ ---- notifications: email: - team@appwrite.io @@ -10,7 +9,10 @@ arch: - arm64 os: linux -dist: focal +dist: jammy + +env: + - DOCKER_COMPOSE_VERSION=v2.22.2 before_install: - curl -fsSL https://get.docker.com | sh @@ -23,6 +25,11 @@ before_install: echo "${DOCKERHUB_PULL_PASSWORD}" | docker login --username "${DOCKERHUB_PULL_USERNAME}" --password-stdin fi - docker --version + - sudo rm /usr/local/bin/docker-compose + - curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose + - chmod +x docker-compose + - sudo mv docker-compose /usr/local/bin + - docker-compose --version install: - docker-compose up -d From b42b34693d8d3656575a539bd5f3e65d09d2180f Mon Sep 17 00:00:00 2001 From: Sascha Greuel Date: Sat, 7 Oct 2023 08:40:17 +0200 Subject: [PATCH 3/6] Switch back to compose version 3.6 --- .travis.yml | 11 ++--------- docker-compose.yml | 2 +- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index a04ceee..844416c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,4 @@ +--- notifications: email: - team@appwrite.io @@ -9,10 +10,7 @@ arch: - arm64 os: linux -dist: jammy - -env: - - DOCKER_COMPOSE_VERSION=v2.22.2 +dist: focal before_install: - curl -fsSL https://get.docker.com | sh @@ -25,11 +23,6 @@ before_install: echo "${DOCKERHUB_PULL_PASSWORD}" | docker login --username "${DOCKERHUB_PULL_USERNAME}" --password-stdin fi - docker --version - - sudo rm /usr/local/bin/docker-compose - - curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose - - chmod +x docker-compose - - sudo mv docker-compose /usr/local/bin - - docker-compose --version install: - docker-compose up -d diff --git a/docker-compose.yml b/docker-compose.yml index 932bacb..c1c74af 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -version: "3.8" +version: "3.6" services: base: From a1a9299378cf3018be4796113709932533db30ab Mon Sep 17 00:00:00 2001 From: Sascha Greuel Date: Sat, 7 Oct 2023 08:50:02 +0200 Subject: [PATCH 4/6] Last try... --- .travis.yml | 16 +++++++++++++--- docker-compose.yml | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 844416c..b7eb70b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,3 @@ ---- notifications: email: - team@appwrite.io @@ -10,10 +9,16 @@ arch: - arm64 os: linux -dist: focal +dist: jammy + +env: + - DOCKER_COMPOSE_VERSION=v2.22.2 before_install: - - curl -fsSL https://get.docker.com | sh + - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - + - sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" + - sudo apt-get update + - sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce - echo '{"experimental":"enabled"}' | sudo tee /etc/docker/daemon.json - mkdir -p $HOME/.docker - echo '{"experimental":"enabled"}' | sudo tee $HOME/.docker/config.json @@ -23,6 +28,11 @@ before_install: echo "${DOCKERHUB_PULL_PASSWORD}" | docker login --username "${DOCKERHUB_PULL_USERNAME}" --password-stdin fi - docker --version + - sudo rm /usr/local/bin/docker-compose + - curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose + - chmod +x docker-compose + - sudo mv docker-compose /usr/local/bin + - docker-compose --version install: - docker-compose up -d diff --git a/docker-compose.yml b/docker-compose.yml index c1c74af..2a65ffa 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -version: "3.6" +version: "3.7" services: base: From 28fa05a9850b4cbbff00d20f5cb7aa6b87e1d77d Mon Sep 17 00:00:00 2001 From: Sascha Greuel Date: Sat, 7 Oct 2023 08:52:47 +0200 Subject: [PATCH 5/6] Reset .travis.yml --- .travis.yml | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index b7eb70b..844416c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,4 @@ +--- notifications: email: - team@appwrite.io @@ -9,16 +10,10 @@ arch: - arm64 os: linux -dist: jammy - -env: - - DOCKER_COMPOSE_VERSION=v2.22.2 +dist: focal before_install: - - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - - - sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" - - sudo apt-get update - - sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce + - curl -fsSL https://get.docker.com | sh - echo '{"experimental":"enabled"}' | sudo tee /etc/docker/daemon.json - mkdir -p $HOME/.docker - echo '{"experimental":"enabled"}' | sudo tee $HOME/.docker/config.json @@ -28,11 +23,6 @@ before_install: echo "${DOCKERHUB_PULL_PASSWORD}" | docker login --username "${DOCKERHUB_PULL_USERNAME}" --password-stdin fi - docker --version - - sudo rm /usr/local/bin/docker-compose - - curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose - - chmod +x docker-compose - - sudo mv docker-compose /usr/local/bin - - docker-compose --version install: - docker-compose up -d From d6431c378a3354c23ec8f6316eb7848a71b43faa Mon Sep 17 00:00:00 2001 From: Sascha Greuel Date: Sat, 7 Oct 2023 08:58:25 +0200 Subject: [PATCH 6/6] Partially reverted changes on docker-compose.yml --- .travis.yml | 3 +-- docker-compose.yml | 18 ++++++++---------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index 844416c..77f081e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,3 @@ ---- notifications: email: - team@appwrite.io @@ -10,7 +9,7 @@ arch: - arm64 os: linux -dist: focal +dist: jammy before_install: - curl -fsSL https://get.docker.com | sh diff --git a/docker-compose.yml b/docker-compose.yml index 2a65ffa..cc51766 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,27 +1,25 @@ -version: "3.7" +version: "3.8" services: - base: + freshclam: build: . + environment: + MODE: freshclam volumes: - conf:/etc/clamav - data:/var/lib/clamav - freshclam: - extends: - service: base - environment: - MODE: freshclam - clamav: - extends: - service: base + build: . depends_on: - freshclam environment: MODE: clamd ulimits: stack: 1048576 + volumes: + - conf:/etc/clamav + - data:/var/lib/clamav ports: - "3310:3310"