Skip to content

Commit

Permalink
Bump CLN docker to v23.08 and other fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Reckless-Satoshi committed Sep 6, 2023
1 parent ae9fdd7 commit 627d2fa
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 24 deletions.
52 changes: 34 additions & 18 deletions docker/cln/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ RUN set -ex \

WORKDIR /opt

RUN wget -qO /opt/tini "https://github.com/krallin/tini/releases/download/v0.18.0/tini" \
&& echo "12d20136605531b09a2c2dac02ccee85e1b874eb322ef6baf7561cd93f93c855 /opt/tini" | sha256sum -c - \
&& chmod +x /opt/tini
RUN wget -qO /tini "https://github.com/krallin/tini/releases/download/v0.18.0/tini" \
&& echo "12d20136605531b09a2c2dac02ccee85e1b874eb322ef6baf7561cd93f93c855 /tini" | sha256sum -c - \
&& chmod +x /tini

ARG BITCOIN_VERSION=24.0.1
ENV BITCOIN_TARBALL bitcoin-${BITCOIN_VERSION}-x86_64-linux-gnu.tar.gz
Expand All @@ -39,8 +39,7 @@ RUN mkdir /opt/bitcoin && cd /opt/bitcoin \
FROM debian:bullseye-slim as builder
ARG DEBIAN_FRONTEND=noninteractive

ARG LIGHTNINGD_VERSION=v23.05.2

ARG LIGHTNINGD_VERSION=v23.08
RUN apt-get update -qq && \
apt-get install -qq -y --no-install-recommends \
autoconf \
Expand All @@ -55,13 +54,18 @@ RUN apt-get update -qq && \
libpq-dev \
libtool \
libffi-dev \
pkg-config \
libssl-dev \
protobuf-compiler \
python3 \
python3.9 \
python3-dev \
python3-mako \
python3-pip \
python3-venv \
python3-setuptools \
libev-dev \
libevent-dev \
qemu-user-static \
wget

# RUN apt-get install -y --no-install-recommends \
Expand All @@ -87,12 +91,12 @@ RUN apt-get install -y --no-install-recommends unzip tclsh \
&& make \
&& make install && cd .. && rm sqlite-src-3290000.zip && rm -rf sqlite-src-3290000

RUN wget -q https://gmplib.org/download/gmp/gmp-6.1.2.tar.xz \
&& tar xvf gmp-6.1.2.tar.xz \
&& cd gmp-6.1.2 \
&& ./configure --disable-assembly \
&& make \
&& make install && cd .. && rm gmp-6.1.2.tar.xz && rm -rf gmp-6.1.2
# RUN wget -q https://gmplib.org/download/gmp/gmp-6.1.2.tar.xz \
# && tar xvf gmp-6.1.2.tar.xz \
# && cd gmp-6.1.2 \
# && ./configure --disable-assembly \
# && make \
# && make install && cd .. && rm gmp-6.1.2.tar.xz && rm -rf gmp-6.1.2

ENV RUST_PROFILE=release
ENV PATH=$PATH:/root/.cargo/bin/
Expand All @@ -105,23 +109,29 @@ RUN git clone --recursive --branch $LIGHTNINGD_VERSION https://github.com/Elemen
RUN git clone --recursive /tmp/lightning . && \
git checkout $(git --work-tree=/tmp/lightning --git-dir=/tmp/lightning/.git rev-parse HEAD)

RUN cd /tmp/lightning/plugins/grpc-plugin \
&& cargo build --release --target-dir /tmp/lightning/grpc/target

RUN git clone --recursive --branch cln-grpc-hold https://github.com/daywalker90/lightning.git /tmp/cln-grpc-hold
RUN cd /tmp/cln-grpc-hold \
&& cargo build --release

ENV PYTHON_VERSION=3
RUN curl -sSL https://install.python-poetry.org | python3 - \
&& pip3 install -U pip \
&& pip3 install -U wheel \
&& /root/.local/bin/poetry install
RUN curl -sSL https://install.python-poetry.org | python3 -

RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.9 1

RUN pip3 install --upgrade pip setuptools wheel
RUN pip3 wheel cryptography
RUN pip3 install grpcio-tools

