Skip to content

Commit

Permalink
implement dev mode (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
pablomendezroyo authored Apr 8, 2024
1 parent 681ed15 commit 3a6c663
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.env
.env
./listener/src/tmp/*
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,18 @@
# validator-monitoring
# 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`.
25 changes: 25 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -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:
3 changes: 3 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ services:
listener:
build:
context: listener
dockerfile: Dockerfile
ports:
- "8080:8080"
environment:
Expand All @@ -30,6 +31,8 @@ services:
depends_on:
- mongo
container_name: ui
ports:
- "8081:8081" # required for mac os access UI

mongo:
build:
Expand Down
35 changes: 35 additions & 0 deletions listener/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -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"]
2 changes: 1 addition & 1 deletion listener/src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

func main() {

logger.Info("Starting listener")
// Load config
config, err := config.LoadConfig()
if err != nil {
Expand Down

0 comments on commit 3a6c663

Please sign in to comment.