1
0
mirror of https://github.com/romanz/electrs.git synced 2024-11-19 09:54:09 +01:00

Merge branch 'fix-dockerfile'

This commit is contained in:
Roman Zeyde 2021-03-25 16:02:06 +02:00
commit 779fdca0cc
No known key found for this signature in database
GPG Key ID: 87CAE5FA46917CBB
2 changed files with 37 additions and 13 deletions

View File

@ -1,27 +1,32 @@
FROM rust:1.44.1-slim-buster as builder
WORKDIR /build
RUN apt-get update \
&& apt-get install -y --no-install-recommends clang=1:7.* cmake=3.* \
libsnappy-dev=1.* curl \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
&& apt-get install -y --no-install-recommends clang=1:7.* cmake=3.* \
libsnappy-dev=1.* \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN adduser --disabled-login --system --shell /bin/false --uid 1000 user
WORKDIR /home/user
COPY . .
RUN chown -R user .
RUN cargo install --locked --path .
# Create runtime image
FROM debian:buster-slim
RUN adduser --disabled-login --system --shell /bin/false --uid 1000 user
WORKDIR /app
WORKDIR /home/user/app
RUN chown user .
COPY --from=builder /home/user/target/release .
RUN apt-get update \
&& apt-get install -y --no-install-recommends curl \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /build/target/release .
RUN groupadd -r user \
&& adduser --disabled-login --system --shell /bin/false --uid 1000 --ingroup user user \
&& chown -R user:user /app
USER user
@ -35,4 +40,4 @@ STOPSIGNAL SIGINT
HEALTHCHECK CMD curl -fSs http://localhost:4224/ || exit 1
ENTRYPOINT ["./electrs", "-vvvv", "--timestamp"]
ENTRYPOINT ["./electrs"]

View File

@ -131,16 +131,35 @@ If you installed `cfg_me` to generate man page, you can run `cfg_me man` to see
Note: currently Docker installation links statically
Note: health check only works if Prometheus is running on port 4224 inside container
```bash
$ docker build -t electrs-app .
$ mkdir db
$ docker run --network host \
--volume $HOME/.bitcoin:/home/user/.bitcoin:ro \
--volume $PWD/db:/home/user/db \
--env ELECTRS_VERBOSE=4 \
--env ELECTRS_TIMESTAMP=true \
--env ELECTRS_DB_DIR=/home/user/db \
--rm -i -t electrs-app
```
If not using the host-network, you probably want to expose the ports for electrs and Prometheus like so:
```bash
$ docker run --volume $HOME/.bitcoin:/home/user/.bitcoin:ro \
--volume $PWD/db:/home/user/db \
--env ELECTRS_VERBOSE=4 \
--env ELECTRS_TIMESTAMP=true \
--env ELECTRS_DB_DIR=/home/user/db \
--env ELECTRS_ELECTRUM_RPC_ADDR=0.0.0.0:50001 \
--env ELECTRS_MONITORING_ADDR=0.0.0.0:4224 \
--rm -i -t electrs-app
```
To access the server from outside Docker, add `-p 50001:50001 -p 4224:4224` but be aware of the security risks. Good practice is to group containers that needs access to the server inside the same Docker network and not expose the ports to the outside world.
## Native OS packages
There are currently no official/stable binary packages.