RUN ./configure --prefix=/tmp/lightning_install --enable-static && \
make DEVELOPER=${DEVELOPER} && \
/root/.local/bin/poetry run make install

FROM debian:bullseye-slim as final
RUN pip3 install -r plugins/clnrest/requirements.txt

COPY --from=downloader /opt/tini /usr/bin/tini
FROM debian:bullseye-slim as final

RUN apt-get update && \
apt-get install -y --no-install-recommends \
Expand All @@ -132,6 +142,10 @@ RUN apt-get update && \
libpq5 && \
rm -rf /var/lib/apt/lists/*


RUN pip3 install flask gunicorn json5
RUN pip3 install --user flask_restx pyln-client

ENV LIGHTNINGD_DATA=/root/.lightning
ENV LIGHTNINGD_RPC_PORT=9835
ENV LIGHTNINGD_PORT=9735
Expand All @@ -141,8 +155,10 @@ RUN mkdir $LIGHTNINGD_DATA && \
touch $LIGHTNINGD_DATA/config
VOLUME [ "/root/.lightning" ]
COPY --from=builder /tmp/lightning_install/ /usr/local/
COPY --from=builder /usr/local/lib/python3.9/dist-packages/ /usr/local/lib/python3.9/dist-packages/
COPY --from=builder /tmp/cln-grpc-hold/target/release/cln-grpc-hold /tmp/cln-grpc-hold
COPY --from=downloader /opt/bitcoin/bin /usr/bin
COPY --from=downloader "/tini" /usr/bin/tini
COPY config /tmp/config
COPY entrypoint.sh entrypoint.sh
RUN chmod +x entrypoint.sh
Expand Down
9 changes: 4 additions & 5 deletions robosats/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from django.conf import settings
from django.contrib.auth.models import AnonymousUser, User, update_last_login
from django.utils.deprecation import MiddlewareMixin
from django.db import IntegrityError
from rest_framework.authtoken.models import Token
from rest_framework.exceptions import AuthenticationFailed
from robohash import Robohash
Expand All @@ -31,6 +30,7 @@ def __call__(self, request):
response = self.get_response(request)
return response


class SplitAuthorizationHeaderMiddleware(MiddlewareMixin):
"""
This middleware splits the HTTP_AUTHORIZATION, leaves on it only the `Token ` and creates
Expand All @@ -44,12 +44,13 @@ class SplitAuthorizationHeaderMiddleware(MiddlewareMixin):
def process_request(self, request):
auth_header = request.META.get("HTTP_AUTHORIZATION", "")
split_auth = auth_header.split(" | ")

if len(split_auth) == 3:
request.META["HTTP_AUTHORIZATION"] = split_auth[0]
request.META["PUBLIC_KEY"] = split_auth[1]
request.META["ENCRYPTED_PRIVATE_KEY"] = split_auth[2]


class RobotTokenSHA256AuthenticationMiddleWare:
"""
Builds on django-rest-framework Token Authentication.
Expand All @@ -66,7 +67,6 @@ def __init__(self, get_response):
self.get_response = get_response

def __call__(self, request):

token_sha256_b91 = request.META.get("HTTP_AUTHORIZATION", "").replace(
"Token ", ""
)
Expand Down Expand Up @@ -95,7 +95,7 @@ def __call__(self, request):

public_key = ""
encrypted_private_key = ""

public_key = request.META.get("PUBLIC_KEY", "").replace("Public ", "")
encrypted_private_key = request.META.get(
"ENCRYPTED_PRIVATE_KEY", ""
Expand Down Expand Up @@ -143,7 +143,6 @@ def __call__(self, request):
# Generate avatar. Does not replace if existing.
image_path = avatar_path.joinpath(nickname + ".webp")
if not image_path.exists():

rh = Robohash(hash)
rh.assemble(roboset="set1", bgset="any") # for backgrounds ON
with open(image_path, "wb") as f:
Expand Down
1 change: 0 additions & 1 deletion robosats/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@
}



MIDDLEWARE = [
"corsheaders.middleware.CorsMiddleware",
"django.middleware.security.SecurityMiddleware",
Expand Down

0 comments on commit 627d2fa

Please sign in to comment.