Skip to content

Commit be4b2da

Browse files
feat: optimize websocket implementation (#1)
1 parent 6b301ba commit be4b2da

File tree

7 files changed

+205
-170
lines changed

7 files changed

+205
-170
lines changed

Cargo.lock

+133-48
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+10-9
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,20 @@ version = "0.1.0"
44
edition = "2021"
55

66
[dependencies]
7-
tokio = { version = "1.42.0", features = ["full"] }
8-
tokio-tungstenite = { version = "0.26.1", features = ["native-tls"] }
9-
tungstenite = "0.26.1"
10-
futures-util = "0.3.31"
11-
serde_json = "1.0.135"
127
bigdecimal = "0.4.7"
138
borsh = { version = "1.5.3", features = ["derive"] }
9+
bytes = "1.9.0"
10+
clap = { version = "4.5", features = ["derive"] }
11+
dotenvy = "0.15"
1412
hex = "0.4.3"
13+
native-tls = "0.2.13"
14+
ratchet_rs = { version = "1.2.1", features = ["deflate"] }
15+
serde_json = "1.0.135"
1516
solana-client = "2.1.7"
16-
solana-sdk = "2.1.7"
1717
solana-program = "2.1.7"
18-
clap = { version = "4.5", features = ["derive"] }
19-
dotenvy = "0.15"
18+
solana-sdk = "2.1.7"
19+
tokio = { version = "1.42.0", features = ["full"] }
20+
tokio-native-tls = "0.3.1"
2021
tracing = "0.1"
2122
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
22-
23+
url = "2.5.4"

Dockerfile

+6-37
Original file line numberDiff line numberDiff line change
@@ -4,45 +4,14 @@ COPY src ./src
44
COPY Cargo.toml Cargo.lock ./
55
RUN cargo build --release
66

7-
FROM python:3.7-slim-bookworm AS runtime
8-
WORKDIR /app
9-
10-
# Install Nginx && python3
11-
RUN apt-get update && apt-get install -y nginx nodejs npm && \
12-
npm install -g wscat && \
13-
apt-get clean && \
14-
rm -rf /var/lib/apt/lists/*
15-
16-
COPY --from=builder /app/target/release/ephemeral-pricing-oracle /usr/local/bin
17-
COPY proxy.py /app/proxy.py
18-
COPY requirements.txt /app/requirements.txt
7+
FROM debian:bookworm-slim AS runtime
198

20-
# Create a virtual environment and install Python dependencies
21-
RUN python3 -m venv /app/venv && \
22-
/app/venv/bin/pip install --upgrade pip && \
23-
/app/venv/bin/pip install -r /app/requirements.txt
9+
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates && \
10+
apt-get clean && rm -rf /var/lib/apt/lists/* \
2411

25-
ENV ORACLE_AUTH_HEADER="Basic bWFnaWNibG9ja3M6ZHJ5LXNsaWRlLW92ZXJ0LWNvbG91cg=="
12+
WORKDIR /app
2613

27-
# Configure Nginx for WebSocket proxying
28-
#RUN echo 'server { \
29-
# listen 8765; \
30-
# server_name localhost; \
31-
# location / { \
32-
# proxy_pass https://api.jp.stork-oracle.network/evm/subscribe; \
33-
# proxy_http_version 1.1; \
34-
# proxy_set_header Upgrade $http_upgrade; \
35-
# proxy_set_header Connection "upgrade"; \
36-
# proxy_set_header Host $host; \
37-
# proxy_set_header X-Real-IP $remote_addr; \
38-
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; \
39-
# proxy_set_header X-Forwarded-Proto $scheme; \
40-
# proxy_set_header Authorization $http_authorization; \
41-
# proxy_pass_request_headers on; \
42-
# proxy_ssl_verify off; \
43-
# } \
44-
#}' > /etc/nginx/conf.d/default.conf
14+
COPY --from=builder /app/target/release/ephemeral-pricing-oracle /usr/local/bin
4515

4616
# Start the application
47-
CMD ["sh", "-c", "/app/venv/bin/python proxy.py & /usr/local/bin/ephemeral-pricing-oracle"]
48-
#CMD ["sh", "-c", "/usr/local/bin/ephemeral-pricing-oracle"]
17+
CMD ["sh", "-c", "/usr/local/bin/ephemeral-pricing-oracle"]

0 commit comments

Comments
 (0)