Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expose websocket electrs API using websocat #6

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 9 additions & 18 deletions a808b51d0d9301fa82390b985c57551966001f9b/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,39 +1,30 @@
# Electrs build stage
FROM rust:latest AS electrs-builder
FROM rust:latest AS builder

ARG COMMIT=253040e346664976c12e6c214ee2858a4dad2e06

RUN apt-get update
RUN apt-get install -y clang cmake
RUN apt-get install -y clang cmake

RUN git clone https://github.com/blockstream/electrs && cd electrs && git checkout ${COMMIT}

WORKDIR /electrs

RUN cargo build --release --bin electrs

# websocat build stage
FROM rust:1.60-alpine3.15 as cargo-build
FROM debian:stable-slim AS websocat-installer

RUN apk add --no-cache musl-dev pkgconfig openssl-dev git

RUN git clone https://github.com/vi/websocat.git && cd websocat && git checkout v1.11.0

WORKDIR /websocat

ARG CARGO_OPTS="--features=workaround1,seqpacket,prometheus_peer,prometheus/process,crypto_peer"

RUN cargo build --release --target=x86_64-unknown-linux-musl $CARGO_OPTS && \
rm -f target/x86_64-unknown-linux-musl/release/deps/websocat*
RUN apt-get update
RUN apt-get install -y wget

RUN cargo build --release --target=x86_64-unknown-linux-musl $CARGO_OPTS && \
strip target/x86_64-unknown-linux-musl/release/websocat
COPY install-websocat.sh /install-websocat.sh
RUN chmod +x /install-websocat.sh && /install-websocat.sh

# Final stage
FROM debian:stable-slim

COPY --from=electrs-builder /electrs/target/release/electrs /usr/local/bin
COPY --from=cargo-build /websocat/target/x86_64-unknown-linux-musl/release/websocat /usr/local/bin
COPY --from=builder /electrs/target/release/electrs /usr/local/bin
COPY --from=websocat-installer /usr/local/bin/websocat /usr/local/bin

COPY entrypoint.sh /entrypoint.sh

Expand Down
13 changes: 11 additions & 2 deletions a808b51d0d9301fa82390b985c57551966001f9b/Dockerfile.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,21 @@ WORKDIR /electrs

RUN cargo build --features liquid --release --bin electrs

FROM debian:stable-slim AS websocat-installer

RUN apt-get update
RUN apt-get install -y wget

COPY install-websocat.sh /install-websocat.sh
louisinger marked this conversation as resolved.
Show resolved Hide resolved
RUN chmod +x /install-websocat.sh && /install-websocat.sh

FROM debian:stable-slim

WORKDIR /build

COPY --from=builder /electrs/target/release/electrs /build
COPY --from=builder /electrs/target/release/electrs /usr/local/bin
COPY --from=websocat-installer /usr/local/bin/websocat /usr/local/bin

STOPSIGNAL SIGINT

ENTRYPOINT ["/build/electrs"]
ENTRYPOINT ["bash", "/entrypoint.sh"]
2 changes: 1 addition & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#/!bin/bash
#!/bin/bash
set -m
electrs&
websocat -b ws-l:127.0.0.1:1234 tcp:127.0.0.1:50001&
louisinger marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
4 changes: 4 additions & 0 deletions install-websocat.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
wget https://github.com/vi/websocat/releases/download/v1.11.0/websocat.x86_64-unknown-linux-musl
chmod +x websocat.x86_64-unknown-linux-musl
mv websocat.x86_64-unknown-linux-musl /usr/local/bin/websocat