Skip to content

Commit

Permalink
Added Docker Build and Publish workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitriy-b committed Oct 7, 2024
1 parent 6b74ecb commit 2b97459
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 1 deletion.
43 changes: 43 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Docker Build and Publish

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Log in to the Container registry
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,26 @@ go build .
./jrpc-interceptor -debug=${LOG_SERVER_DEBUG:-true} -listenSyslog=${LOG_SERVER_URL:-"0.0.0.0:514"} -listenHTTP=${PROMETHEUS_URL:-"0.0.0.0:9100"} -usePrometheus=${USE_PROMETHEUS:-true}
```

### Download docker image from github container registry

1. Create a [personal access token ](https://github.com/settings/tokens)(PAT) on github with repo access
2. Set the PAT as an environment variable

```
export CR_PAT=<your_pat>
```
3. Login to github container registry

```
echo $CR_PAT | docker login ghcr.io -u USERNAME --password-stdin
```

4. Download the image

```
docker pull ghcr.io/NethermindEth/jrpc-interceptor:main
```

## Nginx configuration
All the configuration can be found inside the `nginx` folder.

Expand Down Expand Up @@ -104,7 +124,7 @@ The interceptor publishes the following metrics:
- `ngx_request_size_bytes` - the size of the request;
- `ngx_response_size_bytes` - the size of the response;
- `ngx_request_duration_seconds` - the time of the request;
```
For the `ngx_request_duration_seconds` metric, we use `$request_time` value.
It's the time between the first bytes were read from the client and the log write after the last bytes were sent to the client.

Expand Down

0 comments on commit 2b97459

Please sign in to comment.