Merge pull request #2 from ajilaag/develop

Develop
This commit is contained in:
Flavio Meyer 2020-10-28 13:38:49 +01:00 committed by GitHub
commit f1b9ac1027
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 2 deletions

View file

@ -3,6 +3,9 @@ FROM golang:alpine
# Update
RUN apk update upgrade;
# Install git
RUN apk add git
# Set timezone to Europe/Zurich
RUN apk add tzdata
RUN ln -s /usr/share/zoneinfo/Europe/Zurich /etc/localtime
@ -21,6 +24,8 @@ RUN freshclam --quiet --no-dns
# Build go package
ADD . /go/src/clamav-rest/
RUN go get github.com/dutchcoders/go-clamd
RUN go get github.com/prometheus/client_golang/prometheus/promhttp
ADD ./server.* /etc/ssl/clamav-rest/
RUN cd /go/src/clamav-rest && go build -v

View file

@ -8,8 +8,9 @@
- [Configuration](#configuration)
- [Environment Variables](#environment-variables)
- [Networking](#networking)
- [Maintenance](#maintenance)
- [Maintenance / Monitoring](#maintenance--monitoring)
- [Shell Access](#shell-access)
- [Developing](#developing)
- [References](#references)
@ -134,7 +135,7 @@ Below is the complete list of available options that can be used to customize yo
|-----------|-------------|
| `3310` | ClamD Listening Port |
# Maintenance
# Maintenance / Monitoring
## Shell Access
@ -143,6 +144,15 @@ For debugging and maintenance purposes you may want access the containers shell.
```bash
docker exec -it (whatever your container name is e.g. clamav-rest) /bin/sh
```
## Prometheus
[Prometheus metrics](https://prometheus.io/docs/guides/go-application/) were implemented, which can be retrieved as follows
**HTTP**:
curl http://localhost:9000/metrics
**HTTPS:**
curl https://localhost:9443/metrics
# Developing

View file

@ -12,6 +12,7 @@ import (
"time"
"github.com/dutchcoders/go-clamd"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
var opts map[string]string
@ -184,6 +185,9 @@ func main() {
http.HandleFunc("/scanPath", scanPathHandler)
http.HandleFunc("/", home)
// Prometheus metrics
http.Handle("/metrics", promhttp.Handler())
// Start the HTTPS server in a goroutine
go http.ListenAndServeTLS(SSL_PORT, "/etc/ssl/clamav-rest/server.crt", "/etc/ssl/clamav-rest/server.key", nil)