diff --git a/Dockerfile b/Dockerfile index 322bf76..07bbe20 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,19 @@ -FROM golang:1.3 +FROM alpine +MAINTAINER Niilo Ursin -ADD . /go/src/github.com/osterzel/clamrest +RUN apk --no-cache add clamav clamav-libunrar \ + && mkdir /run/clamav \ + && chown clamav:clamav /run/clamav -WORKDIR /go/src/github.com/osterzel/clamrest -RUN go get -RUN go install github.com/osterzel/clamrest -RUN rm -rf /go/src/github.com/osterzel/clamrest +RUN sed -i 's/^#Foreground .*$/Foreground true/g' /etc/clamav/clamd.conf \ + && sed -i 's/^#TCPSocket .*$/TCPSocket 3310/g' /etc/clamav/clamd.conf \ + && sed -i 's/^#Foreground .*$/Foreground true/g' /etc/clamav/freshclam.conf -ENTRYPOINT /go/bin/clamrest +RUN freshclam --quiet -EXPOSE 8080 +COPY entrypoint.sh /usr/bin/ +COPY clamav-rest /usr/bin/ + +EXPOSE 9000 + +ENTRYPOINT [ "entrypoint.sh" ] \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..41622dc --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,24 @@ +#!/bin/sh +freshclam -d & +clamd & +sleep 20 +/usr/bin/clamav-rest & + +pids=`jobs -p` + +exitcode=0 + +terminate() { + for pid in $pids; do + if ! kill -0 $pid 2>/dev/null; then + wait $pid + exitcode=$? + fi + done + kill $pids 2>/dev/null +} + +trap terminate CHLD +wait + +exit $exitcode