Skip to content
This repository was archived by the owner on Oct 3, 2023. It is now read-only.

Develop #2

Merged
merged 4 commits into from
Oct 28, 2020
Merged
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
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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

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

Expand Down
4 changes: 4 additions & 0 deletions clamrest.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"time"

"github.com/dutchcoders/go-clamd"
"github.com/prometheus/client_golang/prometheus/promhttp"
)

var opts map[string]string
Expand Down Expand Up @@ -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)

Expand Down