diff --git a/.gitignore b/.gitignore index 2eea525..bd2c2c0 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -.env \ No newline at end of file +.env +./listener/src/tmp/* \ No newline at end of file diff --git a/README.md b/README.md index ec0a98c..9a10b2c 100644 --- a/README.md +++ b/README.md @@ -1 +1,18 @@ -# validator-monitoring \ No newline at end of file +# validator-monitoring + +## Description + +This repository contains the code for the validator monitoring system. The system is designed to listen signatures request from different networks validate them and store the results in a database. + +## Running the system + +**Requirements:** + +- docker +- docker-compose + +**Steps:** + +1. Clone the repository +2. Run `docker-compose up` (production) or `docker compose -f docker-compose.dev.yml up` (development) in the root directory of the repository +3. Access database UI at `http://localhost:8081`. diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml new file mode 100644 index 0000000..44d8551 --- /dev/null +++ b/docker-compose.dev.yml @@ -0,0 +1,25 @@ +version: "3.9" + +services: + listener: + extends: + file: docker-compose.yml + service: listener + build: + context: listener + dockerfile: Dockerfile.dev + volumes: + - ./listener/src:/app/src + + mongo: + extends: + file: docker-compose.yml + service: mongo + + ui: + extends: + file: docker-compose.yml + service: ui + +volumes: + mongo-data: diff --git a/docker-compose.yml b/docker-compose.yml index 0747a74..d19bdae 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,6 +4,7 @@ services: listener: build: context: listener + dockerfile: Dockerfile ports: - "8080:8080" environment: @@ -30,6 +31,8 @@ services: depends_on: - mongo container_name: ui + ports: + - "8081:8081" # required for mac os access UI mongo: build: diff --git a/listener/Dockerfile.dev b/listener/Dockerfile.dev new file mode 100644 index 0000000..2460faf --- /dev/null +++ b/listener/Dockerfile.dev @@ -0,0 +1,35 @@ +# Start from the latest golang base image +FROM golang:1.22.0-alpine3.19 + +# Set the Current Working Directory inside the container. +WORKDIR /app + +# Install system dependencies required for Air and your application +RUN apk add --no-cache git + +# Install Air +RUN go install github.com/cosmtrek/air@latest + +# Copy the Air configuration file (if you have one) into the container. +# If you don't have a custom .air.toml, you can skip this step, +# and Air will use its default configuration. +# COPY .air.toml . (Uncomment if you have a custom Air config) + +# Copy go module files. +COPY go.mod . +COPY go.sum . + +# Download dependencies. +# Doing this before copying the entire source code +# utilizes Docker's cache to speed up builds. +RUN go mod download + +# Expect source code to be mounted at this directory rather than copied +# This is the change for development mode. +VOLUME ["/app/src"] + +# Set the Current Working Directory inside the container to the src directory. +WORKDIR /app/src + +# Command to run the application using Air for live reloading. +CMD ["air"] \ No newline at end of file diff --git a/listener/src/main.go b/listener/src/main.go index 33c3b88..20debde 100644 --- a/listener/src/main.go +++ b/listener/src/main.go @@ -7,7 +7,7 @@ import ( ) func main() { - + logger.Info("Starting listener") // Load config config, err := config.LoadConfig() if err != nil {