Skip to content

Commit

Permalink
Add build workflow, expand Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
gnpar committed Sep 18, 2024
1 parent 97c21e5 commit a424189
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .env.sample
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
NODE_HTTPS_URL=https://polygon-mainnet.g.alchemy.com/v2/TOKEN
NODE_HTTPS_URL=https://polygon-bor-rpc.publicnode.com
INJECT_POA_MIDDLEWARE=True

MAX_BLOCK_AGE=30
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/build-push-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Build and Push Docker Image to Google Artifact Registry

on:
push:
branches-ignore:
- "**"
tags:
- v*
workflow_dispatch:
inputs:
version:
description: "Docker image version tag"
required: true

run-name: ${{ github.event_name == 'workflow_dispatch' && format('Build (@{1}) inputs={0}', tojson(inputs), github.ref_name) || '' }}

env:
IMAGE: solid-range-319205/ensuro/eth-exporter
REGISTRY_HOSTNAME: us-docker.pkg.dev

jobs:
build-push:
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- name: Build and push
uses: ensuro/github-actions/[email protected]
with:
registry: "${{ env.REGISTRY_HOSTNAME }}"
image: "${{ env.IMAGE }}"
google_credentials: "${{ secrets.GOOGLE_CREDENTIALS }}"
additional_tag: "${{ github.event.inputs.version }}"
34 changes: 34 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM python:3.10-slim

# Alternatives for APP_ENV:
# - production: for production deployment
# - development: for local develpment environment
# - ci: for continous integration environment

RUN adduser --system --no-create-home --home=/app app

ARG APP_ENV="production"
ENV APP_ENV $APP_ENV

Check warning on line 11 in Dockerfile

View workflow job for this annotation

GitHub Actions / build-push

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/

COPY . /app
WORKDIR /app

# Required since we don't copy the .git folder into the image.
# Production image should be built with `--arg=DOCKER_METADATA_OUTPUT_VERSION=$(python setup.py --version)` to inject the correct version into the package.
ARG DOCKER_METADATA_OUTPUT_VERSION=0.0.1-beta1
ENV SETUPTOOLS_SCM_PRETEND_VERSION=$DOCKER_METADATA_OUTPUT_VERSION

RUN if [ $APP_ENV = "production" ]; then \
pip install . \
&& rm -rf /app \
&& mkdir -p /app; \
else \
pip install -e .; \
fi


EXPOSE 8000

USER app

ENTRYPOINT ["python", "-m", "eth_exporter.exporter"]
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

Prometheus exporter of blockchain data

## Running with docker

A `compose.yaml` file is provided to run the app + prometheus and grafana in docker.

1. Copy the sample config to be used: `cp .env.sample .env`
2. Start the containers: `docker compose up`
3. Services will be available on these urls:
- Exporter: http://localhost:8000/metrics
- Prometheus: http://localhost:9090
- Grafana: http://localhost:3000 (credentials admin:grafana)

<!-- pyscaffold-notes -->

## Note
Expand Down
13 changes: 13 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
services:
devcontainer:
build:
context: .

command: python -m eth_exporter.exporter
env_file: .env

volumes:
- ./samples:/app/samples

ports:
- 8000:8000

prometheus:
image: prom/prometheus
container_name: prometheus
Expand Down

0 comments on commit a424189

Please sign in to comment.