Skip to content

Commit

Permalink
Merge branch 'main' into scripts-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
iulianpascalau authored May 30, 2024
2 parents 6d0a326 + 4b426e6 commit 14a63b9
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 0 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
scripts/
28 changes: 28 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM golang:1.20.7-bookworm AS builder
COPY . /src
WORKDIR /src/cmd/monitor
RUN APPVERSION=$(git describe --tags --long --always | tail -c 11) && echo "package main\n\nfunc init() {\n\tappVersion = \"${APPVERSION}\"\n}" > local.go
RUN go build

FROM debian:bookworm-slim AS usermanager
ARG UID=10000
ARG GID=10000
ARG USERNAME="mx"
ARG PACKAGES="ca-certificates"
RUN apt-get update && apt-get upgrade && apt-get install -y ${PACKAGES}
RUN adduser --uid ${UID} ${USERNAME}

FROM scratch AS runner
ARG UID=10000
ARG GID=10000
ARG USERNAME="mx"
COPY --from=builder /lib/x86_64-linux-gnu/libc.so.6 /lib/x86_64-linux-gnu/libc.so.6
COPY --from=builder /lib64/ld-linux-x86-64.so.2 /lib64/ld-linux-x86-64.so.2
COPY --from=usermanager /etc/ssl/certs /etc/ssl/certs
COPY --from=usermanager /etc/passwd /etc/passwd
COPY --from=usermanager /etc/group /etc/group
USER ${USERNAME}
WORKDIR /home/mx
COPY --chown=${UID}:${GID} --from=builder /src/cmd/monitor/monitor /home/mx/monitor
ENTRYPOINT [ "/home/mx/monitor" ]

39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,45 @@ and the application will automatically fetch the registered BLS keys for that id

## Installation

You can choose to run this tool either in a Docker on in a systemd service.

### Docker Setup

You need to have [docker](https://docs.docker.com/engine/install/) installed on your machine.

Create a directory to save your configs in, and copy the 3 example files required for the tool to run :
```bash
mkdir <config_dir>
cp ./cmd/monitor/config/example/config.toml <config_dir>/config.toml
cp ./cmd/monitor/config/example/credentials.toml <config_dir>/credentials.toml
cp ./cmd/monitor/config/example/network1.list <config_dir>/network1.list
```

Customize your 3 files :
- config.toml is the tool global configuration
- credentials.toml is where you save your secrets
- network1.list is where you fill your addresses to monitor (⚠️ this file will be located in /network1.list in the container, **make sure to make this path correspond in the config.toml file** ⚠️)

Build the image, use the Dockerfile ;
```bash
docker buildx build -t mx-chain-keys-monitor-go:latest -f Dockerfile .
```

Then, edit the lines 7-9 in `./docker-compose.yml` :
- `<path>/<to>/<your>/config.toml:/config.toml:ro`
- `<path>/<to>/<your>/credentials.toml:/credentials.toml:ro`
- `<path>/<to>/<your>/network1.list:/network1.list:ro`
- You can append more networkX.list files if you want to

If you want to provide extra arguments to the tool, add them under the `command` object.

You're ready 🚀

```bash
docker compose up -d
```


### Initial setup

Although it's possible, it is not recommended to run the application as `root`. For that reason, a new user is required to be created.
Expand Down
13 changes: 13 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
services:
mx-chain-keys-monitor-go:
image: mx-chain-keys-monitor-go:latest
container_name: mx-chain-keys-monitor-go
volumes:
- ./cmd/monitor/config/example/config.toml:/config.toml:ro
- ./cmd/monitor/config/example/credentials.toml:/credentials.toml:ro
- ./cmd/monitor/config/example/network1.list:/network1.list:ro
restart: always
command:
- '--config=/config.toml'
- '--credentials=/credentials.toml'
- '-log-level=*:DEBUG'

0 comments on commit 14a63b9

Please sign in to comment.