modify to single docker image for clamav-rest

This commit is contained in:
Niilo Ursin 2017-08-28 23:18:08 +03:00
parent 6c8586f48e
commit 5784f5fc5f
2 changed files with 39 additions and 8 deletions

View file

@ -1,12 +1,19 @@
FROM golang:1.3
FROM alpine
MAINTAINER Niilo Ursin <niilo.ursin+nospam_github@gmail.com>
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" ]

24
entrypoint.sh Executable file
View file

@ -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