Skip to content

Commit caa5803

Browse files
authored
fix: Improve security for Redis container (#598)
* fix: Improving redis docker security * fix: Fixing docker examples * fix: Fixing docker files * fix: Fixing docker examples * fix: Fixing metrics example
1 parent 459a301 commit caa5803

27 files changed

Lines changed: 28 additions & 76 deletions

File tree

docker-compose.integration.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ services:
33
redis:
44
image: redis:7-alpine
55
container_name: integration-redis
6-
ports:
7-
- 6379:6379
6+
command:
7+
- redis-server
88
networks:
99
- integration
1010
healthcheck:

examples/basic-example-logging/docker-compose.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ services:
4040
restart: on-failure:5
4141
redis:
4242
image: redis:bookworm
43-
ports:
44-
- 6379:6379/tcp
4543
security_opt:
4644
- no-new-privileges
4745
volumes:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
REDIS_URL=redis://localhost:6379
1+
REDIS_URL=redis://redis:6379
22
API_KEY=
33
WEBHOOK_SIGNING_KEY=
44
KEYSTORE_PASSPHRASE=

examples/basic-example-metrics/README.md

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,14 @@
22

33
This guide demonstrates how to configure and use the OpenZeppelin Relayer service with metrics monitoring. In this example, we configure and utilize an Ethereum Sepolia Relayer integrated with Prometheus and Grafana for comprehensive performance tracking.
44

5-
65
## Getting Started
76

8-
97
### Prerequisites
108

119
- [Docker](https://docs.docker.com/get-docker/)
1210
- [Docker Compose](https://docs.docker.com/compose/install/)
1311
- Rust (for key generation tools)
1412

15-
1613
### Step 1: Clone the Repository
1714

1815
Clone this repository to your local machine:
@@ -22,7 +19,6 @@ git clone https://github.com/OpenZeppelin/openzeppelin-relayer
2219
cd openzeppelin-relayer
2320
```
2421

25-
2622
### Step 2: Create a Signer
2723

2824
Create a new signer keystore using the provided key generation tool:
@@ -36,28 +32,22 @@ cargo run --example create_key -- \
3632

3733
Note: Replace <DEFINE_YOUR_PASSWORD> with a strong password for the keystore.
3834

39-
4035
Create `examples/basic-example-metrics/.env` file from `examples/basic-example-metrics/.env.example`.
4136

4237
```bash
4338
cp examples/basic-example-metrics/.env.example examples/basic-example-metrics/.env
4439
```
4540

46-
4741
Then, update the `KEYSTORE_PASSPHRASE` field in the `examples/basic-example-metrics/.env` file with the password you used.
4842

49-
50-
5143
### Step 3: Configure Notifications
5244

53-
5445
#### Configure Webhook URL
5546

5647
`examples/basic-example-metrics/config/config.json` file is partially pre-configured. You need to specify the webhook URL that will receive updates from the relayer service.
5748

5849
For simplicity, visit [Webhook.site](https://webhook.site), copy your unique URL, and then update the notifications[0].url field in `examples/basic-example-metrics/config/config.json` with this value.
5950

60-
6151
#### Configure Webhook Signing Key
6252

6353
To sign webhook notification payloads, populate the `WEBHOOK_SIGNING_KEY` entry in the `examples/basic-example-metrics/.env` file.
@@ -67,12 +57,11 @@ For development purposes, you can generate the signing key using:
6757
```bash
6858
cargo run --example generate_uuid
6959
```
70-
> Note: Alternatively, you can use any online UUID generator.
7160

61+
> Note: Alternatively, you can use any online UUID generator.
7262
7363
Copy the generated UUID and update the `WEBHOOK_SIGNING_KEY` entry in the `examples/basic-example-metrics/.env` file.
7464

75-
7665
#### Configure Webhook Signing Key
7766

7867
To sign webhook notification payloads, populate the `WEBHOOK_SIGNING_KEY` entry in the `examples/basic-example/.env` file.
@@ -82,35 +71,31 @@ For development purposes, you can generate the signing key using:
8271
```bash
8372
cargo run --example generate_uuid
8473
```
85-
> Note: Alternatively, you can use any online UUID generator.
8674

75+
> Note: Alternatively, you can use any online UUID generator.
8776
8877
Copy the generated UUID and update the `WEBHOOK_SIGNING_KEY` entry in the `examples/basic-example/.env` file.
8978

90-
9179
### Step 4: Configure API Key
9280

9381
Generate an API key signing key for development purposes using:
9482

9583
```bash
9684
cargo run --example generate_uuid
9785
```
98-
> Note: Alternatively, you can use any online UUID generator.
9986

87+
> Note: Alternatively, you can use any online UUID generator.
10088
10189
Copy the generated UUID and update the `API_KEY` entry in the `examples/basic-example-metrics/.env` file.
10290

103-
104-
10591
### Step 5: Run the Service
10692

107-
Start the service with Docker Compose:
93+
Start the service with Docker Compose and metrics (Prometheus and Grafana):
10894

10995
```bash
110-
docker compose -f examples/basic-example-metrics/docker-compose.yaml up
96+
docker compose -f examples/basic-example-metrics/docker-compose.yaml --profile metrics up -d
11197
```
11298

113-
11499
### Step 6: Test the Relayer
115100

116101
The service is available at `http://localhost:8080/api/v1`
@@ -121,13 +106,13 @@ curl -X GET http://localhost:8080/api/v1/relayers \
121106
-H "AUTHORIZATION: Bearer YOUR_API_KEY"
122107
```
123108

124-
125109
### Step 7: Access Metrics Dashboards
126110

127111
- Prometheus is available at: http://localhost:9090
128112
- Grafana is available at: http://localhost:3000
129113

130114
The default Grafana login credentials are:
115+
131116
- Username: admin
132117
- Password: admin
133118

examples/basic-example-metrics/docker-compose.yaml

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ services:
3636
- metrics-network
3737
redis:
3838
image: redis:bookworm
39-
ports:
40-
- 6379:6379/tcp
4139
security_opt:
4240
- no-new-privileges
4341
volumes:
@@ -69,6 +67,8 @@ services:
6967
prometheus:
7068
container_name: openzeppelin-relayer-prometheus
7169
image: prom/prometheus:v3.1.0
70+
user: 65534:65534
71+
read_only: true
7272
security_opt:
7373
- no-new-privileges
7474
command: --log.level=warn --config.file=/etc/prometheus/prometheus.yml --storage.tsdb.path=/prometheus --storage.tsdb.retention.time=30d --web.console.libraries=/usr/share/prometheus/console_libraries --web.console.templates=/usr/share/prometheus/consoles
@@ -78,12 +78,17 @@ services:
7878
- metrics-network
7979
- relayer-network
8080
volumes:
81-
- ./cmd/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
81+
- ../../cmd/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
82+
- prometheus_data:/prometheus
83+
tmpfs:
84+
- /tmp
8285
restart: on-failure:5
8386
profiles:
8487
- metrics
8588
grafana:
8689
image: grafana/grafana:11.5.1
90+
user: 472:472
91+
read_only: true
8792
security_opt:
8893
- no-new-privileges
8994
ports:
@@ -92,9 +97,13 @@ services:
9297
- metrics-network
9398
- relayer-network
9499
volumes:
95-
- ./cmd/prometheus/grafana.ini:/etc/grafana/grafana.ini
96-
- ./cmd/prometheus/datasources:/etc/grafana/provisioning/datasources
97-
- ./cmd/prometheus/dashboards:/etc/grafana/provisioning/dashboards
100+
- ../../cmd/prometheus/grafana.ini:/etc/grafana/grafana.ini:ro
101+
- ../../cmd/prometheus/datasources:/etc/grafana/provisioning/datasources:ro
102+
- ../../cmd/prometheus/dashboards:/etc/grafana/provisioning/dashboards:ro
103+
- grafana_data:/var/lib/grafana
104+
tmpfs:
105+
- /tmp
106+
- /var/log/grafana
98107
restart: on-failure:5
99108
profiles:
100109
- metrics
@@ -106,6 +115,10 @@ networks:
106115
volumes:
107116
redis_data:
108117
driver: local
118+
prometheus_data:
119+
driver: local
120+
grafana_data:
121+
driver: local
109122
secrets:
110123
api_key:
111124
environment: API_KEY

examples/basic-example-plugin/docker-compose.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ services:
3131
restart: on-failure:5
3232
redis:
3333
image: redis:bookworm
34-
ports:
35-
- 6379:6379/tcp
3634
security_opt:
3735
- no-new-privileges
3836
volumes:

examples/basic-example/docker-compose.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ services:
3131
restart: on-failure:5
3232
redis:
3333
image: redis:bookworm
34-
ports:
35-
- 6379:6379/tcp
3634
security_opt:
3735
- no-new-privileges
3836
volumes:

examples/channels-plugin-example/docker-compose.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ services:
4444
restart: on-failure:5
4545
redis:
4646
image: redis:bookworm
47-
ports:
48-
- 6379:6379/tcp
4947
security_opt:
5048
- no-new-privileges
5149
volumes:

examples/evm-aws-kms-signer/docker-compose.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ services:
3434
restart: on-failure:5
3535
redis:
3636
image: redis:bookworm
37-
ports:
38-
- 6379:6379/tcp
3937
security_opt:
4038
- no-new-privileges
4139
volumes:

examples/evm-cdp-signer/docker-compose.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ services:
2727
restart: on-failure:5
2828
redis:
2929
image: redis:bookworm
30-
ports:
31-
- 6379:6379/tcp
3230
security_opt:
3331
- no-new-privileges
3432
volumes:

0 commit comments

Comments
 (0)