Expose API during Docker deployment

Open
#488 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
docker
Domain
api, devops

Research direction

Start with the README Docker instructions and /srv/explorer/run.sh, focusing on how the API port 3000 is bound inside the container and why the documented port mapping does not provide external access. Done means the existing Docker deployment can expose the API externally, while preserving the web interface behavior.

Written by the indexing model from the issue text.

Description

I am running the esplora Docker image as per the README with the API port exposed:

$ docker run -p 50001:50001 -p 8094:80 -p 3000:3000 \ 
--volume $PWD/data_bitcoin_regtest:/data \
--rm -i -t -e  blockstream/esplora bash -c "/srv/explorer/run.sh bitcoin-regtest explorer"

But in this configuration, there is no access to the API from the outside, which I would want. I have tried all kinds of hacks, but it seems there is no way to do this without creating a custom electrs Docker image? As per this and this issue.

Accessing the API fails (it is set to 127.0.0.1:3000 instead of 0.0.0.0:3000, so understandable, but why not changeable?):

$ curl localhost:3000
curl: (56) Recv failure: Connection reset by peer

Trying access through the web interface just returns HTML:

$ curl http://localhost:8094/api/blocks/tip/
<!DOCTYPE html><head><meta charset="utf-8"><title>Bitcoin Regtest Explorer</title>......

Any help would be appreciated. Is there an easy way to expose the API?

Dominant language
JavaScript
Stars
1.3k
Forks
527
Avg merge
2d 5h
Merged PRs (30d)
4

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Blockstream/esplora

All issues in Blockstream/esplora

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.