From da297b4f6a0533a121dfa1a43a494c089621dd1b Mon Sep 17 00:00:00 2001 From: Bill Date: Sun, 15 Sep 2024 18:41:07 -0400 Subject: [PATCH] Initial Commit --- .gitea/workflows/build.yaml | 48 +++++++++++++++++++++++++++++++++++++ Dockerfile | 34 ++++++++++++++++++++++++++ README.md | 31 ++++++++++++++++++++++++ bin/init | 7 ++++++ 4 files changed, 120 insertions(+) create mode 100644 .gitea/workflows/build.yaml create mode 100644 Dockerfile create mode 100644 README.md create mode 100644 bin/init diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml new file mode 100644 index 0000000..4a96043 --- /dev/null +++ b/.gitea/workflows/build.yaml @@ -0,0 +1,48 @@ +name: Build +run-name: Build Docker Image +on: [push, pull_request] + +jobs: + + build: + + runs-on: ubuntu-20.04 + + env: + VERSION: 1.16.0 + + steps: + + - name: Install docker + uses: papodaca/install-docker-action@main + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Checkout + uses: actions/checkout@v4 + + - name: Login into Registry + uses: docker/login-action@v3 + with: + registry: https://git.prettyhefty.com + username: ${{ gitea.repository_owner }} + password: ${{ secrets.REGISTRY_TOKEN }} + + - name: Prepare Meta + id: prepare + run: | + PLATFORM="linux/amd64" + REPO=${{ gitea.repository }} + + echo ::set-output name=build_date::$(date -u +'%Y-%m-%dT%H:%M:%SZ') + echo ::set-output name=docker_platform::${PLATFORM} + echo ::set-output name=repository::${REPO,,} + echo ::set-output name=version::${VERSION} + + - name: Build Docker image + uses: docker/build-push-action@v6 + with: + platforms: ${{ steps.prepare.outputs.docker_platform }} + push: true + tags: git.prettyhefty.com/${{ steps.prepare.outputs.repository }}:${{ steps.prepare.outputs.version }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f9230d0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,34 @@ +ARG VERSION=1.16.0 + +FROM python:3.7-alpine3.11 +LABEL maintainer="Bill Ballou " + +ARG VERSION + +COPY ./bin /usr/local/bin + +RUN chmod a+x /usr/local/bin/* && \ + apk add --no-cache git build-base openssl && \ + apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/v3.11/main leveldb-dev && \ + apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing rocksdb-dev && \ + pip install aiohttp pylru plyvel websockets python-rocksdb uvloop && \ + git clone -b $VERSION https://github.com/spesmilo/electrumx.git && \ + cd electrumx && \ + python setup.py install && \ + apk del git build-base && \ + rm -rf /tmp/* + +VOLUME ["/data"] +ENV HOME /data +ENV ALLOW_ROOT 1 +ENV EVENT_LOOP_POLICY uvloop +ENV DB_DIRECTORY /data +ENV SERVICES=tcp://:50001,ssl://:50002,wss://:50004,rpc://0.0.0.0:8000 +ENV SSL_CERTFILE ${DB_DIRECTORY}/electrumx.crt +ENV SSL_KEYFILE ${DB_DIRECTORY}/electrumx.key +ENV HOST "" +WORKDIR /data + +EXPOSE 50001 50002 50004 8000 + +CMD ["init"] \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..366d16b --- /dev/null +++ b/README.md @@ -0,0 +1,31 @@ + +# electrumx-docker + +Docker image for running an Electrum server. + +## Usage + +``` +docker run \ + -v /home/username/electrumx:/data \ + -e DAEMON_URL=http://user:pass@host:port \ + -e COIN=BitcoinSegwit \ + -p 50002:50002 \ + lukechilds/electrumx +``` + +If there's an SSL certificate/key (`electrumx.crt`/`electrumx.key`) in the `/data` volume it'll be used. If not, one will be generated for you. + +View all ElectrumX environment variables here: https://github.com/spesmilo/electrumx/blob/master/docs/environment.rst + +### TCP Port + +By default only the SSL port is exposed. Expose the unencrypted TCP port with `-p 50001:50001`. + +### WebSocket Port + +Expose the WebSocket port with `-p 50004:50004`. + +### RPC Port + +To access RPC from your host machine, expose port 8000: `-p 127.0.0.1:8000:8000`. \ No newline at end of file diff --git a/bin/init b/bin/init new file mode 100644 index 0000000..6534e22 --- /dev/null +++ b/bin/init @@ -0,0 +1,7 @@ +#!/bin/sh + +if [ ! -e "${SSL_CERTFILE}" ] || [ ! -e "${SSL_KEYFILE}" ]; then + openssl req -newkey rsa:2048 -sha256 -nodes -x509 -days 365 -subj "/O=ElectrumX" -keyout "${SSL_KEYFILE}" -out "${SSL_CERTFILE}" +fi + +exec /electrumx/electrumx_server \ No newline at end of file