Skip to content
Open
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
47 changes: 47 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Use the latest version of Go as the base image
FROM golang:1.23.12 AS base

# Install needed dependencies for base image and update certs
RUN apt-get update \
&& apt-get install -y ca-certificates \
&& update-ca-certificates

# create a build artifact
FROM base AS builder
# Set the working directory to the root of the project
WORKDIR /app

# Copy the Go dependencies file and download the dependencies
COPY go.mod .
COPY go.sum .
RUN go mod download

# Copy the Makefile and the rest of the source code
COPY .git ./.git
COPY . ./

# Build the application with static linking for Alpine
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o telemetry .

# Create a new, smaller image based on alpine
FROM alpine:latest

# Install ca-certificates for HTTPS support
RUN apk --no-cache add ca-certificates

# Create a non-root user
RUN addgroup -g 1001 telemetry && \
adduser -D -s /bin/sh -u 1001 -G telemetry telemetry

# Make dir for mounting config file and set ownership
RUN mkdir -p /home/telemetry/.telemetry/config && \
chown -R telemetry:telemetry /home/telemetry

# Copy the built executable from the builder image and set ownership
COPY --from=builder /app/telemetry /app/telemetry
RUN chown telemetry:telemetry /app/telemetry

# Switch to the non-root user
USER telemetry

ENTRYPOINT ["/app/telemetry"]
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,14 @@ If you are running Heimdall v2 (where the version API endpoint has changed), fol

After these steps, your telemetry exporter will be compatible with the new Heimdall v2 version API.

## Build Docker Image

```
docker buildx build --platform linux/amd64 -t matic-telemetry .
```

## Run Docker Image
Run matic-telemetry with the config file in the current directory:
```
docker run --name matic-telemetry -v config.toml:/home/telemetry/.telemetry/config/config.toml matic-telemetry
```
23 changes: 18 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,19 +1,32 @@
module github.com/vitwit/matic-telemetry

go 1.15
go 1.21.13

require (
github.com/gorilla/websocket v1.4.2
github.com/sirupsen/logrus v1.8.1
github.com/spf13/viper v1.7.1
gopkg.in/go-playground/validator.v9 v9.31.0
)

require (
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/go-playground/locales v0.13.0 // indirect
github.com/go-playground/universal-translator v0.17.0 // indirect
github.com/gorilla/websocket v1.4.2
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/sirupsen/logrus v1.8.1
github.com/magiconair/properties v1.8.1 // indirect
github.com/mitchellh/mapstructure v1.1.2 // indirect
github.com/pelletier/go-toml v1.2.0 // indirect
github.com/spf13/afero v1.1.2 // indirect
github.com/spf13/cast v1.3.0 // indirect
github.com/spf13/jwalterweatherman v1.0.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.7.1
github.com/stretchr/testify v1.7.0 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c // indirect
golang.org/x/text v0.3.3 // indirect
gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
gopkg.in/go-playground/validator.v9 v9.31.0
gopkg.in/ini.v1 v1.51.0 // indirect
gopkg.in/yaml.v2 v2.3.0 // indirect
)